1 /* Support code for timespec checks.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <support/timespec.h>
24 test_timespec_before_impl (const char *file
, int line
,
25 const struct timespec left
,
26 const struct timespec right
)
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
);
33 printf ("%s:%d: %jd.%09jds not before %jd.%09jds "
34 "(difference %jd.%09jds)\n",
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
);
43 test_timespec_equal_or_after_impl (const char *file
, int line
,
44 const struct timespec left
,
45 const struct timespec right
)
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
);
52 printf ("%s:%d: %jd.%09jds not after %jd.%09jds "
53 "(difference %jd.%09jds)\n",
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
);