CVS commit: src/external/bsd/atf/dist/atf-sh
Module Name:src Committed By: kre Date: Thu Sep 10 22:51:11 UTC 2020 Modified Files: src/external/bsd/atf/dist/atf-sh: libatf-sh.subr Log Message: Replace a pipe into tr to normalise a var name (convert '.' or '-' into '_' to meet sh variable name rules) into a shell string processing loop. On my test system, this reduces the total elapsed time for the bin/sh ATF tests from about 109 secs to about 102 (user cpu from 24.5 to 21, sys cpu from 34 to 30) and the usr.bin/make tests elapsed time from 42.5 to 40 secs (user from a bit over 15 to a bit over 13, and sys from 16+ to 13+). (Recorded on an AMD64 domU). These probably exaggerate the effect, as there are a bunch of quite small tests, which means the ATF overhead (which this change affects) is a greater proportion of the total test time than for some other tests where most of the time is spent actually testing. But I am fairly confident that there will be at least some improvement. This could be further improved by removing the cmdsub invocation method, and instead passing the name of a variable containing the string to normalise (with the result returned in that same var) - but that would mean altering all the callers as well. Some other time maybe. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/atf/dist/atf-sh/libatf-sh.subr 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-sh/libatf-sh.subr diff -u src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.4 src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.5 --- src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.4 Wed Dec 30 22:23:02 2015 +++ src/external/bsd/atf/dist/atf-sh/libatf-sh.subr Thu Sep 10 22:51:10 2020 @@ -544,7 +544,15 @@ _atf_list_tcs() # _atf_normalize() { -echo ${1} | tr .- __ +while : +do + case "${1}" in + (*.*) set -- "${1%.*}_${1##*.}";; + (*-*) set -- "${1%-*}_${1##*-}";; + (*) break;; + esac +done +printf "%s\n" "$1" } #
CVS commit: src/external/bsd/atf/dist/atf-sh
Module Name:src Committed By: kre Date: Mon May 15 04:54:09 UTC 2017 Modified Files: src/external/bsd/atf/dist/atf-sh: atf-sh-api.3 Log Message: Add some information learned from experience with using (and abusing) this API... While here do some markup improvements (it is amazing what one can learn from observing a wizard at work!) (which still probably need more work.) In particular, sh functions are not functions in the mdoc .Fn sense! (Many places where explicit double quotes were not doing what was intended.) To generate a diff of this commit: cvs rdiff -u -r1.1.1.7 -r1.2 src/external/bsd/atf/dist/atf-sh/atf-sh-api.3 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-sh/atf-sh-api.3 diff -u src/external/bsd/atf/dist/atf-sh/atf-sh-api.3:1.1.1.7 src/external/bsd/atf/dist/atf-sh/atf-sh-api.3:1.2 --- src/external/bsd/atf/dist/atf-sh/atf-sh-api.3:1.1.1.7 Sat Feb 8 19:11:32 2014 +++ src/external/bsd/atf/dist/atf-sh/atf-sh-api.3 Mon May 15 04:54:09 2017 @@ -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 October 13, 2013 +.Dd May 15, 2017 .Dt ATF-SH-API 3 .Os .Sh NAME @@ -51,25 +51,44 @@ .Nm atf_test_case .Nd POSIX shell API to write ATF-based test programs .Sh SYNOPSIS -.Fn atf_add_test_case "name" -.Fn atf_check "command" -.Fn atf_check_equal "expr1" "expr2" -.Fn atf_config_get "var_name" -.Fn atf_config_has "var_name" -.Fn atf_expect_death "reason" "..." -.Fn atf_expect_exit "exitcode" "reason" "..." -.Fn atf_expect_fail "reason" "..." -.Fn atf_expect_pass -.Fn atf_expect_signal "signo" "reason" "..." -.Fn atf_expect_timeout "reason" "..." -.Fn atf_fail "reason" -.Fn atf_get "var_name" -.Fn atf_get_srcdir -.Fn atf_pass -.Fn atf_require_prog "prog_name" -.Fn atf_set "var_name" "value" -.Fn atf_skip "reason" -.Fn atf_test_case "name" "cleanup" +.Ic atf_add_test_case Dq name +.br +.Ic atf_check Dq command +.br +.Ic atf_check_equal Do expr1 Dc Dq expr2 +.br +.Ic atf_config_get Dq var_name +.br +.Ic atf_config_has Dq var_name +.br +.Ic atf_expect_death Do reason Dc Dq \&... +.br +.Ic atf_expect_exit Do exitcode Dc Do reason Dc Dq \&... +.br +.Ic atf_expect_fail Do reason Dc Dq \&... +.br +.Ic atf_expect_pass +.br +.Ic atf_expect_signal Do signo Dc Do reason Dc Dq \&... +.br +.Ic atf_expect_timeout Do reason Dc Dq \&... +.br +.Ic atf_fail Dq reason +.br +.Ic atf_get Dq var_name +.br +.Ic atf_get_srcdir +.br +.Ic atf_pass +.br +.Ic atf_require_prog Dq prog_name +.br +.Ic atf_set Do var_name Dc Dq value +.br +.Ic atf_skip Dq reason +.br +.Ic atf_test_case Do name Dc Dq cleanup +.br .Sh DESCRIPTION ATF provides a simple but powerful interface to easily write test programs in @@ -114,13 +133,43 @@ atf_init_test_cases() { ... add additional test cases ... } .Ed +.Pp +All of these functions are required to return with an exit-status of +zero, or ATF will determine that the test is faulty. +In particular, this means that none may end with a conditional like: +.Bd -literal -offset indent +atf_sh_function() { +... appropriate code here ... +condition-test && { + ... more code here ... +} +} +.Ed +.Pp +as if condition-test fails +the return code from atf_sh_function will not be 0. +This can be corrected by adding +.Bd -literal -offset indent +return 0 +.Ed +.Pp +before the end of the function, or by writing it as +.Bd -literal -offset indent +atf_sh_function() { +... appropriate code here ... +if condition-test +then + ... more code here ... +fi +} +.Ed .Ss Definition of test cases Test cases have an identifier and are composed of three different parts: the header, the body and an optional cleanup routine, all of which are described in .Xr atf-test-case 4 . To define test cases, one can use the -.Fn atf_test_case +.Ic atf_test_case function, which takes a first parameter specifiying the test case's name and instructs the library to set things up to accept it as a valid test case. @@ -132,33 +181,34 @@ It is important to note that this functi .Em does not set the test case up for execution when the program is run. In order to do so, a later registration is needed through the -.Fn atf_add_test_case +.Ic atf_add_test_case function detailed in .Sx Program initialization . .Pp Later on, one must define the three parts of the body by providing two or three functions (remember that the cleanup routine is optional). These functions are named after the test case's identifier, and are -.Fn _head , -.Fn _body +.Ic _head , +.Ic _body and -.Fn _cleanup. +.Ic _cleanup. None of these take parameters when executed. .Ss Program initialization The test program must define an -.Fn atf_init_test_cases +.Ic atf_init_test_cases function, which is in charge of registering the test cases that will be executed at run time by using the
CVS commit: src/external/bsd/atf/dist/atf-sh
Module Name:src Committed By: christos Date: Fri Dec 4 01:43:58 UTC 2015 Modified Files: src/external/bsd/atf/dist/atf-sh: atf-check.cpp Log Message: fix the open error messages to include the right file and strerror To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/bsd/atf/dist/atf-sh/atf-check.cpp 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-sh/atf-check.cpp diff -u src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.9 src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.10 --- src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.9 Sat Feb 8 14:13:44 2014 +++ src/external/bsd/atf/dist/atf-sh/atf-check.cpp Thu Dec 3 20:43:58 2015 @@ -359,11 +359,20 @@ execute_with_shell(char* const* argv) static void +open_error(const atf::fs::path& path) +{ +throw std::runtime_error("Failed to open " + path.str() + " " + + ::strerror(errno)); +} + + +static +void cat_file(const atf::fs::path& path) { std::ifstream stream(path.c_str()); if (!stream) -throw std::runtime_error("Failed to open " + path.str()); + open_error(path); stream >> std::noskipws; std::istream_iterator< char > begin(stream), end; @@ -379,7 +388,7 @@ grep_file(const atf::fs::path& path, con { std::ifstream stream(path.c_str()); if (!stream) -throw std::runtime_error("Failed to open " + path.str()); + open_error(path); bool found = false; @@ -410,11 +419,11 @@ compare_files(const atf::fs::path& p1, c std::ifstream f1(p1.c_str()); if (!f1) -throw std::runtime_error("Failed to open " + p1.str()); + open_error(p1); std::ifstream f2(p2.c_str()); if (!f2) -throw std::runtime_error("Failed to open " + p1.str()); + open_error(p2); for (;;) { char buf1[512], buf2[512];
CVS commit: src/external/bsd/atf/dist/atf-sh
Module Name:src Committed By: christos Date: Wed Dec 30 22:23:02 UTC 2015 Modified Files: src/external/bsd/atf/dist/atf-sh: libatf-sh.subr Log Message: Work around ksh bug To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/atf/dist/atf-sh/libatf-sh.subr 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-sh/libatf-sh.subr diff -u src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.3 src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.4 --- src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.3 Thu Jan 9 20:39:32 2014 +++ src/external/bsd/atf/dist/atf-sh/libatf-sh.subr Wed Dec 30 17:23:02 2015 @@ -526,7 +526,10 @@ _atf_list_tcs() echo "ident: $(atf_get ident)" for _var in ${Test_Case_Vars}; do + # Elide ksh bug! + set +e [ "${_var}" != "ident" ] && echo "${_var}: $(atf_get ${_var})" + set -e done [ ${#} -gt 1 ] && echo
CVS commit: src/external/bsd/atf/dist/atf-sh
Module Name:src Committed By: christos Date: Thu Jun 3 18:52:46 UTC 2010 Modified Files: src/external/bsd/atf/dist/atf-sh: atf.footer.subr Log Message: Use proper signal names. Prefixing them with "SIG" is an extension which is not supported by posix shells. To generate a diff of this commit: cvs rdiff -u -r1.1.1.2 -r1.2 src/external/bsd/atf/dist/atf-sh/atf.footer.subr 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-sh/atf.footer.subr diff -u src/external/bsd/atf/dist/atf-sh/atf.footer.subr:1.1.1.2 src/external/bsd/atf/dist/atf-sh/atf.footer.subr:1.2 --- src/external/bsd/atf/dist/atf-sh/atf.footer.subr:1.1.1.2 Sat May 8 04:05:23 2010 +++ src/external/bsd/atf/dist/atf-sh/atf.footer.subr Thu Jun 3 14:52:46 2010 @@ -535,7 +535,7 @@ # _atf_sighup_handler() { -Held_Signals="${Held_Signals} SIGHUP" +Held_Signals="${Held_Signals} HUP" } # @@ -546,7 +546,7 @@ # _atf_sigint_handler() { -Held_Signals="${Held_Signals} SIGINT" +Held_Signals="${Held_Signals} INT" } # @@ -557,7 +557,7 @@ # _atf_sigterm_handler() { -Held_Signals="${Held_Signals} SIGTERM" +Held_Signals="${Held_Signals} TERM" } #
CVS commit: src/external/bsd/atf/dist/atf-sh
Module Name:src Committed By: pooka Date: Fri Nov 26 12:04:36 UTC 2010 Modified Files: src/external/bsd/atf/dist/atf-sh: atf-check.cpp Log Message: Remove spammy (debug?) prints. took ages to figure out they were not coming from my application... XXX: the memcmp below looks suspicious To generate a diff of this commit: cvs rdiff -u -r1.1.1.2 -r1.2 src/external/bsd/atf/dist/atf-sh/atf-check.cpp 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-sh/atf-check.cpp diff -u src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.1.1.2 src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.2 --- src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.1.1.2 Sun Nov 7 17:43:28 2010 +++ src/external/bsd/atf/dist/atf-sh/atf-check.cpp Fri Nov 26 12:04:36 2010 @@ -421,8 +421,6 @@ if (f2.bad()) throw std::runtime_error("Failed to read from " + p1.str()); -std::cout << "1 read: " << f1.gcount() << "\n"; -std::cout << "2 read: " << f2.gcount() << "\n"; if ((f1.gcount() == 0) && (f2.gcount() == 0)) { equal = true; break;
CVS commit: src/external/bsd/atf/dist/atf-sh
Module Name:src Committed By: jmmv Date: Mon Dec 6 18:04:02 UTC 2010 Modified Files: src/external/bsd/atf/dist/atf-sh: atf-check.cpp atf-check_test.sh Log Message: Pull up revision c917871de7dd67ba57c17496ad68fe4e4aa8b239: Fix atf-check match checker to validate lines without newline Problem found by po...@. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/atf/dist/atf-sh/atf-check.cpp cvs rdiff -u -r1.1.1.2 -r1.2 \ 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-sh/atf-check.cpp diff -u src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.2 src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.3 --- src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.2 Fri Nov 26 12:04:36 2010 +++ src/external/bsd/atf/dist/atf-sh/atf-check.cpp Mon Dec 6 18:04:02 2010 @@ -378,7 +378,7 @@ bool found = false; std::string line; -while (!found && std::getline(stream, line).good()) { +while (!found && !std::getline(stream, line).fail()) { if (atf::text::match(line, regexp)) found = true; } 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.1.1.2 src/external/bsd/atf/dist/atf-sh/atf-check_test.sh:1.2 --- src/external/bsd/atf/dist/atf-sh/atf-check_test.sh:1.1.1.2 Sun Nov 7 17:43:29 2010 +++ src/external/bsd/atf/dist/atf-sh/atf-check_test.sh Mon Dec 6 18:04:02 2010 @@ -234,6 +234,7 @@ } oflag_match_body() { +h_pass "printf no-newline" -o "match:^no-newline" h_pass "echo line1; echo foo bar" -o "match:^foo" h_pass "echo foo bar" -o "match:o b" h_fail "echo foo bar" -o "match:baz" @@ -365,6 +366,7 @@ } eflag_match_body() { +h_pass "printf no-newline 1>&2" -e "match:^no-newline" h_pass "echo line1 1>&2; echo foo bar 1>&2" -e "match:^foo" h_pass "echo foo bar 1>&2" -e "match:o b" h_fail "echo foo bar 1>&2" -e "match:baz"
CVS commit: src/external/bsd/atf/dist/atf-sh
Module Name:src Committed By: jmmv Date: Mon Dec 27 20:36:17 UTC 2010 Modified Files: src/external/bsd/atf/dist/atf-sh: atf-check.cpp Log Message: Pull up revision 869e092e4986eb5dce90331ca9a64e125d7796eb from mainstream: Revision: 869e092e4986eb5dce90331ca9a64e125d7796eb Parent: cca40eb08e7469dfe9d6ca982613458f24c1de28 Author: j...@netbsd.org Date: 12/27/10 21:19:19 Branch: org.NetBSD.atf.src Changelog: Recognize sigabrt in the signal checker Problem found by Paul Goyette. Changes against parent cca40eb08e7469dfe9d6ca982613458f24c1de28 patched atf-sh/atf-check.cpp To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/atf/dist/atf-sh/atf-check.cpp 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-sh/atf-check.cpp diff -u src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.3 src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.4 --- src/external/bsd/atf/dist/atf-sh/atf-check.cpp:1.3 Mon Dec 6 18:04:02 2010 +++ src/external/bsd/atf/dist/atf-sh/atf-check.cpp Mon Dec 27 20:36:17 2010 @@ -184,6 +184,7 @@ { "int", SIGINT }, { "quit", SIGQUIT }, { "trap", SIGTRAP }, +{ "abrt", SIGABRT }, { "kill", SIGKILL }, { "segv", SIGSEGV }, { "pipe", SIGPIPE },
CVS commit: src/external/bsd/atf/dist/atf-sh
Module Name:src Committed By: martin Date: Mon Feb 23 08:48:18 UTC 2015 Modified Files: src/external/bsd/atf/dist/atf-sh: atf_check_test.sh Log Message: Wait 10 seconds instead of 1 before killing the helper - otherwise on slow machines it might not have gotten around to execute the first command at all (and since it next waits for 42 seconds, 10 seconds is safe). To generate a diff of this commit: cvs rdiff -u -r1.1.1.5 -r1.2 \ 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-sh/atf_check_test.sh diff -u src/external/bsd/atf/dist/atf-sh/atf_check_test.sh:1.1.1.5 src/external/bsd/atf/dist/atf-sh/atf_check_test.sh:1.2 --- src/external/bsd/atf/dist/atf-sh/atf_check_test.sh:1.1.1.5 Sat Feb 8 19:11:32 2014 +++ src/external/bsd/atf/dist/atf-sh/atf_check_test.sh Mon Feb 23 08:48:18 2015 @@ -174,7 +174,7 @@ flush_stdout_on_timeout_body() "$(atf_get_srcdir)/misc_helpers" -s "$(atf_get_srcdir)" atf_check_timeout \ >out 2>err & pid="${!}" -sleep 1 +sleep 10 kill "${pid}" grep 'Executing command.*true' out \
CVS commit: src/external/bsd/atf/dist/atf-sh
Module Name:src Committed By: christos Date: Fri Jan 10 01:16:07 UTC 2014 Modified Files: src/external/bsd/atf/dist/atf-sh: libatf-sh.subr Log Message: Make cleanup work as documented; note there are no tests testing that cleanup works. To generate a diff of this commit: cvs rdiff -u -r1.1.1.5 -r1.2 src/external/bsd/atf/dist/atf-sh/libatf-sh.subr 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-sh/libatf-sh.subr diff -u src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.1.1.5 src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.2 --- src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.1.1.5 Mon Jan 16 17:36:53 2012 +++ src/external/bsd/atf/dist/atf-sh/libatf-sh.subr Thu Jan 9 20:16:07 2014 @@ -772,6 +772,7 @@ main() _atf_syntax_error "Cannot provide more than one test case name" else _atf_run_tc "${1}" +_atf_run_tc "${1}:cleanup" fi fi }
CVS commit: src/external/bsd/atf/dist/atf-sh
Module Name:src Committed By: christos Date: Fri Jan 10 01:39:32 UTC 2014 Modified Files: src/external/bsd/atf/dist/atf-sh: libatf-sh.subr Log Message: Undo previous; unfortunately the cleanup routine gets called in a different shell so it can't cleanup stuff set in the environment of the first shell. There are 2 problems: - calling the test routine directly does not cleanup (not using atf-run) - when using atf-run, the cleanup routine needs state from the running code which can only be stored in files. This will never allow us to run tests in parallel since we need to keep a known place to pass state. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/atf/dist/atf-sh/libatf-sh.subr 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-sh/libatf-sh.subr diff -u src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.2 src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.3 --- src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.2 Thu Jan 9 20:16:07 2014 +++ src/external/bsd/atf/dist/atf-sh/libatf-sh.subr Thu Jan 9 20:39:32 2014 @@ -772,7 +772,6 @@ main() _atf_syntax_error "Cannot provide more than one test case name" else _atf_run_tc "${1}" -_atf_run_tc "${1}:cleanup" fi fi }