summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2009-07-21 22:11:47 +0200
committerDieter Plaetinck <dieter@plaetinck.be>2009-07-21 22:11:47 +0200
commit3bd20bde1e49ab664cc53262ec5ebb3e6323d3f6 (patch)
treebd7e686e44c3f4e62dc83712b7be94b0e550d204 /tests
parentd982d8e1f9e6b806d44340ca28858e388a1fded7 (diff)
make tests separate reusable files + make the testing thing a bit better
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/framework-runtime35
-rw-r--r--tests/lib/setup-file5
-rw-r--r--tests/lib/test-file6
-rw-r--r--tests/lib/test-lvm-lv9
-rw-r--r--tests/lib/test-mount6
-rw-r--r--tests/lib/test-nofile6
-rw-r--r--tests/lib/test-nopackage11
-rw-r--r--tests/lib/test-ping7
-rw-r--r--tests/lib/test-swap5
-rw-r--r--tests/runtime/automatic-lvm-dmcrypt-install-sda/perform_test.sh26
-rw-r--r--tests/runtime/automatic-lvm-dmcrypt-install-sda/profile2
11 files changed, 106 insertions, 12 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
diff --git a/tests/runtime/automatic-lvm-dmcrypt-install-sda/perform_test.sh b/tests/runtime/automatic-lvm-dmcrypt-install-sda/perform_test.sh
index d0a20b0..390ee63 100644
--- a/tests/runtime/automatic-lvm-dmcrypt-install-sda/perform_test.sh
+++ b/tests/runtime/automatic-lvm-dmcrypt-install-sda/perform_test.sh
@@ -1,20 +1,24 @@
-#!/bin/sh
+#!/bin/bash
+source /usr/share/aif/tests/lib/framework-runtime
-free -m | grep 'Swap:.*20.*' || echo 'SWAP CHECK FAILED'
+aiftest swap 19
+aiftest lvm-lv cryptpool cryptroot '800.00 MB'
+aiftest mount '/dev/mapper/cryptpool-cryptroot on / type xfs (rw)'
+aiftest mount '/dev/mapper/cryptpool-crypthome on /home type xfs (rw)'
+for i in /etc/ / /root/ /home/ /var/
+do
+ aiftest file "$i"/test_file
+done
+aiftest file /usr/bin/ssh
+aiftest nofile /sbin/mkfs.reiserfs
+aiftest nopackage sudo
+aiftest ping 2 archlinux.org
-lvdisplay | grep -A 5 'LV Name.*/dev/mapper/cryptpool-cryptroot' | grep available || echo 'LV ROOT CHECK FAILED'
-lvdisplay | grep -A 7 'LV Name.*/dev/mapper/cryptpool-cryptroot' | grep 'LV Size.*800.00 MB' || echo 'LV ROOT CHECK FAILED'
+aiftest-done
-mount | grep '/dev/mapper/cryptpool-cryptroot on / type xfs (rw)' || echo 'ROOT FS CHECK FAILED'
-mount | grep '/dev/mapper/cryptpool-crypthome on /home type xfs (rw)' || echo 'HOME FS CHECK FAILED'
-for i in /etc/ / /root/ /home/ /var/
-do
[ -f "$i/test_file" ] || echo "TEST FAILED. NO FILE $i/test_file"
-done
-[ -x /usr/bin/ssh ] || echo 'PACKAGE INSTALLATION CHECK SSH FAILED'
-[ -f /sbin/mkfs.reiserfs ] && echo 'PACKAGE INSTALLATION CHECK REISERFS FAILED'
ping -c 2 archlinux.org || echo 'PING CHECK FAILED'
diff --git a/tests/runtime/automatic-lvm-dmcrypt-install-sda/profile b/tests/runtime/automatic-lvm-dmcrypt-install-sda/profile
index 1494d3a..484de8e 100644
--- a/tests/runtime/automatic-lvm-dmcrypt-install-sda/profile
+++ b/tests/runtime/automatic-lvm-dmcrypt-install-sda/profile
@@ -11,7 +11,7 @@ RUNTIME_PACKAGES=
# packages to install
TARGET_GROUPS=base
TARGET_PACKAGES_EXCLUDE='reiserfsprogs'
-TARGET_PACKAGES=openssh
+TARGET_PACKAGES='openssh aif'
worker_configure_system () {
sed -i 's/filesystems/usbinput keymap encrypt lvm2 filesystems/' $var_TARGET_DIR/etc/mkinitcpio.conf