]> granicus.if.org Git - strace/blob - tests/time.c
tests: change the license to GPL-2.0-or-later
[strace] / tests / time.c
1 /*
2  * This file is part of time strace test.
3  *
4  * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
5  * Copyright (c) 2015-2017 The strace developers.
6  * All rights reserved.
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10
11 #include "tests.h"
12 #include <asm/unistd.h>
13
14 #ifdef __NR_time
15
16 # include <time.h>
17 # include <stdio.h>
18 # include <stdint.h>
19 # include <unistd.h>
20
21 int
22 main(void)
23 {
24         TAIL_ALLOC_OBJECT_CONST_PTR(time_t, p);
25
26         time_t t = syscall(__NR_time, NULL);
27         if ((time_t) -1 == t)
28                 perror_msg_and_skip("time");
29         printf("time(NULL) = %lld (", (long long) t);
30         print_time_t_nsec(t, 0, 0);
31         puts(")");
32
33         t = syscall(__NR_time, p + 1);
34         printf("time(%p) = %s\n", p + 1, sprintrc(t));
35
36         t = syscall(__NR_time, p);
37         printf("time([%lld", (long long) *p);
38         print_time_t_nsec((time_t) *p, 0, 1),
39         printf("]) = %lld (", (long long) t);
40         print_time_t_nsec(t, 0, 0);
41         puts(")");
42
43         puts("+++ exited with 0 +++");
44         return 0;
45 }
46
47 #else
48
49 SKIP_MAIN_UNDEFINED("__NR_time")
50
51 #endif