diff options
author | Dieter Plaetinck <dieter@plaetinck.be> | 2009-07-21 22:11:47 +0200 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2009-07-21 22:11:47 +0200 |
commit | 3bd20bde1e49ab664cc53262ec5ebb3e6323d3f6 (patch) | |
tree | bd7e686e44c3f4e62dc83712b7be94b0e550d204 /tests/lib | |
parent | d982d8e1f9e6b806d44340ca28858e388a1fded7 (diff) |
make tests separate reusable files + make the testing thing a bit better
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/framework-runtime | 35 | ||||
-rw-r--r-- | tests/lib/setup-file | 5 | ||||
-rw-r--r-- | tests/lib/test-file | 6 | ||||
-rw-r--r-- | tests/lib/test-lvm-lv | 9 | ||||
-rw-r--r-- | tests/lib/test-mount | 6 | ||||
-rw-r--r-- | tests/lib/test-nofile | 6 | ||||
-rw-r--r-- | tests/lib/test-nopackage | 11 | ||||
-rw-r--r-- | tests/lib/test-ping | 7 | ||||
-rw-r--r-- | tests/lib/test-swap | 5 |
9 files changed, 90 insertions, 0 deletions
diff --git a/tests/lib/framework-runtime b/tests/lib/framework-runtime new file mode 100644 index 0000000..c1b16fd --- /dev/null +++ b/tests/lib/framework-runtime @@ -0,0 +1,35 @@ +#!/bin/bash +lib="/usr/share/aif/tests/lib" +STATUS=0 + +# $1 name of test +# $2... other args +function aiftest () { + name=$1 + shift + if [ ! -f $lib/test-$name ] + then + echo "NO SUCH TEST: $lib/test-$1" >&2 + return 2 + else + $lib/test-$name "$@" + ret=$? + if [ $ret -eq 0 ] + then + "$NAME : OK" + else + "$NAME [ $ret ] : NOT OK" + fi + [ $ret -gt $STATUS ] && STATUS=$ret +} + +aiftest-done () { + if [ $STATUS -eq 0 ] + then + echo 'ALL TESTS ENDED SUCCESSFULLY' + exit 0 + else + echo 'ONE OR MORE TESTS FAILED!' >&2 + exit $STATUS + fi +} diff --git a/tests/lib/setup-file b/tests/lib/setup-file new file mode 100644 index 0000000..eeb8b17 --- /dev/null +++ b/tests/lib/setup-file @@ -0,0 +1,5 @@ +#!/bin/bash +for i in "$@" +do + touch $i/test_file +done diff --git a/tests/lib/test-file b/tests/lib/test-file new file mode 100644 index 0000000..b1504ae --- /dev/null +++ b/tests/lib/test-file @@ -0,0 +1,6 @@ +#!/bin/bash +# $1 filename + +NAME="FILE TEST, $1" + +[ -f "$1" ] diff --git a/tests/lib/test-lvm-lv b/tests/lib/test-lvm-lv new file mode 100644 index 0000000..2c6a6bc --- /dev/null +++ b/tests/lib/test-lvm-lv @@ -0,0 +1,9 @@ +#!/bin/bash +# $1 VG +# $2 LV +# $2 SIZE eg '800.00 MB' + +NAME="LOGICAL VOLUME CHECK, /dev/mapper/$1-$2" + +lvdisplay | grep -A 5 'LV Name.*/dev/mapper/'$1-$2 | grep -q available || exit 1 +lvdisplay | grep -A 7 'LV Name.*/dev/mapper/'$1-$2 | grep -q 'LV Size.*'"$2" || exit 2 diff --git a/tests/lib/test-mount b/tests/lib/test-mount new file mode 100644 index 0000000..e45715a --- /dev/null +++ b/tests/lib/test-mount @@ -0,0 +1,6 @@ +#!/bin/bash +# $1 mount output string + +NAME="MOUNT CHECK, $1" + +mount | grep -q '/dev/mapper/cryptpool-crypthome on /home type xfs (rw)' diff --git a/tests/lib/test-nofile b/tests/lib/test-nofile new file mode 100644 index 0000000..f5e13c5 --- /dev/null +++ b/tests/lib/test-nofile @@ -0,0 +1,6 @@ +#!/bin/bash +# $1 filename + +NAME="NOFILE TEST, $1" + +[ ! -f "$1" ] diff --git a/tests/lib/test-nopackage b/tests/lib/test-nopackage new file mode 100644 index 0000000..62bfc36 --- /dev/null +++ b/tests/lib/test-nopackage @@ -0,0 +1,11 @@ +#!/bin/bash +# $1 packagename + +NAME="NO PACKAGE, $1" + +if pacman -Qi $1 +then + exit 1 +else + exit 0 +fi diff --git a/tests/lib/test-ping b/tests/lib/test-ping new file mode 100644 index 0000000..2fba015 --- /dev/null +++ b/tests/lib/test-ping @@ -0,0 +1,7 @@ +#!/bin/bash +# $1 iterations +# $2 host + +NAME="PING CHECK ON $2" + +ping -c $1 $2 diff --git a/tests/lib/test-swap b/tests/lib/test-swap new file mode 100644 index 0000000..892815d --- /dev/null +++ b/tests/lib/test-swap @@ -0,0 +1,5 @@ +#!/bin/bash + +name="SWAP CHECK, SIZE $1" + +free -m | grep -q 'Swap:.*'$1'.*'
\ No newline at end of file |