summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2009-07-21 18:51:33 +0200
committerDieter Plaetinck <dieter@plaetinck.be>2009-07-21 18:51:33 +0200
commit59d9b7dfd24e53c205cff5a75057e218e781fd1a (patch)
treef80369d205401093804580e3f5f90f4a87909b10
parentf711f60ecc63dddc8fb1d62fdb4dcfa3a08fa2e2 (diff)
experimental test suite, with one test
-rw-r--r--Makefile4
-rw-r--r--README4
-rwxr-xr-xsrc/aif-test.sh28
-rwxr-xr-xtests/buildtime/test-check_is_in.sh (renamed from tests/test-check_is_in.sh)0
-rwxr-xr-xtests/buildtime/test-menus.sh (renamed from tests/test-menus.sh)0
-rw-r--r--tests/runtime/automatic-lvm-dmcrypt-install-sda/install.sh2
-rw-r--r--tests/runtime/automatic-lvm-dmcrypt-install-sda/perform_test.sh20
-rw-r--r--tests/runtime/automatic-lvm-dmcrypt-install-sda/profile (renamed from examples/test-on-sda)9
-rw-r--r--tests/runtime/automatic-lvm-dmcrypt-install-sda/setup_test.sh6
9 files changed, 64 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 61a524c..051d959 100644
--- a/Makefile
+++ b/Makefile
@@ -4,9 +4,11 @@ install:
install -d $(DESTDIR)/sbin
install -d $(DESTDIR)/usr/share/aif/docs
install -d $(DESTDIR)/usr/share/aif/examples
+ install -d $(DESTDIR)/usr/share/aif/tests
install -d $(DESTDIR)/usr/lib/aif/core
install -d $(DESTDIR)/usr/lib/aif/user
install -D -m755 src/aif.sh $(DESTDIR)/sbin/aif
+ install -D -m755 src/aif-test.sh $(DESTDIR)/sbin/aif-test
install -D -m644 HOWTO $(DESTDIR)/usr/share/aif/docs
install -D -m644 README $(DESTDIR)/usr/share/aif/docs
cp -rp src/core $(DESTDIR)/usr/lib/aif
@@ -15,6 +17,8 @@ install:
chmod -R 755 $(DESTDIR)/usr/lib/aif/user
cp -rp examples $(DESTDIR)/usr/share/aif
chmod -R 755 $(DESTDIR)/usr/share/aif/examples
+ cp -rp tests $(DESTDIR)/usr/share/aif
+ chmod -R 755 $(DESTDIR)/usr/share/aif/tests
uninstall:
diff --git a/README b/README
index d7bf625..ae7f2d4 100644
--- a/README
+++ b/README
@@ -211,3 +211,7 @@ the runtime (install cd live environment), target (affects/belongs to the
target installation) and TMP (everything in between or extra). Variablenames
should have _TARGET or _TMP suffixes or none for runtime. (That's the
theory, it isn't always the case like that now, I need to do more refactoring)
+
+** Test suite **
+
+AIF also has a (WIP) test-suited. the source is the documentation.
diff --git a/src/aif-test.sh b/src/aif-test.sh
new file mode 100755
index 0000000..4d2110e
--- /dev/null
+++ b/src/aif-test.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+echo "Aif-test: a 'unit-testing' tool for AIF"
+echo " for a list of available tests: find /usr/share/aif/tests/"
+[ "$1" != runtime] && echo "\$1: type of test to execute (runtime. no support for buildtime yet)" >&2 && exit 1
+[ -z "$2" ] && echo "\$2: name of test to execute" >&2 && exit 1
+
+test_dir="/usr/share/aif/tests/$1/$2"
+[ ! -d "$test_dir" ] && echo "No such test found: $test_dir" >&2 && exit 2
+
+echo "Running test $test_dir. THIS WILL PROBABLY ERASE DATA ON ONE OR MORE OF YOUR HARD DISKS. TO ABORT PRESS CTRL-C WITHIN 10 SECONDS"
+sleep 10
+
+# this script should install the system
+$test_dir/install.sh || fail=1
+
+# this script does any additional things such as touching files that we should recognize later
+$test_dir/setup_test.sh || fail=1
+
+# this script will do the actual testing (network check, recognize filesystems and files, ..)
+cp $test_dir/perform_test.sh /mnt/etc/rc.d/perform_test || fail=1
+
+# make sure the test will run on the target system
+sed -i's#DAEMONS=(\(.*\))#DAEMONS=(\1 perform_test)#' /mnt/etc/rc.conf || fail=1
+
+[ "$fail" == '1' ] && echo "Something failed. will not reboot" >&2 && exit 3
+
+reboot
diff --git a/tests/test-check_is_in.sh b/tests/buildtime/test-check_is_in.sh
index 0d97361..0d97361 100755
--- a/tests/test-check_is_in.sh
+++ b/tests/buildtime/test-check_is_in.sh
diff --git a/tests/test-menus.sh b/tests/buildtime/test-menus.sh
index b8dd99c..b8dd99c 100755
--- a/tests/test-menus.sh
+++ b/tests/buildtime/test-menus.sh
diff --git a/tests/runtime/automatic-lvm-dmcrypt-install-sda/install.sh b/tests/runtime/automatic-lvm-dmcrypt-install-sda/install.sh
new file mode 100644
index 0000000..735824a
--- /dev/null
+++ b/tests/runtime/automatic-lvm-dmcrypt-install-sda/install.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+aif -p automatic -c /usr/share/aif/tests/runtime/automatic-lvm-dmcrypt-install-sda/profile -d \ 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
new file mode 100644
index 0000000..d0a20b0
--- /dev/null
+++ b/tests/runtime/automatic-lvm-dmcrypt-install-sda/perform_test.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+
+free -m | grep 'Swap:.*20.*' || echo 'SWAP CHECK FAILED'
+
+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'
+
+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/examples/test-on-sda b/tests/runtime/automatic-lvm-dmcrypt-install-sda/profile
index 45ad187..1494d3a 100644
--- a/examples/test-on-sda
+++ b/tests/runtime/automatic-lvm-dmcrypt-install-sda/profile
@@ -1,6 +1,3 @@
-# this config is like fancy-install-on-sda but with small filesystems. very usefull for quickly testing in VM's
-# this config is meant for testing AIF and is not very suited for end users.
-
phase_finish=(msg_report grub_hack)
@@ -16,12 +13,6 @@ TARGET_GROUPS=base
TARGET_PACKAGES_EXCLUDE='reiserfsprogs'
TARGET_PACKAGES=openssh
-# you can optionally also override some functions...
-worker_intro () {
- infofy "Automatic procedure running the test-install-on-sda example config. this will install a system with lvm on top of dm_crypt. THIS WILL ERASE AND OVERWRITE YOUR /DEV/SDA. IF YOU DO NOT WANT THIS PRESS CTRL+C WITHIN 10 SECONDS"
- sleep 10
-}
-
worker_configure_system () {
sed -i 's/filesystems/usbinput keymap encrypt lvm2 filesystems/' $var_TARGET_DIR/etc/mkinitcpio.conf
}
diff --git a/tests/runtime/automatic-lvm-dmcrypt-install-sda/setup_test.sh b/tests/runtime/automatic-lvm-dmcrypt-install-sda/setup_test.sh
new file mode 100644
index 0000000..d5bc0d0
--- /dev/null
+++ b/tests/runtime/automatic-lvm-dmcrypt-install-sda/setup_test.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+for i in /etc/ / /root/ /home/ /var/
+do
+ touch /mnt${i}test_file
+done