diff options
| author | Florian Weimer <fweimer@redhat.com> | 2024-08-16 16:05:20 +0200 |
|---|---|---|
| committer | Florian Weimer <fweimer@redhat.com> | 2024-08-16 16:05:20 +0200 |
| commit | bf2927484152e12996af60ea439cf94b66fcd81d (patch) | |
| tree | 10b66543486ca858cfe88fb204dbc0df67c27f36 /io/tst-lutimes.c | |
| parent | 921690512946d73bf66a8c495baff31316e4489f (diff) | |
io: Use struct statx and xstatx in tests
This avoids the need to define struct_statx to an appropriate
struct stat type variant because struct statx does not change
based on time/file offset flags.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'io/tst-lutimes.c')
| -rw-r--r-- | io/tst-lutimes.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/io/tst-lutimes.c b/io/tst-lutimes.c index edef5ab90e..78bcc58291 100644 --- a/io/tst-lutimes.c +++ b/io/tst-lutimes.c @@ -18,34 +18,32 @@ #include <support/check.h> #include <support/xunistd.h> +#include <fcntl.h> #include <sys/stat.h> #include <sys/time.h> -#ifndef struct_stat -# define struct_stat struct stat64 -#endif - static int test_lutimes_helper (const char *testfile, int fd, const char *testlink, const struct timeval *tv) { - struct_stat stfile_orig; - xlstat (testfile, &stfile_orig); + struct statx stfile_orig; + xstatx (AT_FDCWD, testfile, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, + &stfile_orig); TEST_VERIFY_EXIT (lutimes (testlink, tv) == 0); - struct_stat stlink; - xlstat (testlink, &stlink); + struct statx stlink; + xstatx (AT_FDCWD, testlink, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, &stlink); - TEST_COMPARE (stlink.st_atime, tv[0].tv_sec); - TEST_COMPARE (stlink.st_mtime, tv[1].tv_sec); + TEST_COMPARE (stlink.stx_atime.tv_sec, tv[0].tv_sec); + TEST_COMPARE (stlink.stx_mtime.tv_sec, tv[1].tv_sec); /* Check if the timestamp from original file is not changed. */ - struct_stat stfile; - xlstat (testfile, &stfile); + struct statx stfile; + xstatx (AT_FDCWD, testfile, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, &stfile); - TEST_COMPARE (stfile_orig.st_atime, stfile.st_atime); - TEST_COMPARE (stfile_orig.st_mtime, stfile.st_mtime); + TEST_COMPARE (stfile_orig.stx_atime.tv_sec, stfile.stx_atime.tv_sec); + TEST_COMPARE (stfile_orig.stx_mtime.tv_sec, stfile.stx_mtime.tv_sec); return 0; } |
