functional: add mntent test
[libc-test.git] / src / regression / statvfs.c
blob6c8f187285cffc3843741edc81726e3b70db0a2d
1 // commit 7673acd31503016f2af93e187aac98da07af42b4 2014-03-12
2 // internal statfs struct was wrong on mips
3 // this test does various sanity checks to catch such bugs
4 #include <string.h>
5 #include <errno.h>
6 #include <sys/statvfs.h>
7 #include "test.h"
9 int main(void)
11 struct statvfs f;
13 if (statvfs("/", &f))
14 t_error("statvfs(\"/\") failed: %s\n", strerror(errno));
15 if (f.f_bsize == 0 || f.f_bsize > 1<<28)
16 t_error("/ has bogus f_bsize: %lu\n", (unsigned long)f.f_bsize);
17 if (f.f_blocks == 0)
18 t_error("/ has 0 blocks\n");
19 if (f.f_blocks < f.f_bfree)
20 t_error("/ has more free blocks (%llu) than total blocks (%llu)\n",
21 (unsigned long long)f.f_bfree, (unsigned long long)f.f_blocks);
22 if (f.f_blocks < f.f_bavail)
23 t_error("/ has more avail blocks (%llu) than total blocks (%llu)\n",
24 (unsigned long long)f.f_bavail, (unsigned long long)f.f_blocks);
25 if (f.f_files == 0)
26 t_error("/ has 0 file nodes\n");
27 if (f.f_files < f.f_ffree)
28 t_error("/ has more free file nodes (%llu) than total file nodes (%llu)\n",
29 (unsigned long long)f.f_ffree, (unsigned long long)f.f_files);
30 if (f.f_files < f.f_favail)
31 t_error("/ has more avail file nodes (%llu) than total file nodes (%llu)\n",
32 (unsigned long long)f.f_favail, (unsigned long long)f.f_files);
33 if (f.f_namemax > 1<<16 || f.f_namemax < 8)
34 t_error("/ has bogus f_namemax: %lu\n", (unsigned long)f.f_namemax);
36 return t_status;