[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#662083: Bug#766456: libzip: FTBFS on hurd-i386



Hi!

On Fri, 2014-10-24 at 09:43:22 +0200, Svante Signell wrote:
> Currently libzip FTBFS on GNU/Hurd due to one failing test:
> open_nosuchfile.test. This test checks for a non-existing file and the
> error codes for ENOENT: No such file or directory. On GNU/Linux and
> GNU/kFreeBSD this number is 2 in errno.h but for GNU/Hurd it is
> 1073741826, resulting in a false negative.
> 
> The attached patch solves this problem by printing the string "No such
> file or directory" in regress/tryopen.c and test for that string in
> regress/open_nosuchfile.test instead of printing and testing the error
> number.

I don't think this fix is right, for several reasons. The string is
just a description and could vary over time or depending on the system
or libc used. It also can return a localized string if the locale has
not been forced to C (which I don't know if it's the case here).

A more fail-proof fix might be something like the following untested
modifications (keeping the strerror() so that if the test fails it's
easier to know what went wrong):

> Index: libzip-0.11.2/regress/tryopen.c
> ===================================================================
> --- libzip-0.11.2.orig/regress/tryopen.c
> +++ libzip-0.11.2/regress/tryopen.c
> @@ -35,6 +35,7 @@
>  #include "config.h"
>  
>  #include <errno.h>
> +#include <string.h>
>  #include <stdio.h>
>  #include <stdlib.h>
>  #ifdef HAVE_UNISTD_H
> @@ -102,7 +103,7 @@ main(int argc, char *argv[])
>  	
>  	printf("opening '%s' returned error %d", fname, ze);
>  	if (zip_error_get_sys_type(ze) == ZIP_ET_SYS)
> -	    printf("/%d", errno);
> +	    printf("/%s", strerror(errno));

	    printf("/%s", errno == ENOENT ? "ENOENT" : strerror(errno));

>  	printf("\n");
>  	error++;
>      }
> Index: libzip-0.11.2/regress/open_nosuchfile.test
> ===================================================================
> --- libzip-0.11.2.orig/regress/open_nosuchfile.test
> +++ libzip-0.11.2/regress/open_nosuchfile.test
> @@ -2,5 +2,5 @@
>  program tryopen
>  args nosuchfile
>  return 1
> -stdout opening 'nosuchfile' returned error 11/2
> +stdout opening 'nosuchfile' returned error 11/No such file or directory

stdout opening 'nosuchfile' returned error 11/ENOENT

>  stderr 1 errors

Thanks,
Guillem


Reply to: