2 * Copyright (C) 2005, 2007, 2009-2024 Free Software Foundation, Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Jim Meyering and Bruno Haible. */
23 #include "signature.h"
24 SIGNATURE_CHECK (gettimeofday
, int,
25 (struct timeval
*, GETTIMEOFDAY_TIMEZONE
*));
44 gettimeofday (&tv
, NULL
);
45 if (memcmp (lt
, &saved_lt
, sizeof (struct tm
)) != 0)
47 fprintf (stderr
, "gettimeofday still clobbers the localtime buffer!\n");
60 ASSERT (gettimeofday (&tv1
, NULL
) == 0);
62 ASSERT (gettimeofday (&tv3
, NULL
) == 0);
65 /* Verify monotonicity of gettimeofday(). */
66 ASSERT (tv1
.tv_sec
< tv3
.tv_sec
67 || (tv1
.tv_sec
== tv3
.tv_sec
&& tv1
.tv_usec
<= tv3
.tv_usec
));
69 /* Verify monotonicity of time(). */
72 /* Verify that the tv_sec field of the result is the same as time(NULL). */
73 /* Note: It's here that the dependency to the 'time' module is needed.
74 Without it, this assertion would sometimes fail on glibc systems, see
75 https://sourceware.org/bugzilla/show_bug.cgi?id=30200 */
76 ASSERT (tv1
.tv_sec
<= tt2
);
77 ASSERT (tt2
<= tv3
.tv_sec
);
78 ASSERT (tv3
.tv_sec
<= tt4
);
87 return test_exit_status
;