From 9263cc58747a1b2ed5a345e5b35014b44decd444 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Mon, 29 Jul 2013 14:57:59 -0400 Subject: provide default values for test scripts Our test scripts currently require that the first argument be the library or binary to be tested. This makes integrating them with automake which doesn't have a mechanism for passing specific arguments to individual tests. Instead, provide a default built from paths in the environment which can be provided to all test scripts by automake. Signed-off-by: Andrew Gregory Signed-off-by: Allan McRae --- test/scripts/human_to_size_test.sh | 7 ++++--- test/scripts/parseopts_test.sh | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'test/scripts') diff --git a/test/scripts/human_to_size_test.sh b/test/scripts/human_to_size_test.sh index 678fa876..63061372 100755 --- a/test/scripts/human_to_size_test.sh +++ b/test/scripts/human_to_size_test.sh @@ -3,11 +3,12 @@ declare -i testcount=0 fail=0 pass=0 total=15 # source the library function -if [[ -z $1 || ! -f $1 ]]; then - printf "Bail out! path to human_to_size library not provided or does not exist\n" +lib=${1:-${PMTEST_SCRIPTLIB_DIR}human_to_size.sh} +if [[ -z $lib || ! -f $lib ]]; then + echo "Bail out! human_to_size library ($lib) could not be located\n" exit 1 fi -. "$1" +. "$lib" if ! type -t human_to_size >/dev/null; then printf 'Bail out! human_to_size function not found\n' diff --git a/test/scripts/parseopts_test.sh b/test/scripts/parseopts_test.sh index 8df1908b..5ff4bc55 100755 --- a/test/scripts/parseopts_test.sh +++ b/test/scripts/parseopts_test.sh @@ -3,11 +3,12 @@ declare -i testcount=0 pass=0 fail=0 total=25 # source the library function -if [[ -z $1 || ! -f $1 ]]; then - printf "Bail out! path to parseopts library not provided or does not exist\n" +lib=${1:-${PMTEST_SCRIPTLIB_DIR}parseopts.sh} +if [[ -z $lib || ! -f $lib ]]; then + printf "Bail out! parseopts library ($lib) could not be located\n" exit 1 fi -. "$1" +. "$lib" if ! type -t parseopts >/dev/null; then printf 'Bail out! parseopts function not found\n' -- cgit v1.2.3-24-g4f1b