VirtualBox

source: kBuild/vendor/sed/current/gnulib-tests/test-sys_stat.c@ 3613

Last change on this file since 3613 was 3611, checked in by bird, 7 months ago

vendor/sed/current: GNU sed 4.9 (sed-4.9.tar.xz sha256:6e226b732e1cd739464ad6862bd1a1aba42d7982922da7a53519631d24975181)

File size: 8.1 KB
Line 
1/* Test of <sys/stat.h> substitute.
2 Copyright (C) 2007-2022 Free Software Foundation, Inc.
3
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.
8
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.
13
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/>. */
16
17/* Written by Bruno Haible <[email protected]>, 2007. */
18
19#include <config.h>
20
21#include <sys/stat.h>
22
23/* Check the existence of some macros. */
24int a[] =
25 {
26 S_IFMT,
27#ifdef S_IFBLK /* missing on MSVC */
28 S_IFBLK,
29#endif
30 S_IFCHR, S_IFDIR, S_IFIFO, S_IFREG,
31#ifdef S_IFLNK /* missing on native Windows and DJGPP */
32 S_IFLNK,
33#endif
34#ifdef S_IFSOCK /* missing on native Windows and DJGPP */
35 S_IFSOCK,
36#endif
37 S_IRWXU, S_IRUSR, S_IWUSR, S_IXUSR,
38 S_IRWXG, S_IRGRP, S_IWGRP, S_IXGRP,
39 S_IRWXO, S_IROTH, S_IWOTH, S_IXOTH,
40 S_ISUID, S_ISGID, S_ISVTX,
41 S_ISBLK (S_IFREG),
42 S_ISCHR (S_IFREG),
43 S_ISDIR (S_IFREG),
44 S_ISFIFO (S_IFREG),
45 S_ISREG (S_IFREG),
46 S_ISLNK (S_IFREG),
47 S_ISSOCK (S_IFREG),
48 S_ISDOOR (S_IFREG),
49 S_ISMPB (S_IFREG),
50 S_ISMPX (S_IFREG),
51 S_ISNAM (S_IFREG),
52 S_ISNWK (S_IFREG),
53 S_ISPORT (S_IFREG),
54 S_ISCTG (S_IFREG),
55 S_ISOFD (S_IFREG),
56 S_ISOFL (S_IFREG),
57 S_ISWHT (S_IFREG)
58 };
59
60/* Sanity checks. */
61
62static_assert (S_IRWXU == (S_IRUSR | S_IWUSR | S_IXUSR));
63static_assert (S_IRWXG == (S_IRGRP | S_IWGRP | S_IXGRP));
64static_assert (S_IRWXO == (S_IROTH | S_IWOTH | S_IXOTH));
65
66#ifdef S_IFBLK
67static_assert (S_ISBLK (S_IFBLK));
68#endif
69static_assert (!S_ISBLK (S_IFCHR));
70static_assert (!S_ISBLK (S_IFDIR));
71static_assert (!S_ISBLK (S_IFIFO));
72static_assert (!S_ISBLK (S_IFREG));
73#ifdef S_IFLNK
74static_assert (!S_ISBLK (S_IFLNK));
75#endif
76#ifdef S_IFSOCK
77static_assert (!S_ISBLK (S_IFSOCK));
78#endif
79
80#ifdef S_IFBLK
81static_assert (!S_ISCHR (S_IFBLK));
82#endif
83static_assert (S_ISCHR (S_IFCHR));
84static_assert (!S_ISCHR (S_IFDIR));
85static_assert (!S_ISCHR (S_IFIFO));
86static_assert (!S_ISCHR (S_IFREG));
87#ifdef S_IFLNK
88static_assert (!S_ISCHR (S_IFLNK));
89#endif
90#ifdef S_IFSOCK
91static_assert (!S_ISCHR (S_IFSOCK));
92#endif
93
94#ifdef S_IFBLK
95static_assert (!S_ISDIR (S_IFBLK));
96#endif
97static_assert (!S_ISDIR (S_IFCHR));
98static_assert (S_ISDIR (S_IFDIR));
99static_assert (!S_ISDIR (S_IFIFO));
100static_assert (!S_ISDIR (S_IFREG));
101#ifdef S_IFLNK
102static_assert (!S_ISDIR (S_IFLNK));
103#endif
104#ifdef S_IFSOCK
105static_assert (!S_ISDIR (S_IFSOCK));
106#endif
107
108#ifdef S_IFBLK
109static_assert (!S_ISFIFO (S_IFBLK));
110#endif
111static_assert (!S_ISFIFO (S_IFCHR));
112static_assert (!S_ISFIFO (S_IFDIR));
113static_assert (S_ISFIFO (S_IFIFO));
114static_assert (!S_ISFIFO (S_IFREG));
115#ifdef S_IFLNK
116static_assert (!S_ISFIFO (S_IFLNK));
117#endif
118#ifdef S_IFSOCK
119static_assert (!S_ISFIFO (S_IFSOCK));
120#endif
121
122#ifdef S_IFBLK
123static_assert (!S_ISREG (S_IFBLK));
124#endif
125static_assert (!S_ISREG (S_IFCHR));
126static_assert (!S_ISREG (S_IFDIR));
127static_assert (!S_ISREG (S_IFIFO));
128static_assert (S_ISREG (S_IFREG));
129#ifdef S_IFLNK
130static_assert (!S_ISREG (S_IFLNK));
131#endif
132#ifdef S_IFSOCK
133static_assert (!S_ISREG (S_IFSOCK));
134#endif
135
136#ifdef S_IFBLK
137static_assert (!S_ISLNK (S_IFBLK));
138#endif
139static_assert (!S_ISLNK (S_IFCHR));
140static_assert (!S_ISLNK (S_IFDIR));
141static_assert (!S_ISLNK (S_IFIFO));
142static_assert (!S_ISLNK (S_IFREG));
143#ifdef S_IFLNK
144static_assert (S_ISLNK (S_IFLNK));
145#endif
146#ifdef S_IFSOCK
147static_assert (!S_ISLNK (S_IFSOCK));
148#endif
149
150#ifdef S_IFBLK
151static_assert (!S_ISSOCK (S_IFBLK));
152#endif
153static_assert (!S_ISSOCK (S_IFCHR));
154static_assert (!S_ISSOCK (S_IFDIR));
155static_assert (!S_ISSOCK (S_IFIFO));
156static_assert (!S_ISSOCK (S_IFREG));
157#ifdef S_IFLNK
158static_assert (!S_ISSOCK (S_IFLNK));
159#endif
160#ifdef S_IFSOCK
161static_assert (S_ISSOCK (S_IFSOCK));
162#endif
163
164#ifdef S_IFBLK
165static_assert (!S_ISDOOR (S_IFBLK));
166#endif
167static_assert (!S_ISDOOR (S_IFCHR));
168static_assert (!S_ISDOOR (S_IFDIR));
169static_assert (!S_ISDOOR (S_IFIFO));
170static_assert (!S_ISDOOR (S_IFREG));
171#ifdef S_IFLNK
172static_assert (!S_ISDOOR (S_IFLNK));
173#endif
174#ifdef S_IFSOCK
175static_assert (!S_ISDOOR (S_IFSOCK));
176#endif
177
178#ifdef S_IFBLK
179static_assert (!S_ISMPB (S_IFBLK));
180#endif
181static_assert (!S_ISMPB (S_IFCHR));
182static_assert (!S_ISMPB (S_IFDIR));
183static_assert (!S_ISMPB (S_IFIFO));
184static_assert (!S_ISMPB (S_IFREG));
185#ifdef S_IFLNK
186static_assert (!S_ISMPB (S_IFLNK));
187#endif
188#ifdef S_IFSOCK
189static_assert (!S_ISMPB (S_IFSOCK));
190#endif
191
192#ifdef S_IFBLK
193static_assert (!S_ISMPX (S_IFBLK));
194#endif
195static_assert (!S_ISMPX (S_IFCHR));
196static_assert (!S_ISMPX (S_IFDIR));
197static_assert (!S_ISMPX (S_IFIFO));
198static_assert (!S_ISMPX (S_IFREG));
199#ifdef S_IFLNK
200static_assert (!S_ISMPX (S_IFLNK));
201#endif
202#ifdef S_IFSOCK
203static_assert (!S_ISMPX (S_IFSOCK));
204#endif
205
206#ifdef S_IFBLK
207static_assert (!S_ISNAM (S_IFBLK));
208#endif
209static_assert (!S_ISNAM (S_IFCHR));
210static_assert (!S_ISNAM (S_IFDIR));
211static_assert (!S_ISNAM (S_IFIFO));
212static_assert (!S_ISNAM (S_IFREG));
213#ifdef S_IFLNK
214static_assert (!S_ISNAM (S_IFLNK));
215#endif
216#ifdef S_IFSOCK
217static_assert (!S_ISNAM (S_IFSOCK));
218#endif
219
220#ifdef S_IFBLK
221static_assert (!S_ISNWK (S_IFBLK));
222#endif
223static_assert (!S_ISNWK (S_IFCHR));
224static_assert (!S_ISNWK (S_IFDIR));
225static_assert (!S_ISNWK (S_IFIFO));
226static_assert (!S_ISNWK (S_IFREG));
227#ifdef S_IFLNK
228static_assert (!S_ISNWK (S_IFLNK));
229#endif
230#ifdef S_IFSOCK
231static_assert (!S_ISNWK (S_IFSOCK));
232#endif
233
234#ifdef S_IFBLK
235static_assert (!S_ISPORT (S_IFBLK));
236#endif
237static_assert (!S_ISPORT (S_IFCHR));
238static_assert (!S_ISPORT (S_IFDIR));
239static_assert (!S_ISPORT (S_IFIFO));
240static_assert (!S_ISPORT (S_IFREG));
241#ifdef S_IFLNK
242static_assert (!S_ISPORT (S_IFLNK));
243#endif
244#ifdef S_IFSOCK
245static_assert (!S_ISPORT (S_IFSOCK));
246#endif
247
248#ifdef S_IFBLK
249static_assert (!S_ISCTG (S_IFBLK));
250#endif
251static_assert (!S_ISCTG (S_IFCHR));
252static_assert (!S_ISCTG (S_IFDIR));
253static_assert (!S_ISCTG (S_IFIFO));
254static_assert (!S_ISCTG (S_IFREG));
255#ifdef S_IFLNK
256static_assert (!S_ISCTG (S_IFLNK));
257#endif
258#ifdef S_IFSOCK
259static_assert (!S_ISCTG (S_IFSOCK));
260#endif
261
262#ifdef S_IFBLK
263static_assert (!S_ISOFD (S_IFBLK));
264#endif
265static_assert (!S_ISOFD (S_IFCHR));
266static_assert (!S_ISOFD (S_IFDIR));
267static_assert (!S_ISOFD (S_IFIFO));
268static_assert (!S_ISOFD (S_IFREG));
269#ifdef S_IFLNK
270static_assert (!S_ISOFD (S_IFLNK));
271#endif
272#ifdef S_IFSOCK
273static_assert (!S_ISOFD (S_IFSOCK));
274#endif
275
276#ifdef S_IFBLK
277static_assert (!S_ISOFL (S_IFBLK));
278#endif
279static_assert (!S_ISOFL (S_IFCHR));
280static_assert (!S_ISOFL (S_IFDIR));
281static_assert (!S_ISOFL (S_IFIFO));
282static_assert (!S_ISOFL (S_IFREG));
283#ifdef S_IFLNK
284static_assert (!S_ISOFL (S_IFLNK));
285#endif
286#ifdef S_IFSOCK
287static_assert (!S_ISOFL (S_IFSOCK));
288#endif
289
290#ifdef S_IFBLK
291static_assert (!S_ISWHT (S_IFBLK));
292#endif
293static_assert (!S_ISWHT (S_IFCHR));
294static_assert (!S_ISWHT (S_IFDIR));
295static_assert (!S_ISWHT (S_IFIFO));
296static_assert (!S_ISWHT (S_IFREG));
297#ifdef S_IFLNK
298static_assert (!S_ISWHT (S_IFLNK));
299#endif
300#ifdef S_IFSOCK
301static_assert (!S_ISWHT (S_IFSOCK));
302#endif
303
304/* POSIX 2008 requires traditional encoding of permission constants. */
305static_assert (S_IRWXU == 00700);
306static_assert (S_IRUSR == 00400);
307static_assert (S_IWUSR == 00200);
308static_assert (S_IXUSR == 00100);
309static_assert (S_IRWXG == 00070);
310static_assert (S_IRGRP == 00040);
311static_assert (S_IWGRP == 00020);
312static_assert (S_IXGRP == 00010);
313static_assert (S_IRWXO == 00007);
314static_assert (S_IROTH == 00004);
315static_assert (S_IWOTH == 00002);
316static_assert (S_IXOTH == 00001);
317static_assert (S_ISUID == 04000);
318static_assert (S_ISGID == 02000);
319static_assert (S_ISVTX == 01000);
320
321#if ((0 <= UTIME_NOW && UTIME_NOW < 1000000000) \
322 || (0 <= UTIME_OMIT && UTIME_OMIT < 1000000000) \
323 || UTIME_NOW == UTIME_OMIT)
324invalid UTIME macros
325#endif
326
327/* Check the existence of some types. */
328nlink_t t1;
329off_t t2;
330mode_t t3;
331
332struct timespec st;
333
334int
335main (void)
336{
337 return 0;
338}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette