summaryrefslogtreecommitdiff
path: root/test/util
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2013-07-29 14:57:59 -0400
committerAllan McRae <allan@archlinux.org>2013-08-21 11:00:18 +1000
commit9263cc58747a1b2ed5a345e5b35014b44decd444 (patch)
treeda45a0af15eea5ef4718929439e78f23a852da9d /test/util
parent1152052b3e27e3252f6685a369fce8a426710015 (diff)
downloadpacman-9263cc58747a1b2ed5a345e5b35014b44decd444.tar.xz
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 <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'test/util')
-rwxr-xr-xtest/util/pacsorttest.sh15
-rwxr-xr-xtest/util/vercmptest.sh16
2 files changed, 13 insertions, 18 deletions
diff --git a/test/util/pacsorttest.sh b/test/util/pacsorttest.sh
index 0abddc26..ac16c459 100755
--- a/test/util/pacsorttest.sh
+++ b/test/util/pacsorttest.sh
@@ -19,12 +19,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# default binary if one was not specified as $1
-bin='pacsort'
+bin=${1:-${PMTEST_UTIL_DIR}pacsort}
# holds counts of tests
total=23
run=0
failure=0
+if ! type -p "$bin"; then
+ echo "Bail out! pacsort binary ($bin) could not be located"
+ exit 1
+fi
+
# args:
# runtest input expected test_description optional_opts
runtest() {
@@ -42,14 +47,6 @@ runtest() {
fi
}
-# use first arg as our binary if specified
-[[ -n "$1" ]] && bin="$1"
-
-if ! type -p "$bin"; then
- echo "Bail out! pacsort binary ($bin) could not be located"
- exit 1
-fi
-
echo "Running pacsort tests..."
echo "1..$total"
diff --git a/test/util/vercmptest.sh b/test/util/vercmptest.sh
index 9297cdcb..a7fd8517 100755
--- a/test/util/vercmptest.sh
+++ b/test/util/vercmptest.sh
@@ -18,12 +18,18 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# default binary if one was not specified as $1
-bin='vercmp'
+bin=${1:-${PMTEST_UTIL_DIR}vercmp}
# holds counts of tests
total=92
run=0
failure=0
+# use first arg as our binary if specified
+if ! type -p "$bin"; then
+ echo "Bail out! vercmp binary ($bin) could not be located"
+ exit 1
+fi
+
# args:
# pass ver1 ver2 ret expected
pass() {
@@ -57,14 +63,6 @@ runtest() {
$func $2 $1 $ret $reverse
}
-# use first arg as our binary if specified
-[[ -n "$1" ]] && bin="$1"
-
-if ! type -p "$bin"; then
- echo "Bail out! vercmp binary ($bin) could not be located"
- exit 1
-fi
-
echo "# Running vercmp tests..."
echo "1..$total"