summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2021-03-02 10:23:11 -0500
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>2021-03-02 10:23:11 -0500
commita92d6ffe7c2bb867bdbc71d6a24dcadb3798f2db (patch)
tree20b0c44b89e1ffe2ecb9b851636fcff09c4b58ff
parent253774c8d87de6623c0bcedb7a5bfedae0f4bc85 (diff)
downloadlibfaketime-a92d6ffe7c2bb867bdbc71d6a24dcadb3798f2db.tar.gz
add snippet testing clock_gettime(CLOCK_REALTIME)
-rw-r--r--test/snippets/clock_gettime.c8
-rw-r--r--test/snippets/clock_gettime.variable1
2 files changed, 9 insertions, 0 deletions
diff --git a/test/snippets/clock_gettime.c b/test/snippets/clock_gettime.c
new file mode 100644
index 0000000..94f3629
--- /dev/null
+++ b/test/snippets/clock_gettime.c
@@ -0,0 +1,8 @@
+struct timespec ts;
+clockid_t ckid = CLOCK_REALTIME;
+int ret = clock_gettime(ckid, &ts);
+if (ret == 0) {
+ printf("[%s] clock_gettime(CLOCK_REALTIME[%d], &ts) -> {%lld, %ld}\n", where, ckid, (long long)ts.tv_sec, ts.tv_nsec);
+ } else {
+ printf("[%s] clock_gettime(CLOCK_REALTIME[%d], &ts) returned non-zero (%d), errno = %d (%s)\n", where, ckid, ret, errno, strerror(errno));
+ }
diff --git a/test/snippets/clock_gettime.variable b/test/snippets/clock_gettime.variable
new file mode 100644
index 0000000..3f75b5f
--- /dev/null
+++ b/test/snippets/clock_gettime.variable
@@ -0,0 +1 @@
+FAKETIME 2020-02-02 02:02:02+00:00