]>
Commit | Line | Data |
---|---|---|
9871ae0a | 1 | /* Test for utimes |
dff8da6b | 2 | Copyright (C) 2021-2024 Free Software Foundation, Inc. |
9871ae0a LM |
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 | |
17 | <https://www.gnu.org/licenses/>. */ | |
18 | ||
9871ae0a LM |
19 | #include <support/check.h> |
20 | #include <support/xunistd.h> | |
bf292748 | 21 | #include <fcntl.h> |
f8466cc5 AZ |
22 | #include <sys/stat.h> |
23 | #include <sys/time.h> | |
24 | #include <time.h> | |
9871ae0a LM |
25 | |
26 | static int | |
f8466cc5 | 27 | test_utimes_helper (const char *file, int fd, const struct timeval *tv) |
9871ae0a | 28 | { |
f8466cc5 | 29 | int result = utimes (file, tv); |
9871ae0a LM |
30 | TEST_VERIFY_EXIT (result == 0); |
31 | ||
bf292748 FW |
32 | struct statx st; |
33 | xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st); | |
9871ae0a LM |
34 | |
35 | /* Check if seconds for atime match */ | |
bf292748 | 36 | TEST_COMPARE (st.stx_atime.tv_sec, tv[0].tv_sec); |
9871ae0a LM |
37 | |
38 | /* Check if seconds for mtime match */ | |
bf292748 | 39 | TEST_COMPARE (st.stx_mtime.tv_sec, tv[1].tv_sec); |
9871ae0a LM |
40 | |
41 | return 0; | |
42 | } | |
43 | ||
272e71dc | 44 | #define TEST_CALL(fname, fd, lname, v1, v2) \ |
f8466cc5 AZ |
45 | test_utimes_helper (fname, fd, (struct timeval[]) { { v1, 0 }, \ |
46 | { v2, 0 } }) | |
9871ae0a | 47 | |
f8466cc5 | 48 | #include "tst-utimensat-skeleton.c" |