Module Name: src Committed By: jmmv Date: Tue Jun 14 15:26:21 UTC 2011
Modified Files: src/external/bsd/atf/dist/atf-c: defs.h.in tc.h src/external/bsd/atf/dist/atf-c++: tests.cpp src/external/bsd/atf/dist/atf-c/detail: process.c src/external/bsd/atf/dist/atf-run: atf-run.cpp integration_test.sh test-program.cpp test_program_test.cpp src/external/bsd/atf/dist/doc: atf-test-case.4 Log Message: Post-import merge of atf-0.14. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/atf/dist/atf-c/defs.h.in \ src/external/bsd/atf/dist/atf-c/tc.h cvs rdiff -u -r1.6 -r1.7 src/external/bsd/atf/dist/atf-c++/tests.cpp cvs rdiff -u -r1.2 -r1.3 src/external/bsd/atf/dist/atf-c/detail/process.c cvs rdiff -u -r1.11 -r1.12 src/external/bsd/atf/dist/atf-run/atf-run.cpp cvs rdiff -u -r1.2 -r1.3 \ src/external/bsd/atf/dist/atf-run/integration_test.sh \ src/external/bsd/atf/dist/atf-run/test_program_test.cpp cvs rdiff -u -r1.8 -r1.9 src/external/bsd/atf/dist/atf-run/test-program.cpp cvs rdiff -u -r1.3 -r1.4 src/external/bsd/atf/dist/doc/atf-test-case.4 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/defs.h.in diff -u src/external/bsd/atf/dist/atf-c/defs.h.in:1.2 src/external/bsd/atf/dist/atf-c/defs.h.in:1.3 --- src/external/bsd/atf/dist/atf-c/defs.h.in:1.2 Sat Jun 11 18:03:57 2011 +++ src/external/bsd/atf/dist/atf-c/defs.h.in Tue Jun 14 15:26:20 2011 @@ -1,7 +1,7 @@ /* * Automated Testing Framework (atf) * - * Copyright (c) 2008 The NetBSD Foundation, Inc. + * Copyright (c) 2008, 2011 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,6 +30,7 @@ #if !defined(ATF_C_DEFS_H) #define ATF_C_DEFS_H +#define ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(a, b) @ATTRIBUTE_FORMAT_PRINTF@ #define ATF_DEFS_ATTRIBUTE_NORETURN @ATTRIBUTE_NORETURN@ #define ATF_DEFS_ATTRIBUTE_PRINTF(a,b) @ATTRIBUTE_PRINTF(a,b)@ Index: src/external/bsd/atf/dist/atf-c/tc.h diff -u src/external/bsd/atf/dist/atf-c/tc.h:1.2 src/external/bsd/atf/dist/atf-c/tc.h:1.3 --- src/external/bsd/atf/dist/atf-c/tc.h:1.2 Sat Jun 11 18:03:57 2011 +++ src/external/bsd/atf/dist/atf-c/tc.h Tue Jun 14 15:26:20 2011 @@ -1,7 +1,7 @@ /* * Automated Testing Framework (atf) * - * Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc. + * Copyright (c) 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -104,33 +104,33 @@ /* To be run from test case bodies only. */ void atf_tc_fail(const char *, ...) - ATF_DEFS_ATTRIBUTE_PRINTF(1, 2) + ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2) ATF_DEFS_ATTRIBUTE_NORETURN; void atf_tc_fail_nonfatal(const char *, ...) - ATF_DEFS_ATTRIBUTE_PRINTF(1, 2); + ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2); void atf_tc_pass(void) ATF_DEFS_ATTRIBUTE_NORETURN; void atf_tc_require_prog(const char *); void atf_tc_skip(const char *, ...) - ATF_DEFS_ATTRIBUTE_PRINTF(1, 2) + ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2) ATF_DEFS_ATTRIBUTE_NORETURN; void atf_tc_expect_pass(void); void atf_tc_expect_fail(const char *, ...) - ATF_DEFS_ATTRIBUTE_PRINTF(1, 2); + ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2); void atf_tc_expect_exit(const int, const char *, ...) - ATF_DEFS_ATTRIBUTE_PRINTF(2, 3); + ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3); void atf_tc_expect_signal(const int, const char *, ...) - ATF_DEFS_ATTRIBUTE_PRINTF(2, 3); + ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3); void atf_tc_expect_death(const char *, ...) - ATF_DEFS_ATTRIBUTE_PRINTF(1, 2); + ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2); void atf_tc_expect_timeout(const char *, ...) - ATF_DEFS_ATTRIBUTE_PRINTF(1, 2); + ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2); /* To be run from test case bodies only; internal to macros.h. */ void atf_tc_fail_check(const char *, const size_t, const char *, ...) - ATF_DEFS_ATTRIBUTE_PRINTF(3, 4); + ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(3, 4); void atf_tc_fail_requirement(const char *, const size_t, const char *, ...) - ATF_DEFS_ATTRIBUTE_PRINTF(3, 4) + ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(3, 4) ATF_DEFS_ATTRIBUTE_NORETURN; void atf_tc_check_errno(const char *, const size_t, const int, const char *, const bool); Index: src/external/bsd/atf/dist/atf-c++/tests.cpp diff -u src/external/bsd/atf/dist/atf-c++/tests.cpp:1.6 src/external/bsd/atf/dist/atf-c++/tests.cpp:1.7 --- src/external/bsd/atf/dist/atf-c++/tests.cpp:1.6 Sun Nov 7 17:45:22 2010 +++ src/external/bsd/atf/dist/atf-c++/tests.cpp Tue Jun 14 15:26:20 2011 @@ -1,7 +1,7 @@ // // Automated Testing Framework (atf) // -// Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc. +// Copyright (c) 2007, 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -641,6 +641,16 @@ impl::tc* tc = find_tc(init_tcs(), fields.first); + if (!atf::env::has("__RUNNING_INSIDE_ATF_RUN") || atf::env::get( + "__RUNNING_INSIDE_ATF_RUN") != "internal-yes-value") + { + std::cerr << m_prog_name << ": WARNING: Running test cases without " + "atf-run(1) is unsupported\n"; + std::cerr << m_prog_name << ": WARNING: No isolation nor timeout " + "control is being applied; you may get unexpected failures; see " + "atf-test-case(4)\n"; + } + try { switch (fields.second) { case BODY: Index: src/external/bsd/atf/dist/atf-c/detail/process.c diff -u src/external/bsd/atf/dist/atf-c/detail/process.c:1.2 src/external/bsd/atf/dist/atf-c/detail/process.c:1.3 --- src/external/bsd/atf/dist/atf-c/detail/process.c:1.2 Tue Apr 5 17:17:35 2011 +++ src/external/bsd/atf/dist/atf-c/detail/process.c Tue Jun 14 15:26:20 2011 @@ -412,6 +412,24 @@ } 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 *, @@ -427,6 +445,10 @@ { 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/atf-run.cpp diff -u src/external/bsd/atf/dist/atf-run/atf-run.cpp:1.11 src/external/bsd/atf/dist/atf-run/atf-run.cpp:1.12 --- src/external/bsd/atf/dist/atf-run/atf-run.cpp:1.11 Tue Apr 5 17:17:35 2011 +++ src/external/bsd/atf/dist/atf-run/atf-run.cpp Tue Jun 14 15:26:21 2011 @@ -33,6 +33,7 @@ extern "C" { #include <sys/types.h> +#include <sys/param.h> #include <sys/stat.h> #include <sys/wait.h> #include <unistd.h> @@ -67,6 +68,12 @@ namespace impl = atf::atf_run; +#if defined(MAXCOMLEN) +static const std::string::size_type max_core_name_length = MAXCOMLEN; +#else +static const std::string::size_type max_core_name_length = std::string::npos; +#endif + class atf_run : public atf::application::app { static const char* m_description; @@ -119,7 +126,8 @@ w.stderr_tc("Test program crashed; attempting to get stack trace"); - const atf::fs::path corename = workdir / (tp.leaf_name() + ".core"); + const atf::fs::path corename = workdir / + (tp.leaf_name().substr(0, max_core_name_length) + ".core"); if (!atf::fs::exists(corename)) { w.stderr_tc("Expected file " + corename.str() + " not found"); return; Index: src/external/bsd/atf/dist/atf-run/integration_test.sh diff -u src/external/bsd/atf/dist/atf-run/integration_test.sh:1.2 src/external/bsd/atf/dist/atf-run/integration_test.sh:1.3 --- src/external/bsd/atf/dist/atf-run/integration_test.sh:1.2 Sun Nov 7 17:54:03 2010 +++ src/external/bsd/atf/dist/atf-run/integration_test.sh Tue Jun 14 15:26:21 2011 @@ -1,7 +1,7 @@ # # Automated Testing Framework (atf) # -# Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc. +# Copyright (c) 2007, 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -120,6 +120,18 @@ EOF } +atf_test_case no_warnings +no_warnings_head() +{ + atf_set "descr" "Tests that atf-run suppresses warnings about not running" \ + "within atf-run" +} +no_warnings_body() +{ + create_helper pass + atf_check -s eq:0 -o ignore -e not-match:'WARNING.*atf-run' atf-run helper +} + atf_test_case config config_head() { @@ -583,8 +595,8 @@ isolation_env_body() { undef_vars="LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY \ - LC_NUMERIC LC_TIME TZ" - def_vars="HOME" + LC_NUMERIC LC_TIME" + def_vars="HOME TZ" mangleenv="env" for v in ${undef_vars} ${def_vars}; do @@ -607,6 +619,8 @@ for v in ${def_vars}; do atf_check -s eq:0 -o ignore -e empty grep "^tc-so:${v}=" stdout done + + atf_check -s eq:0 -o ignore -e empty grep "^tc-so:TZ=UTC" stdout } atf_test_case isolation_home @@ -621,6 +635,18 @@ atf_check -s eq:0 -o ignore -e ignore env HOME=foo atf-run helper } +atf_test_case isolation_stdin +isolation_stdin_head() +{ + atf_set "descr" "Tests that atf-run nullifies the stdin of test cases" +} +isolation_stdin_body() +{ + create_helper read_stdin + create_atffile helper + atf_check -s eq:0 -o ignore -e ignore -x 'echo hello world | atf-run helper' +} + atf_test_case isolation_umask isolation_umask_head() { @@ -855,6 +881,36 @@ -v var1=a -v var2=' ' helper } +atf_test_case require_files +require_files_head() +{ + atf_set "descr" "Tests that atf-run validates the require.files property" +} +require_files_body() +{ + create_helper require_files + create_atffile helper + + touch i-exist + + echo "Checking absolute paths" + atf_check -s eq:0 -o match:"${TESTCASE}, passed" -e ignore atf-run \ + -v files='/bin/cp' helper + atf_check -s eq:0 -o match:"${TESTCASE}, passed" -e ignore atf-run \ + -v files="$(pwd)/i-exist" helper + atf_check -s eq:0 \ + -o match:"${TESTCASE}, skipped, .*/dont-exist" \ + -e ignore atf-run -v files="$(pwd)/i-exist $(pwd)/dont-exist" helper + + echo "Checking that relative paths are not allowed" + atf_check -s eq:1 \ + -o match:"${TESTCASE}, failed, Relative paths.*not allowed.*hello" \ + -e ignore atf-run -v files='hello' helper + atf_check -s eq:1 \ + -o match:"${TESTCASE}, failed, Relative paths.*not allowed.*a/b" \ + -e ignore atf-run -v files='a/b' helper +} + atf_test_case require_machine require_machine_head() { @@ -1031,6 +1087,7 @@ atf_init_test_cases() { + atf_add_test_case no_warnings atf_add_test_case config atf_add_test_case vflag atf_add_test_case atffile @@ -1047,6 +1104,7 @@ atf_add_test_case hooks atf_add_test_case isolation_env atf_add_test_case isolation_home + atf_add_test_case isolation_stdin atf_add_test_case isolation_umask atf_add_test_case cleanup_pass atf_add_test_case cleanup_fail @@ -1057,6 +1115,7 @@ atf_add_test_case cleanup_symlink atf_add_test_case require_arch atf_add_test_case require_config + atf_add_test_case require_files atf_add_test_case require_machine atf_add_test_case require_progs atf_add_test_case require_user_root Index: src/external/bsd/atf/dist/atf-run/test_program_test.cpp diff -u src/external/bsd/atf/dist/atf-run/test_program_test.cpp:1.2 src/external/bsd/atf/dist/atf-run/test_program_test.cpp:1.3 --- src/external/bsd/atf/dist/atf-run/test_program_test.cpp:1.2 Tue Nov 16 17:55:56 2010 +++ src/external/bsd/atf/dist/atf-run/test_program_test.cpp Tue Jun 14 15:26:21 2011 @@ -1,7 +1,7 @@ // // Automated Testing Framework (atf) // -// Copyright (c) 2010 The NetBSD Foundation, Inc. +// Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -227,6 +227,7 @@ "timeout: 300\n" "require.arch: thearch\n" "require.config: foo-bar\n" + "require.files: /a/1 /b/2\n" "require.machine: themachine\n" "require.progs: /bin/cp mv\n" "require.user: root\n" @@ -234,7 +235,7 @@ // NO_CHECK_STYLE_BEGIN const char* exp_calls[] = { - "got_tc(single_test, {descr=Some description, ident=single_test, require.arch=thearch, require.config=foo-bar, require.machine=themachine, require.progs=/bin/cp mv, require.user=root, timeout=300})", + "got_tc(single_test, {descr=Some description, ident=single_test, require.arch=thearch, require.config=foo-bar, require.files=/a/1 /b/2, require.machine=themachine, require.progs=/bin/cp mv, require.user=root, timeout=300})", "got_eof()", NULL }; Index: src/external/bsd/atf/dist/atf-run/test-program.cpp diff -u src/external/bsd/atf/dist/atf-run/test-program.cpp:1.8 src/external/bsd/atf/dist/atf-run/test-program.cpp:1.9 --- src/external/bsd/atf/dist/atf-run/test-program.cpp:1.8 Thu Mar 17 19:45:36 2011 +++ src/external/bsd/atf/dist/atf-run/test-program.cpp Tue Jun 14 15:26:21 2011 @@ -239,7 +239,9 @@ atf::env::unset("LC_MONETARY"); atf::env::unset("LC_NUMERIC"); atf::env::unset("LC_TIME"); - atf::env::unset("TZ"); + atf::env::set("TZ", "UTC"); + + atf::env::set("__RUNNING_INSIDE_ATF_RUN", "internal-yes-value"); impl::change_directory(workdir); } @@ -418,6 +420,7 @@ ident_regex + "; was '" + value + "'"); } else if (name == "require.arch") { } else if (name == "require.config") { + } else if (name == "require.files") { } else if (name == "require.machine") { } else if (name == "require.progs") { } else if (name == "require.user") { Index: src/external/bsd/atf/dist/doc/atf-test-case.4 diff -u src/external/bsd/atf/dist/doc/atf-test-case.4:1.3 src/external/bsd/atf/dist/doc/atf-test-case.4:1.4 --- src/external/bsd/atf/dist/doc/atf-test-case.4:1.3 Thu Mar 31 16:44:17 2011 +++ src/external/bsd/atf/dist/doc/atf-test-case.4 Tue Jun 14 15:26:21 2011 @@ -1,7 +1,7 @@ .\" .\" Automated Testing Framework (atf) .\" -.\" Copyright (c) 2007, 2008, 2010 The NetBSD Foundation, Inc. +.\" Copyright (c) 2007, 2008, 2010, 2011 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -26,7 +26,7 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd December 13, 2010 +.Dd May 29, 2011 .Dt ATF-TEST-CASE 4 .Os .Sh NAME @@ -148,6 +148,9 @@ collected by the test program they are contained in. The developer need not care about this as long as he uses the correct APIs to implement the test cases. +.Pp +The standard input of the test cases is unconditionally connected to +.Sq /dev/zero . .Ss Meta-data The following list describes all meta-data properties interpreted internally by ATF. @@ -179,7 +182,7 @@ The test case's identifier. Must be unique inside the test program and should be short but descriptive. .It require.arch -Type textual. +Type: textual. Optional. .Pp A whitespace separated list of architectures that the test case can be run @@ -192,8 +195,17 @@ to execute the test case. If any of the required variables is not defined, the test case is .Em skipped . +.It require.files +Type: textual. +Optional. +.Pp +A whitespace separated list of files that must be present to execute the +test case. +The names of these files must be absolute paths. +If any of the required files is not found, the test case is +.Em skipped . .It require.machine -Type textual. +Type: textual. Optional. .Pp A whitespace separated list of machine types that the test case can be run @@ -219,14 +231,19 @@ .Sq root or .Sq unprivileged . -If the requested privileges do not match the current user, the test case is +.Pp +If the test case is running as a regular user and this property is +.Sq root , +the test case is .Em skipped . .Pp -.Em NOTE : -In the future, it is expected that the test case will attempt to gain the -necessary privileges on its own before failing. -At the very least, lowering the privileges from the super-user to an -unprivileged user will be supported. +If the test case is running as root and this property is +.Sq unprivileged , +.Xr atf-run 1 +will automatically drop the privileges if the +.Sq unprivileged-user +configuration property is set; otherwise the test case is +.Em skipped . .It timeout Type: integral. Optional; defaults to @@ -268,7 +285,8 @@ .It Ev LC_TIME Undefined. .It Ev TZ -Undefined. +Hardcoded to +.Sq UTC . .El .Ss Work directories The test program always creates a temporary directory @@ -284,6 +302,7 @@ .Sq 0022 . The test case's code is free to change this during execution. .Sh SEE ALSO +.Xr atf-run 1 , .Xr atf-test-program 1 , .Xr atf-formats 5 , .Xr atf 7