[PATCH v3 3/3] statvfs: f_type: NEWS & test

Florian Weimer fweimer@redhat.com
Tue Aug 15 09:15:21 GMT 2023


* наб:

> diff --git a/io/tst-statvfs.c b/io/tst-statvfs.c
> index 227c62d7da..b38ecae466 100644
> --- a/io/tst-statvfs.c
> +++ b/io/tst-statvfs.c
> @@ -1,5 +1,7 @@
>  #include <stdio.h>
> +#include <sys/statfs.h>
>  #include <sys/statvfs.h>
> +#include <support/check.h>
>  
>  
>  /* This test cannot detect many errors.  But it will fail if the
> @@ -11,17 +13,18 @@ do_test (int argc, char *argv[])
>    for (int i = 1; i < argc; ++i)
>      {
>        struct statvfs st;
> -      if (statvfs (argv[i], &st) != 0)
> -        printf ("%s: failed (%m)\n", argv[i]);
> -      else
> -        printf ("%s: free: %llu, mandatory: %s\n", argv[i],
> -                (unsigned long long int) st.f_bfree,
> +      struct statfs stf;
> +      TEST_COMPARE (statvfs (argv[i], &st), 0);
> +      TEST_COMPARE (statfs (argv[i], &stf), 0);
> +      TEST_COMPARE (st.f_type, stf.f_type);

This fails with certain file systems because the types of f_type differ
in signedness:

=====FAIL: io/tst-statvfs.out=====
tst-statvfs.c:19: numeric comparison failure
   left: 2435016766 (0x9123683e); from: st.f_type
  right: -1859950530 (0x9123683e); from: stf.f_type
/builddir/build/BUILD/glibc-2.38.9000-40-gd6fe19facc/build-i686-redhat-linux/io/
tst-statvfs: free: 53658025, mandatory: no, tp=9123683e
tst-statvfs.c:19: numeric comparison failure
   left: 2435016766 (0x9123683e); from: st.f_type
  right: -1859950530 (0x9123683e); from: stf.f_type
tst-statvfs.c: free: 53658025, mandatory: no, tp=9123683e
tst-statvfs.c:19: numeric comparison failure
   left: 2435016766 (0x9123683e); from: st.f_type
  right: -1859950530 (0x9123683e); from: stf.f_type
/tmp: free: 53658025, mandatory: no, tp=9123683e
error: 3 test failures

Thanks,
Florian



More information about the Libc-alpha mailing list