]> granicus.if.org Git - strace/blob - tests/localtime.c
strace: terminate itself if interrupted by a signal
[strace] / tests / localtime.c
1 /*
2  * Check handling of localtime() returning NULL in printleader().
3  *
4  * Copyright (c) 2018 The strace developers.
5  * All rights reserved.
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9
10 #include "tests.h"
11
12 #include <assert.h>
13 #include <stdio.h>
14 #include <time.h>
15 #include <unistd.h>
16
17 #include <asm/unistd.h>
18
19 int
20 main(void)
21 {
22         struct timespec ts;
23         int pid;
24
25         assert(!clock_gettime(CLOCK_REALTIME, &ts));
26
27         pid = syscall(__NR_gettid);
28
29         /* We expect localtime to fail here */
30         printf("%lld.%06ld gettid() = %d\n",
31                (long long) ts.tv_sec, (long) (ts.tv_nsec / 1000), pid);
32
33         printf("%lld.%06ld +++ exited with 0 +++\n",
34                (long long) ts.tv_sec, (long) (ts.tv_nsec / 1000));
35
36         return 0;
37 }