summaryrefslogtreecommitdiffstats
path: root/test/util/vercmptest.sh
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-08-08 21:27:31 +0200
committerDan McGee <dan@archlinux.org>2011-08-08 23:49:19 +0200
commitfab66f157d1b622cb120e21373a4893ad693ff33 (patch)
tree8f1f087a36b5f49f244d669d8d2cadf2c1d3519c /test/util/vercmptest.sh
parent1a919a11b85cb882bf5e632036a9030e4a98aba0 (diff)
downloadpacman-fab66f157d1b622cb120e21373a4893ad693ff33.tar.gz
pacman-fab66f157d1b622cb120e21373a4893ad693ff33.tar.xz
Bash-ify test/util/vercmptest.sh
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'test/util/vercmptest.sh')
-rwxr-xr-xtest/util/vercmptest.sh18
1 files changed, 9 insertions, 9 deletions
diff --git a/test/util/vercmptest.sh b/test/util/vercmptest.sh
index 7ebeba53..54ede04b 100755
--- a/test/util/vercmptest.sh
+++ b/test/util/vercmptest.sh
@@ -36,7 +36,7 @@ pass() {
fail() {
echo "test: ver1: $1 ver2: $2 ret: $3 expected: $4"
echo " ==> FAILURE"
- failure=$(expr $failure + 1)
+ ((failure++))
}
# args:
@@ -45,22 +45,22 @@ runtest() {
# run the test
ret=$($bin $1 $2)
func='pass'
- [ $ret -eq $3 ] || func='fail'
+ [[ -n $ret && $ret -eq $3 ]] || func='fail'
$func $1 $2 $ret $3
- total=$(expr $total + 1)
+ ((total++))
# and run its mirror case just to be sure
reverse=0
- [ $3 -eq 1 ] && reverse=-1
- [ $3 -eq -1 ] && reverse=1
+ [[ $3 -eq 1 ]] && reverse=-1
+ [[ $3 -eq -1 ]] && reverse=1
ret=$($bin $2 $1)
func='pass'
- [ $ret -eq $reverse ] || func='fail'
+ [[ -n $ret && $ret -eq $reverse ]] || func='fail'
$func $2 $1 $ret $reverse
- total=$(expr $total + 1)
+ ((total++))
}
# use first arg as our binary if specified
-[ -n "$1" ] && bin="$1"
+[[ -n "$1" ]] && bin="$1"
if ! type -p "$bin"; then
echo "vercmp binary ($bin) could not be located"
@@ -140,7 +140,7 @@ runtest 1:1.1 1.1 1
#END TESTS
echo
-if [ $failure -eq 0 ]; then
+if [[ $failure -eq 0 ]]; then
echo "All $total tests successful"
exit 0
fi