summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2021-02-25 20:44:36 -0500
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>2021-02-25 23:33:30 -0500
commit940502b3debaba2b03b23dcf6615cc88729a3d61 (patch)
treefd4275adca4b27d868ca874260ca1cdfcc132b7a /test
parent26b4b395e91c76e7168751d8de269f7b9eec3912 (diff)
downloadlibfaketime-940502b3debaba2b03b23dcf6615cc88729a3d61.tar.gz
Added snippet for syscall(__NR_clock_gettime)
Closes: #176
Diffstat (limited to 'test')
-rw-r--r--test/snippets/include_headers.h1
-rw-r--r--test/snippets/syscall_clock_gettime.c8
-rw-r--r--test/snippets/syscall_clock_gettime.variable1
3 files changed, 10 insertions, 0 deletions
diff --git a/test/snippets/include_headers.h b/test/snippets/include_headers.h
index 0c1bd85..55cd48f 100644
--- a/test/snippets/include_headers.h
+++ b/test/snippets/include_headers.h
@@ -5,3 +5,4 @@
#include <sys/syscall.h>
#include <string.h>
#include <errno.h>
+#include <time.h>
diff --git a/test/snippets/syscall_clock_gettime.c b/test/snippets/syscall_clock_gettime.c
new file mode 100644
index 0000000..21b99ba
--- /dev/null
+++ b/test/snippets/syscall_clock_gettime.c
@@ -0,0 +1,8 @@
+struct timespec ts;
+clockid_t ckid = CLOCK_REALTIME;
+long ret = syscall(__NR_clock_gettime, ckid, &ts);
+if (ret == 0)
+ printf("[%s] syscall(__NR_gettime, CLOCK_REALTIME[%d], &ts) -> {%lld, %ld}\n", where, ckid, (long long)ts.tv_sec, ts.tv_nsec);
+else
+ printf("[%s] syscall(__NR_gettime, CLOCK_REALTIME[%d], &ts) returned non-zero (%ld)\n", where, ckid, ret);
+
diff --git a/test/snippets/syscall_clock_gettime.variable b/test/snippets/syscall_clock_gettime.variable
new file mode 100644
index 0000000..e89e166
--- /dev/null
+++ b/test/snippets/syscall_clock_gettime.variable
@@ -0,0 +1 @@
+FAKETIME 2020-01-01 00:00:00