From dba2e3c8f09a64ebf3c07323f1cb5fb2fa611d12 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Fri, 26 Dec 2008 16:32:07 +0000 Subject: [PATCH] test/common.sh: new file for common utility functions for the test scripts. Moved findprog out of manpage test script into this new file. --- ChangeLog | 8 +++++++- test/common.sh | 33 +++++++++++++++++++++++++++++++++ test/tests/manpages/test-manpages | 28 +++------------------------- 3 files changed, 43 insertions(+), 26 deletions(-) create mode 100644 test/common.sh diff --git a/ChangeLog b/ChangeLog index e561c51..d1082ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ -2008-08-03 Peter Maydell +2008-12-26 Peter Maydell + + * test/common.sh: new file for common utility functions for the + test scripts. Moved findprog out of manpage test script into this + new file. + +2008-12-25 Peter Maydell * test/runtest: automatically run setup-test if it hasn't already been done. Improve error handling in test script with 'set -e'. diff --git a/test/common.sh b/test/common.sh new file mode 100644 index 0000000..1c675e2 --- /dev/null +++ b/test/common.sh @@ -0,0 +1,33 @@ +# Common helper routines for test shell scripts -- intended to be sourced by them +test_skip () +{ + WHY="$1" + echo "$Test $0 SKIP ($WHY)" + exit 120 +} + +# portable implementation of 'which' utility +findprog() +{ + FOUND= + PROG="$1" + IFS_SAVE="$IFS" + IFS=: + for D in $PATH; do + if [ -z "$D" ]; then + D=. + fi + if [ -f "$D/$PROG" ] && [ -x "$D/$PROG" ]; then + printf '%s\n' "$D/$PROG" + break + fi + done + IFS="$IFS_SAVE" +} + +require_prog () +{ + if [ -z "$(findprog $1)" ]; then + test_skip "missing $1" + fi +} diff --git a/test/tests/manpages/test-manpages b/test/tests/manpages/test-manpages index ab06831..2ad77d8 100644 --- a/test/tests/manpages/test-manpages +++ b/test/tests/manpages/test-manpages @@ -6,31 +6,9 @@ # ###################################################### -# First find out whether we have a groff on the path: - -# portable implementation of 'which' utility -findprog() -{ - FOUND= - PROG="$1" - IFS_SAVE="$IFS" - IFS=: - for D in $PATH; do - if [ -z "$D" ]; then - D=. - fi - if [ -f "$D/$PROG" ] && [ -x "$D/$PROG" ]; then - printf '%s\n' "$D/$PROG" - break - fi - done - IFS="$IFS_SAVE" -} - -if [ -z "$(findprog groff)" ]; then - echo "Test $0 SKIP (missing groff)" - exit 120 -fi +. common.sh + +require_prog groff cd $MH_TEST_DIR/share/man -- 1.7.10.4