diff options
author | Cameron Katri <me@cameronkatri.com> | 2021-05-09 14:20:58 -0400 |
---|---|---|
committer | Cameron Katri <me@cameronkatri.com> | 2021-05-09 14:20:58 -0400 |
commit | 5fd83771641d15c418f747bd343ba6738d3875f7 (patch) | |
tree | 5abf0f78f680d9837dbd93d4d4c3933bb7509599 /shell_cmds/tests | |
download | apple_cmds-5fd83771641d15c418f747bd343ba6738d3875f7.tar.gz apple_cmds-5fd83771641d15c418f747bd343ba6738d3875f7.tar.zst apple_cmds-5fd83771641d15c418f747bd343ba6738d3875f7.zip |
Import macOS userland
adv_cmds-176
basic_cmds-55
bootstrap_cmds-116.100.1
developer_cmds-66
diskdev_cmds-667.40.1
doc_cmds-53.60.1
file_cmds-321.40.3
mail_cmds-35
misc_cmds-34
network_cmds-606.40.1
patch_cmds-17
remote_cmds-63
shell_cmds-216.60.1
system_cmds-880.60.2
text_cmds-106
Diffstat (limited to 'shell_cmds/tests')
-rw-r--r-- | shell_cmds/tests/regress.m4 | 59 | ||||
-rw-r--r-- | shell_cmds/tests/shell_cmds.plist | 53 |
2 files changed, 112 insertions, 0 deletions
diff --git a/shell_cmds/tests/regress.m4 b/shell_cmds/tests/regress.m4 new file mode 100644 index 0000000..c06caa1 --- /dev/null +++ b/shell_cmds/tests/regress.m4 @@ -0,0 +1,59 @@ +# $FreeBSD: head/usr.bin/tests/regress.m4 263227 2014-03-16 08:04:06Z jmmv $ + +dnl A library of routines for doing regression tests for userland utilities. + +dnl Start up. We initialise the exit status to 0 (no failure) and change +dnl into the directory specified by our first argument, which is the +dnl directory to run the tests inside. +define(`REGRESSION_START', +TESTDIR=$1 +if [ -z "$TESTDIR" ]; then + TESTDIR=. +fi +cd $TESTDIR + +STATUS=0) + +dnl Check $? to see if we passed or failed. The first parameter is the test +dnl which passed or failed. It may be nil. +define(`REGRESSION_PASSFAIL', +if [ $? -eq 0 ]; then + echo "ok - $1 # Test detected no regression. (in $TESTDIR)" +else + STATUS=$? + echo "not ok - $1 # Test failed: regression detected. See above. (in $TESTDIR)" +fi) + +dnl An actual test. The first parameter is the test name. The second is the +dnl command/commands to execute for the actual test. Their exit status is +dnl checked. It is assumed that the test will output to stdout, and that the +dnl output to be used to check for regression will be in regress.TESTNAME.out. +define(`REGRESSION_TEST', +$2 | diff -u ${SRCDIR:-.}/regress.$1.out - +REGRESSION_PASSFAIL($1)) + +dnl A freeform regression test. Only exit status is checked. +define(`REGRESSION_TEST_FREEFORM', +$2 +REGRESSION_PASSFAIL($1)) + +dnl A regression test like REGRESSION_TEST, except only regress.out is used +dnl for checking output differences. The first argument is the command, the +dnl second argument (which may be empty) is the test name. +define(`REGRESSION_TEST_ONE', +$1 | diff -u ${SRCDIR:-.}/regress.out - +REGRESSION_PASSFAIL($2)) + +dnl A fatal error. This will exit with the given status (first argument) and +dnl print the message (second argument) prefixed with the string "FATAL :" to +dnl the error stream. +define(`REGRESSION_FATAL', +echo "Bail out! $2 (in $TESTDIR)" > /dev/stderr +exit $1) + +dnl Cleanup. Exit with the status code of the last failure. Should probably +dnl be the number of failed tests, but hey presto, this is what it does. This +dnl could also clean up potential droppings, if some forms of regression tests +dnl end up using mktemp(1) or such. +define(`REGRESSION_END', +exit $STATUS) diff --git a/shell_cmds/tests/shell_cmds.plist b/shell_cmds/tests/shell_cmds.plist new file mode 100644 index 0000000..bdeb182 --- /dev/null +++ b/shell_cmds/tests/shell_cmds.plist @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>Project</key> + <string>libutil</string> + <key>Tests</key> + <array> + <dict> + <key>Command</key> + <array> + <string>/bin/sh</string> + <string>/AppleInternal/Tests/shell_cmds/printf/legacy_test.sh</string> + </array> + <key>IgnoreOutput</key><true/> + <key>TestName</key><string>shell_cmds.printf</string> + <key>WhenToRun</key> + <array> + <string>PRESUBMISSION</string> + <string>NIGHTLY</string> + </array> + </dict> + <dict> + <key>Command</key> + <array> + <string>/bin/sh</string> + <string>/AppleInternal/Tests/shell_cmds/test/legacy_test.sh</string> + </array> + <key>TestName</key><string>shell_cmds.test</string> + <key>WhenToRun</key> + <array> + <string>PRESUBMISSION</string> + <string>NIGHTLY</string> + </array> + </dict> + <dict> + <key>Command</key> + <array> + <string>/bin/sh</string> + <string>/AppleInternal/Tests/shell_cmds/time/test_time.sh</string> + </array> + <key>TestName</key><string>shell_cmds.time</string> + <key>WhenToRun</key> + <array> + <string>PRESUBMISSION</string> + <string>NIGHTLY</string> + </array> + </dict> + </array> + <key>Timeout</key> + <integer>30</integer> +</dict> +</plist> |