Module Name: src Committed By: jmmv Date: Wed Jun 15 08:48:36 UTC 2011
Modified Files: src/external/bsd/atf/dist/atf-c/detail: process.c src/external/bsd/atf/dist/atf-run: test-program.cpp src/external/bsd/atf/dist/atf-sh: atf-check_test.sh Log Message: Pull up part of revision f621bc0489ac3e4ef364f840a852a6a5290e8e12: ----- Only silence stdin for test programs atf-check is expected to accept data in its stdin, and a previous change broke this behavior. ----- This should fix a few tests that broke during the 0.14 import. In particularly, the tests in libc/stdlib and libc/ssp that redirect stuff to atf_check. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/atf/dist/atf-c/detail/process.c cvs rdiff -u -r1.9 -r1.10 src/external/bsd/atf/dist/atf-run/test-program.cpp cvs rdiff -u -r1.3 -r1.4 src/external/bsd/atf/dist/atf-sh/atf-check_test.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/bsd/atf/dist/atf-c/detail/process.c diff -u src/external/bsd/atf/dist/atf-c/detail/process.c:1.3 src/external/bsd/atf/dist/atf-c/detail/process.c:1.4 --- src/external/bsd/atf/dist/atf-c/detail/process.c:1.3 Tue Jun 14 15:26:20 2011 +++ src/external/bsd/atf/dist/atf-c/detail/process.c Wed Jun 15 08:48:35 2011 @@ -412,24 +412,6 @@ } static -atf_error_t -silence_stdin(void) -{ - atf_error_t err; - - close(STDIN_FILENO); - int fd = open("/dev/zero", O_RDONLY); - if (fd == -1) - err = atf_libc_error(errno, "Could not open /dev/zero"); - else { - INV(fd == STDIN_FILENO); - err = atf_no_error(); - } - - return err; -} - -static void do_child(void (*)(void *), void *, @@ -445,10 +427,6 @@ { atf_error_t err; - err = silence_stdin(); - if (atf_is_error(err)) - goto out; - err = child_connect(outsp, STDOUT_FILENO); if (atf_is_error(err)) goto out; Index: src/external/bsd/atf/dist/atf-run/test-program.cpp diff -u src/external/bsd/atf/dist/atf-run/test-program.cpp:1.9 src/external/bsd/atf/dist/atf-run/test-program.cpp:1.10 --- src/external/bsd/atf/dist/atf-run/test-program.cpp:1.9 Tue Jun 14 15:26:21 2011 +++ src/external/bsd/atf/dist/atf-run/test-program.cpp Wed Jun 15 08:48:36 2011 @@ -31,6 +31,7 @@ #include <sys/types.h> #include <sys/stat.h> +#include <fcntl.h> #include <signal.h> #include <unistd.h> } @@ -220,6 +221,17 @@ static void +silence_stdin(void) +{ + ::close(STDIN_FILENO); + int fd = ::open("/dev/null", O_RDONLY); + if (fd == -1) + throw std::runtime_error("Could not open /dev/null"); + INV(fd == STDIN_FILENO); +} + +static +void prepare_child(const atf::fs::path& workdir) { const int ret = ::setpgid(::getpid(), 0); @@ -244,6 +256,8 @@ atf::env::set("__RUNNING_INSIDE_ATF_RUN", "internal-yes-value"); impl::change_directory(workdir); + + silence_stdin(); } static Index: src/external/bsd/atf/dist/atf-sh/atf-check_test.sh diff -u src/external/bsd/atf/dist/atf-sh/atf-check_test.sh:1.3 src/external/bsd/atf/dist/atf-sh/atf-check_test.sh:1.4 --- src/external/bsd/atf/dist/atf-sh/atf-check_test.sh:1.3 Thu Mar 31 16:44:17 2011 +++ src/external/bsd/atf/dist/atf-sh/atf-check_test.sh Wed Jun 15 08:48:36 2011 @@ -400,6 +400,17 @@ h_fail "echo foo bar 1>&2" -e not-match:foo } +atf_test_case stdin +stdin_head() +{ + atf_set "descr" "Tests that stdin is preserved" +} +stdin_body() +{ + echo "hello" | ${Atf_Check} -o match:"hello" cat || \ + atf_fail "atf-check does not seem to respect stdin" +} + atf_test_case invalid_umask invalid_umask_head() { @@ -444,6 +455,8 @@ atf_add_test_case eflag_multiple atf_add_test_case eflag_negated + atf_add_test_case stdin + atf_add_test_case invalid_umask }