Rename align test (Anyone mentioned autoconfigure?). Add some minor changes, run...
authorMilan Broz <gmazyland@gmail.com>
Sat, 1 May 2010 09:58:55 +0000 (09:58 +0000)
committerMilan Broz <gmazyland@gmail.com>
Sat, 1 May 2010 09:58:55 +0000 (09:58 +0000)
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@210 36d66b0a-2a48-0410-832c-cd162a569da5

tests/Makefile.am
tests/align-test [moved from tests/align_test with 85% similarity]

index b7533b2..3590cac 100644 (file)
@@ -1,6 +1,6 @@
-TESTS = apitest compat-test
+TESTS = apitest compat-test align-test
 
-EXTRA_DIST = fileDiffer.py compatimage.img.bz2 align_test compat-test
+EXTRA_DIST = fileDiffer.py compatimage.img.bz2 align-test compat-test
 
 apitest_SOURCES = apitest.c
 apitest_LDADD = ../lib/libcryptsetup.la
similarity index 85%
rename from tests/align_test
rename to tests/align-test
index a6c1eaf..41ecd52 100755 (executable)
@@ -3,24 +3,34 @@
 CRYPTSETUP="../src/cryptsetup"
 DEV=""
 
+cleanup() {
+       udevadm settle
+       rmmod scsi_debug 2>/dev/null
+       sleep 2
+}
+
 fail()
 {
        [ -n "$1" ] && echo "$1"
+       cleanup
        exit 100
 }
 
 add_device() {
        modprobe scsi_debug $@
        sleep 2
-       DEV=/dev/$(grep scsi_debug /sys/block/*/device/model | cut -f4 -d /)
+       DEV=$(grep scsi_debug /sys/block/*/device/model | cut -f4 -d /)
+
+       if [ ! -e /sys/block/$DEV/alignment_offset ] ; then
+               echo "This kernel seems to not support topology info, test skipped."
+               cleanup
+               exit 0
+       fi
+
+       DEV="/dev/$DEV"
        [ -b $DEV ] || fail "Cannot find $DEV."
 }
 
-cleanup() {
-       udevadm settle
-       rmmod scsi_debug 2>/dev/null
-       sleep 2
-}
 
 format() # key_bits expected [forced]
 {
@@ -43,6 +53,11 @@ format() # key_bits expected [forced]
        echo "PASSED"
 }
 
+if [ $(id -u) != 0 ]; then
+       echo "WARNING: You must be root to run this test, test skipped."
+       exit 0
+fi
+
 modprobe --dry-run scsi_debug || exit 0
 cleanup