]>
Commit | Line | Data |
---|---|---|
51983996 | 1 | /* Support code for timespec checks. |
d614a753 | 2 | Copyright (C) 2019-2020 Free Software Foundation, Inc. |
51983996 MC |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with the GNU C Library; if not, see | |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
51983996 MC |
18 | |
19 | #include <support/timespec.h> | |
20 | #include <stdio.h> | |
eb669ff5 | 21 | #include <stdint.h> |
51983996 MC |
22 | |
23 | void | |
24 | test_timespec_before_impl (const char *file, int line, | |
25 | const struct timespec left, | |
26 | const struct timespec right) | |
27 | { | |
28 | if (left.tv_sec > right.tv_sec | |
29 | || (left.tv_sec == right.tv_sec | |
30 | && left.tv_nsec > right.tv_nsec)) { | |
31 | support_record_failure (); | |
32 | const struct timespec diff = timespec_sub (left, right); | |
eb669ff5 | 33 | printf ("%s:%d: %jd.%09jds not before %jd.%09jds " |
b62bb3bc | 34 | "(difference %jd.%09jds)\n", |
51983996 | 35 | file, line, |
eb669ff5 AZ |
36 | (intmax_t) left.tv_sec, (intmax_t) left.tv_nsec, |
37 | (intmax_t) right.tv_sec, (intmax_t) right.tv_nsec, | |
38 | (intmax_t) diff.tv_sec, (intmax_t) diff.tv_nsec); | |
51983996 MC |
39 | } |
40 | } | |
41 | ||
42 | void | |
43 | test_timespec_equal_or_after_impl (const char *file, int line, | |
44 | const struct timespec left, | |
45 | const struct timespec right) | |
46 | { | |
47 | if (left.tv_sec < right.tv_sec | |
48 | || (left.tv_sec == right.tv_sec | |
49 | && left.tv_nsec < right.tv_nsec)) { | |
50 | support_record_failure (); | |
51 | const struct timespec diff = timespec_sub (right, left); | |
eb669ff5 | 52 | printf ("%s:%d: %jd.%09jds not after %jd.%09jds " |
b62bb3bc | 53 | "(difference %jd.%09jds)\n", |
51983996 | 54 | file, line, |
eb669ff5 AZ |
55 | (intmax_t) left.tv_sec, (intmax_t) left.tv_nsec, |
56 | (intmax_t) right.tv_sec, (intmax_t) right.tv_nsec, | |
57 | (intmax_t) diff.tv_sec, (intmax_t) diff.tv_nsec); | |
51983996 MC |
58 | } |
59 | } |