This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] elf: tst-ldconfig-bad-aux-cache: use support_capture_subprocess


* Alexandra Hájková:

> +#include <support/capture_subprocess.h>
>  #include <support/check.h>
>  #include <support/support.h>
>  #include <support/xunistd.h>
> @@ -52,6 +53,12 @@ display_info (const char *fpath, const struct stat *sb,
>    return 0;
>  }
>  
> +static void
> +execv_wrapper(void *args)
> +{
> +    execv(((char **)args)[0], (char **)args);
> +}

I think there should be spaces after execv and the casts.

And I forgot to mention that this should have _exit (1); after the
execve, so that a failure results in an error notification to the
parent.  Maybe you could even use

  FAIL_EXIT1 ("execve: %m");

(exit is safe in this context, too.)

> +  struct support_capture_subprocess result;
> +  result = support_capture_subprocess (execv_wrapper, args);
> +  support_capture_subprocess_check (&result, "execv", 0, sc_allow_none);
> +
> +  xstat (path, &fs);
> +
> +  size = fs.st_size;
> +  /* Run 3 tests, each truncating aux-cache shorter and shorter.  */
> +  for (i = 3; i > 0; i--)
> +  {
> +      new_size = size * i / 4;
> +      if (truncate (path, new_size))
> +          FAIL_EXIT1 ("truncation failed: %m");
> +      if (nftw (path, display_info, 1000, 0) == -1)
> +          FAIL_EXIT1 ("nftw failed.");
> +
> +      /* Verify that ldconfig can run with a truncated
> +         aux-cache and doesn't crash.  */
> +      struct support_capture_subprocess result;
> +      result = support_capture_subprocess (execv_wrapper, args);
> +      support_capture_subprocess_check (&result, "execv", 0, sc_allow_none);
> +  }

This is a great simplification, thanks.  It's now much clearer what the
test is actually doing.

Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]