root/maint/gnulib/tests/test-sys_stat.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

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

/* [previous][next][first][last][top][bottom][index][help] */