[CRIU] [PATCH 3/4] test: poll -- Use gettimeofday syscall directly
Cyrill Gorcunov
gorcunov at openvz.org
Thu Mar 26 01:23:14 PDT 2015
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>
---
test/zdtm/live/static/poll.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/test/zdtm/live/static/poll.c b/test/zdtm/live/static/poll.c
index 85f545593b6e..db4b427ce3e2 100644
--- a/test/zdtm/live/static/poll.c
+++ b/test/zdtm/live/static/poll.c
@@ -19,6 +19,24 @@
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)
+{
+ int ret;
+
+ ret = syscall(__NR_gettimeofday, tv, tz);
+ if (ret) {
+ errno = -ret;
+ ret = -1;
+ }
+ return ret;
+}
+
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 +79,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 +90,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 +107,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