3 static void do_prepare (void);
4 #define PREPARE(argc, argv) do_prepare ()
5 static int do_test (void);
6 #define TEST_FUNCTION do_test ()
7 #include <test-skeleton.c>
14 fd
= create_temp_file ("tst-posix_fallocate.", NULL
);
17 printf ("cannot create temporary file: %m\n");
28 if (fstat64 (fd
, &st
) != 0)
30 puts ("1st fstat failed");
36 puts ("file not created with size 0");
40 if (posix_fallocate (fd
, 512, 768) != 0)
42 puts ("1st posix_fallocate call failed");
46 if (fstat64 (fd
, &st
) != 0)
48 puts ("2nd fstat failed");
52 if (st
.st_size
!= 512 + 768)
54 printf ("file size after first posix_fallocate call is %llu, expected %u\n",
55 (unsigned long long int) st
.st_size
, 512u + 768u);
59 if (posix_fallocate (fd
, 0, 1024) != 0)
61 puts ("2nd posix_fallocate call failed");
65 if (fstat64 (fd
, &st
) != 0)
67 puts ("3rd fstat failed");
71 if (st
.st_size
!= 512 + 768)
73 puts ("file size changed in second posix_fallocate");
77 if (posix_fallocate (fd
, 2048, 64) != 0)
79 puts ("3rd posix_fallocate call failed");
83 if (fstat64 (fd
, &st
) != 0)
85 puts ("4th fstat failed");
89 if (st
.st_size
!= 2048 + 64)
91 printf ("file size after first posix_fallocate call is %llu, expected %u\n",
92 (unsigned long long int) st
.st_size
, 2048u + 64u);