]> git.ipfire.org Git - thirdparty/glibc.git/blob - io/test-stat.c
f6cf85a38b9807c23c2c3ea8d6fcb5403aff58b1
[thirdparty/glibc.git] / io / test-stat.c
1 /* Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Contributed by Maciej W. Rozycki <macro@ds2.pg.gda.pl>, 2000.
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
19 /* We need to define:
20 #define _FILE_OFFSET_BITS 64
21 #define _LARGEFILE64_SOURCE 1
22 */
23
24 #include <assert.h>
25 #include <stddef.h>
26 #include <sys/stat.h>
27
28 static int
29 do_test (void)
30 {
31 /* With _FILE_OFFSET_BITS=64 struct stat and struct stat64 should
32 be identical. */
33 assert (sizeof (struct stat)
34 == sizeof (struct stat64));
35 assert (offsetof (struct stat, st_dev)
36 == offsetof (struct stat64, st_dev));
37 assert (offsetof (struct stat, st_ino)
38 == offsetof (struct stat64, st_ino));
39 assert (offsetof (struct stat, st_mode)
40 == offsetof (struct stat64, st_mode));
41 assert (offsetof (struct stat, st_nlink)
42 == offsetof (struct stat64, st_nlink));
43 assert (offsetof (struct stat, st_uid)
44 == offsetof (struct stat64, st_uid));
45 assert (offsetof (struct stat, st_gid)
46 == offsetof (struct stat64, st_gid));
47 assert (offsetof (struct stat, st_rdev)
48 == offsetof (struct stat64, st_rdev));
49 assert (offsetof (struct stat, st_size)
50 == offsetof (struct stat64, st_size));
51 assert (offsetof (struct stat, st_atime)
52 == offsetof (struct stat64, st_atime));
53 assert (offsetof (struct stat, st_mtime)
54 == offsetof (struct stat64, st_mtime));
55 assert (offsetof (struct stat, st_ctime)
56 == offsetof (struct stat64, st_ctime));
57 assert (offsetof (struct stat, st_blksize)
58 == offsetof (struct stat64, st_blksize));
59 assert (offsetof (struct stat, st_blocks)
60 == offsetof (struct stat64, st_blocks));
61 #if 0
62 /* Some systems have st_fstype but not all. Don't check it for now. */
63 assert (offsetof (struct stat, st_fstype)
64 == offsetof (struct stat64, st_fstype));
65 #endif
66 return 0;
67 }
68
69 #define TEST_FUNCTION do_test ()
70 #include "../test-skeleton.c"