From: Szabolcs Nagy Date: Wed, 12 Mar 2014 18:52:35 +0000 (+0100) Subject: add statvfs regression test X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=9f72a5b491a7dc707fcf2e3dee1f8cd53e19ec9a;p=libc-test add statvfs regression test --- diff --git a/src/regression/statvfs.c b/src/regression/statvfs.c new file mode 100644 index 0000000..6c8f187 --- /dev/null +++ b/src/regression/statvfs.c @@ -0,0 +1,37 @@ +// commit 7673acd31503016f2af93e187aac98da07af42b4 2014-03-12 +// internal statfs struct was wrong on mips +// this test does various sanity checks to catch such bugs +#include +#include +#include +#include "test.h" + +int main(void) +{ + struct statvfs f; + + if (statvfs("/", &f)) + t_error("statvfs(\"/\") failed: %s\n", strerror(errno)); + if (f.f_bsize == 0 || f.f_bsize > 1<<28) + t_error("/ has bogus f_bsize: %lu\n", (unsigned long)f.f_bsize); + if (f.f_blocks == 0) + t_error("/ has 0 blocks\n"); + if (f.f_blocks < f.f_bfree) + t_error("/ has more free blocks (%llu) than total blocks (%llu)\n", + (unsigned long long)f.f_bfree, (unsigned long long)f.f_blocks); + if (f.f_blocks < f.f_bavail) + t_error("/ has more avail blocks (%llu) than total blocks (%llu)\n", + (unsigned long long)f.f_bavail, (unsigned long long)f.f_blocks); + if (f.f_files == 0) + t_error("/ has 0 file nodes\n"); + if (f.f_files < f.f_ffree) + t_error("/ has more free file nodes (%llu) than total file nodes (%llu)\n", + (unsigned long long)f.f_ffree, (unsigned long long)f.f_files); + if (f.f_files < f.f_favail) + t_error("/ has more avail file nodes (%llu) than total file nodes (%llu)\n", + (unsigned long long)f.f_favail, (unsigned long long)f.f_files); + if (f.f_namemax > 1<<16 || f.f_namemax < 8) + t_error("/ has bogus f_namemax: %lu\n", (unsigned long)f.f_namemax); + + return t_status; +}