[CRIU] [PATCH 3/4 v2] test: poll -- Use gettimeofday syscall directly

Cyrill Gorcunov gorcunov at gmail.com
Thu Mar 26 01:29:20 PDT 2015


On Thu, Mar 26, 2015 at 11:23:14AM +0300, Cyrill Gorcunov wrote:
> The gettimeofday uses /etc/localtime (thanks avagin@
> for the hint) which is not present in namespace tests.
> So lets use syscall directly and make test pass in
> namespace environment as well.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>

There were a small nit. Update attached.
-------------- next part --------------
>From 678c3803c2144567a70db8182c6c2b2959e00bd6 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Thu, 26 Mar 2015 10:38:35 +0300
Subject: [PATCH 3/4 v2] test: poll -- Use gettimeofday syscall directly

The gettimeofday uses /etc/localtime (thanks avagin@
for the hint) which is not present in namespace tests.
So lets use syscall directly and make test pass in
namespace environment as well.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
diff --git a/test/zdtm/live/static/poll.c b/test/zdtm/live/static/poll.c
index 85f545593b6e..37fcaf19e6fb 100644
--- a/test/zdtm/live/static/poll.c
+++ b/test/zdtm/live/static/poll.c
@@ -19,6 +19,17 @@
 const char *test_doc	= "Check poll() timeouts";
 const char *test_author	= "Cyrill Gorcunov <gorcunov at parallels.com>";
 
+#ifdef __x86_64__
+#define __NR_gettimeofday 96
+#else
+#define __NR_gettimeofday 78
+#endif
+
+static int sys_gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+	return syscall(__NR_gettimeofday, tv, tz);
+}
+
 static void show_timestamp(char *prefix, unsigned long tv_sec, unsigned long tv_usec)
 {
 	test_msg("%8s: sec %20lu nsec %20lu\n", prefix, tv_sec, tv_usec);
@@ -61,7 +72,7 @@ int main(int argc, char *argv[])
 
 	show_pollfd(ufds, 2);
 
-	if (gettimeofday(&time1, NULL)) {
+	if (sys_gettimeofday(&time1, NULL)) {
 		err("Can't get first delta");
 		exit(1);
 	}
@@ -72,7 +83,7 @@ int main(int argc, char *argv[])
 		err("Fork failed");
 		exit(1);
 	} else if (pid == 0) {
-		if (gettimeofday(&time1, NULL)) {
+		if (sys_gettimeofday(&time1, NULL)) {
 			err("Can't get from times");
 			exit(1);
 		}
@@ -89,7 +100,7 @@ int main(int argc, char *argv[])
 				exit(1);
 			}
 
-			if (gettimeofday(&time2, NULL)) {
+			if (sys_gettimeofday(&time2, NULL)) {
 				err("Can't get from times");
 				exit(1);
 			}
-- 
1.9.3



More information about the CRIU mailing list