mirror of git://sourceware.org/git/glibc.git
tst-freopen4-main.c: Call support_capture_subprocess with chroot
Update tst-freopen4-main.c to call support_capture_subprocess with chroot, which makes temporary files inaccessible, so that temporary files can be deleted. This partially fixes BZ #33182. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
parent
e7db515060
commit
6463d4a7b2
|
|
@ -28,25 +28,15 @@
|
||||||
#include <support/test-driver.h>
|
#include <support/test-driver.h>
|
||||||
#include <support/xstdio.h>
|
#include <support/xstdio.h>
|
||||||
#include <support/xunistd.h>
|
#include <support/xunistd.h>
|
||||||
|
#include <support/capture_subprocess.h>
|
||||||
|
|
||||||
int
|
static void
|
||||||
do_test (void)
|
do_test_chroot (void *data)
|
||||||
{
|
{
|
||||||
mtrace ();
|
char *temp_dir = (char *) data;
|
||||||
char *temp_dir;
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* These chroot tests verify that either reopening a renamed or
|
|
||||||
deleted file works even in the absence of /proc, or that it fails
|
|
||||||
(without memory leaks); thus, for example, such reopening does
|
|
||||||
not crash in the absence of /proc. */
|
|
||||||
|
|
||||||
support_become_root ();
|
|
||||||
if (!support_can_chroot ())
|
|
||||||
return EXIT_UNSUPPORTED;
|
|
||||||
|
|
||||||
temp_dir = support_create_temp_directory ("tst-freopen4");
|
|
||||||
xchroot (temp_dir);
|
xchroot (temp_dir);
|
||||||
|
|
||||||
/* Test freopen with NULL, renamed file. This verifies that
|
/* Test freopen with NULL, renamed file. This verifies that
|
||||||
|
|
@ -96,6 +86,32 @@ do_test (void)
|
||||||
puts ("freopen of deleted file failed (OK)");
|
puts ("freopen of deleted file failed (OK)");
|
||||||
|
|
||||||
free (temp_dir);
|
free (temp_dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
do_test (void)
|
||||||
|
{
|
||||||
|
mtrace ();
|
||||||
|
char *temp_dir;
|
||||||
|
|
||||||
|
/* These chroot tests verify that either reopening a renamed or
|
||||||
|
deleted file works even in the absence of /proc, or that it fails
|
||||||
|
(without memory leaks); thus, for example, such reopening does
|
||||||
|
not crash in the absence of /proc. */
|
||||||
|
|
||||||
|
support_become_root ();
|
||||||
|
if (!support_can_chroot ())
|
||||||
|
return EXIT_UNSUPPORTED;
|
||||||
|
|
||||||
|
temp_dir = support_create_temp_directory ("tst-freopen4");
|
||||||
|
|
||||||
|
struct support_capture_subprocess result;
|
||||||
|
result = support_capture_subprocess (do_test_chroot, temp_dir);
|
||||||
|
support_capture_subprocess_check (&result, "freopen4", 0,
|
||||||
|
sc_allow_stdout);
|
||||||
|
fputs (result.out.buffer, stdout);
|
||||||
|
support_capture_subprocess_free (&result);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue