4 static void do_prepare (void);
5 #define PREPARE(argc, argv) do_prepare ()
6 static int do_test (void);
7 #define TEST_FUNCTION do_test ()
8 #include <test-skeleton.c>
15 fd
= create_temp_file ("tst-posix_fallocate.", NULL
);
18 printf ("cannot create temporary file: %m\n");
29 if (fstat64 (fd
, &st
) != 0)
31 puts ("1st fstat failed");
37 puts ("file not created with size 0");
41 if (posix_fallocate (fd
, 512, 768) != 0)
43 puts ("1st posix_fallocate call failed");
47 if (fstat64 (fd
, &st
) != 0)
49 puts ("2nd fstat failed");
53 if (st
.st_size
!= 512 + 768)
55 printf ("file size after first posix_fallocate call is %llu, expected %u\n",
56 (unsigned long long int) st
.st_size
, 512u + 768u);
60 if (posix_fallocate (fd
, 0, 1024) != 0)
62 puts ("2nd posix_fallocate call failed");
66 if (fstat64 (fd
, &st
) != 0)
68 puts ("3rd fstat failed");
72 if (st
.st_size
!= 512 + 768)
74 puts ("file size changed in second posix_fallocate");
78 if (posix_fallocate (fd
, 2048, 64) != 0)
80 puts ("3rd posix_fallocate call failed");
84 if (fstat64 (fd
, &st
) != 0)
86 puts ("4th fstat failed");
90 if (st
.st_size
!= 2048 + 64)
92 printf ("file size after first posix_fallocate call is %llu, expected %u\n",
93 (unsigned long long int) st
.st_size
, 2048u + 64u);