diff options
author | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2021-03-02 10:26:20 -0500 |
---|---|---|
committer | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2021-03-02 10:26:20 -0500 |
commit | a3f9410e51e42c7f8025fcd9f22a17c718224475 (patch) | |
tree | eff87a842085880e812e446e9319edabbc1a32a6 | |
parent | a92d6ffe7c2bb867bdbc71d6a24dcadb3798f2db (diff) | |
download | libfaketime-a3f9410e51e42c7f8025fcd9f22a17c718224475.tar.gz |
Add clock_gettime_heap snippet
This invokes clock_gettime, but uses a timespec from the heap instead
of the stack.
-rw-r--r-- | test/snippets/clock_gettime_heap.c | 8 | ||||
-rw-r--r-- | test/snippets/clock_gettime_heap.variable | 1 | ||||
-rw-r--r-- | test/snippets/include_headers.h | 1 |
3 files changed, 10 insertions, 0 deletions
diff --git a/test/snippets/clock_gettime_heap.c b/test/snippets/clock_gettime_heap.c new file mode 100644 index 0000000..11ae827 --- /dev/null +++ b/test/snippets/clock_gettime_heap.c @@ -0,0 +1,8 @@ +struct timespec *ts = malloc(sizeof(struct timespec)); +clockid_t ckid = CLOCK_REALTIME; +int ret = clock_gettime(ckid, ts); +if (ret == 0) { + printf("[%s] clock_gettime_heap(CLOCK_REALTIME[%d], ts) -> {%lld, %ld}\n", where, ckid, (long long)ts->tv_sec, ts->tv_nsec); + } else { + printf("[%s] clock_gettime_heap(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_heap.variable b/test/snippets/clock_gettime_heap.variable new file mode 100644 index 0000000..3f75b5f --- /dev/null +++ b/test/snippets/clock_gettime_heap.variable @@ -0,0 +1 @@ +FAKETIME 2020-02-02 02:02:02+00:00 diff --git a/test/snippets/include_headers.h b/test/snippets/include_headers.h index 55cd48f..1c329bc 100644 --- a/test/snippets/include_headers.h +++ b/test/snippets/include_headers.h @@ -6,3 +6,4 @@ #include <string.h> #include <errno.h> #include <time.h> +#include <stdlib.h> |