Back to index

glibc  2.9
Defines | Functions
test-stat2.c File Reference
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/stat.h>

Go to the source code of this file.

Defines

#define TEST(name)

Functions

int main (int argc, char *argv[])

Define Documentation

#define TEST (   name)
Value:
same = st.name == st64.name;                                         \
      printf (#name ": %jd vs %jd  %s\n",                            \
             (intmax_t) st.name, (intmax_t) st64.name,                      \
             same ? "OK" : "FAIL");                                         \
      result |= ! same

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 27 of file test-stat2.c.

{
  int i;
  int result = 0;

  for (i = 1; i < argc; ++i)
    {
      struct stat st;
      struct stat64 st64;
      int same;

      if (stat (argv[i], &st) != 0)
       {
         if (errno != EOVERFLOW)
           {
             /* Something is wrong.  */
             printf ("stat(\"%s\",....) failed: %m", argv[i]);
             result = 1;
           }
         continue;
       }

      if (stat64 (argv[i], &st64) != 0)
       {
         if (errno != ENOSYS)
           {
             /* Something is wrong.  */
             printf ("stat64(\"%s\",....) failed: %m", argv[i]);
             result = 1;
           }
         continue;
       }

      printf ("\nName: %s\n", argv[i]);

#define TEST(name) \
      same = st.name == st64.name;                                   \
      printf (#name ": %jd vs %jd  %s\n",                            \
             (intmax_t) st.name, (intmax_t) st64.name,                      \
             same ? "OK" : "FAIL");                                         \
      result |= ! same

      TEST (st_dev);
      TEST (st_ino);
      TEST (st_mode);
      TEST (st_nlink);
      TEST (st_uid);
      TEST (st_gid);
#ifdef _STATBUF_ST_RDEV
      TEST (st_rdev);
#endif
#ifdef _STATBUF_ST_BLKSIZE
      TEST (st_blksize);
#endif
      TEST (st_blocks);
      TEST (st_atime);
      TEST (st_mtime);
      TEST (st_ctime);
    }

  return result;
}

Here is the call graph for this function: