summaryrefslogtreecommitdiffstats
path: root/tools/regression
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2005-07-27 22:27:30 +0000
committerpjd <pjd@FreeBSD.org>2005-07-27 22:27:30 +0000
commit3f2c6109db5d1497e3f5184fc6f6b074e2ac6b4a (patch)
tree7327934a0a27fd0557932bfbbdac28ec1899fcab /tools/regression
parent354bcaec755d3c33c9e9de942efe120d3594dedc (diff)
downloadFreeBSD-src-3f2c6109db5d1497e3f5184fc6f6b074e2ac6b4a.zip
FreeBSD-src-3f2c6109db5d1497e3f5184fc6f6b074e2ac6b4a.tar.gz
Add regression tests (121 in total) for GEOM_ELI class.
To use them, run: # prove /usr/src/tools/regression/geom_eli Sponsored by: Wheel Sp. z o.o. http://www.wheel.pl MFC after: 1 week
Diffstat (limited to 'tools/regression')
-rw-r--r--tools/regression/geom_eli/attach-d.t38
-rw-r--r--tools/regression/geom_eli/delkey.t140
-rw-r--r--tools/regression/geom_eli/detach-l.t44
-rw-r--r--tools/regression/geom_eli/init.t51
-rw-r--r--tools/regression/geom_eli/kill.t97
-rw-r--r--tools/regression/geom_eli/onetime-d.t33
-rw-r--r--tools/regression/geom_eli/onetime.t48
-rw-r--r--tools/regression/geom_eli/setkey.t156
8 files changed, 607 insertions, 0 deletions
diff --git a/tools/regression/geom_eli/attach-d.t b/tools/regression/geom_eli/attach-d.t
new file mode 100644
index 0000000..de4602f
--- /dev/null
+++ b/tools/regression/geom_eli/attach-d.t
@@ -0,0 +1,38 @@
+#!/bin/sh
+# $FreeBSD$
+
+base=`basename $0`
+no=45
+sectors=100
+keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
+mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
+
+echo "1..3"
+
+dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1
+
+geli init -P -K $keyfile md${no}
+geli attach -d -p -k $keyfile md${no}
+if [ -c /dev/md${no}.eli ]; then
+ echo "ok 1"
+else
+ echo "not ok 1"
+fi
+# Be sure it doesn't detach on read.
+dd if=/dev/md${no}.eli of=/dev/null 2>/dev/null
+sleep 1
+if [ -c /dev/md${no}.eli ]; then
+ echo "ok 2"
+else
+ echo "not ok 2"
+fi
+true > /dev/md${no}.eli
+sleep 1
+if [ ! -c /dev/md${no}.eli ]; then
+ echo "ok 3"
+else
+ echo "not ok 3"
+fi
+
+mdconfig -d -u $no
+rm -f $keyfile
diff --git a/tools/regression/geom_eli/delkey.t b/tools/regression/geom_eli/delkey.t
new file mode 100644
index 0000000..2a9ae40
--- /dev/null
+++ b/tools/regression/geom_eli/delkey.t
@@ -0,0 +1,140 @@
+#!/bin/sh
+# $FreeBSD$
+
+base=`basename $0`
+no=45
+sectors=100
+keyfile1=`mktemp /tmp/$base.XXXXXX` || exit 1
+keyfile2=`mktemp /tmp/$base.XXXXXX` || exit 1
+keyfile3=`mktemp /tmp/$base.XXXXXX` || exit 1
+keyfile4=`mktemp /tmp/$base.XXXXXX` || exit 1
+mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
+
+echo "1..14"
+
+dd if=/dev/random of=${keyfile1} bs=512 count=16 >/dev/null 2>&1
+dd if=/dev/random of=${keyfile2} bs=512 count=16 >/dev/null 2>&1
+dd if=/dev/random of=${keyfile3} bs=512 count=16 >/dev/null 2>&1
+dd if=/dev/random of=${keyfile4} bs=512 count=16 >/dev/null 2>&1
+
+geli init -P -K $keyfile1 md${no}
+geli attach -p -k $keyfile1 md${no}
+geli setkey -n 1 -P -K $keyfile2 md${no}
+
+# Remove key 0 for attached provider.
+geli delkey -n 0 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 1"
+else
+ echo "not ok 1"
+fi
+geli detach md${no}
+
+# We cannot use keyfile1 anymore.
+geli attach -p -k $keyfile1 md${no} 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo "ok 2"
+else
+ echo "not ok 2"
+fi
+
+# Attach with key 1.
+geli attach -p -k $keyfile2 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 3"
+else
+ echo "not ok 3"
+fi
+
+# We cannot remove last key without -f option (for attached provider).
+geli delkey -n 1 md${no} 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo "ok 4"
+else
+ echo "not ok 4"
+fi
+
+# Remove last key for attached provider.
+geli delkey -f -n 1 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 5"
+else
+ echo "not ok 5"
+fi
+
+# If there are no valid keys, but provider is attached, we can save situation.
+geli setkey -n 0 -P -K $keyfile3 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 6"
+else
+ echo "not ok 6"
+fi
+geli detach md${no}
+
+# We cannot use keyfile2 anymore.
+geli attach -p -k $keyfile2 md${no} 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo "ok 7"
+else
+ echo "not ok 7"
+fi
+
+# Attach with key 0.
+geli attach -p -k $keyfile3 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 8"
+else
+ echo "not ok 8"
+fi
+
+# Setup key 1.
+geli setkey -n 1 -P -K $keyfile4 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 9"
+else
+ echo "not ok 9"
+fi
+geli detach md${no}
+
+# Remove key 1 for detached provider.
+geli delkey -n 1 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 10"
+else
+ echo "not ok 10"
+fi
+
+# We cannot use keyfile4 anymore.
+geli attach -p -k $keyfile4 md${no} 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo "ok 11"
+else
+ echo "not ok 11"
+fi
+
+# We cannot remove last key without -f option (for detached provider).
+geli delkey -n 0 md${no} 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo "ok 12"
+else
+ echo "not ok 12"
+fi
+
+# Remove last key for detached provider.
+geli delkey -f -n 0 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 13"
+else
+ echo "not ok 13"
+fi
+
+# We cannot use keyfile3 anymore.
+geli attach -p -k $keyfile3 md${no} 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo "ok 14"
+else
+ echo "not ok 14"
+fi
+
+mdconfig -d -u $no
+rm -f $keyfile1 $keyfile2 $keyfile3 $keyfile4
diff --git a/tools/regression/geom_eli/detach-l.t b/tools/regression/geom_eli/detach-l.t
new file mode 100644
index 0000000..ae6c3b2
--- /dev/null
+++ b/tools/regression/geom_eli/detach-l.t
@@ -0,0 +1,44 @@
+#!/bin/sh
+# $FreeBSD$
+
+base=`basename $0`
+no=45
+sectors=100
+keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
+mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
+
+echo "1..4"
+
+dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1
+
+geli init -P -K $keyfile md${no}
+geli attach -p -k $keyfile md${no}
+if [ -c /dev/md${no}.eli ]; then
+ echo "ok 1"
+else
+ echo "not ok 1"
+fi
+# Be sure it doesn't detach before 'detach -l'.
+dd if=/dev/md${no}.eli of=/dev/null 2>/dev/null
+sleep 1
+if [ -c /dev/md${no}.eli ]; then
+ echo "ok 2"
+else
+ echo "not ok 2"
+fi
+geli detach -l md${no}
+if [ -c /dev/md${no}.eli ]; then
+ echo "ok 3"
+else
+ echo "not ok 3"
+fi
+dd if=/dev/md${no}.eli of=/dev/null 2>/dev/null
+sleep 1
+if [ ! -c /dev/md${no}.eli ]; then
+ echo "ok 4"
+else
+ echo "not ok 4"
+fi
+
+mdconfig -d -u $no
+rm -f $keyfile
diff --git a/tools/regression/geom_eli/init.t b/tools/regression/geom_eli/init.t
new file mode 100644
index 0000000..5e4775c
--- /dev/null
+++ b/tools/regression/geom_eli/init.t
@@ -0,0 +1,51 @@
+#!/bin/sh
+# $FreeBSD$
+
+base=`basename $0`
+no=45
+sectors=100
+rnd=`mktemp /tmp/$base.XXXXXX` || exit 1
+keyfile=`mktemp /tmp/$base.XXXXXX` || exit 1
+mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
+
+echo "1..36"
+
+i=1
+for cipher in aes:0 aes:128 aes:192 aes:256 \
+ 3des:0 3des:192 \
+ blowfish:0 blowfish:128 blowfish:160 blowfish:192 blowfish:224 \
+ blowfish:256 blowfish:288 blowfish:320 blowfish:352 blowfish:384 \
+ blowfish:416 blowfish:448; do
+ algo=${cipher%%:*}
+ keylen=${cipher##*:}
+
+ dd if=/dev/random of=${rnd} bs=512 count=${sectors} >/dev/null 2>&1
+ dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1
+
+ geli init -a $algo -l $keylen -P -K $keyfile md${no}
+ geli attach -p -k $keyfile md${no}
+
+ dd if=${rnd} of=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null
+
+ md_rnd=`dd if=${rnd} bs=512 count=${sectors} 2>/dev/null | md5`
+ md_ddev=`dd if=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null | md5`
+ md_edev=`dd if=/dev/md${no} bs=512 count=${sectors} 2>/dev/null | md5`
+
+ if [ ${md_rnd} = ${md_ddev} ]; then
+ echo "ok $i - ${cipher}"
+ else
+ echo "not ok $i - ${cipher}"
+ fi
+ i=$((i+1))
+ if [ ${md_rnd} != ${md_edev} ]; then
+ echo "ok $i - ${cipher}"
+ else
+ echo "not ok $i - ${cipher}"
+ fi
+ i=$((i+1))
+
+ geli detach md${no}
+done
+
+mdconfig -d -u $no
+rm -f $rnd $keyfile
diff --git a/tools/regression/geom_eli/kill.t b/tools/regression/geom_eli/kill.t
new file mode 100644
index 0000000..ecd910a
--- /dev/null
+++ b/tools/regression/geom_eli/kill.t
@@ -0,0 +1,97 @@
+#!/bin/sh
+# $FreeBSD$
+
+base=`basename $0`
+no=45
+sectors=100
+keyfile1=`mktemp /tmp/$base.XXXXXX` || exit 1
+keyfile2=`mktemp /tmp/$base.XXXXXX` || exit 1
+mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
+
+echo "1..9"
+
+dd if=/dev/random of=${keyfile1} bs=512 count=16 >/dev/null 2>&1
+dd if=/dev/random of=${keyfile2} bs=512 count=16 >/dev/null 2>&1
+
+geli init -P -K $keyfile1 md${no}
+geli attach -p -k $keyfile1 md${no}
+geli setkey -n 1 -P -K $keyfile2 md${no}
+
+# Kill attached provider.
+geli kill md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 1"
+else
+ echo "not ok 1"
+fi
+sleep 1
+# Provider should be automatically detached.
+if [ ! -c /dev/md{$no}.eli ]; then
+ echo "ok 2"
+else
+ echo "not ok 2"
+fi
+
+# We cannot use keyfile1 anymore.
+geli attach -p -k $keyfile1 md${no} 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo "ok 3"
+else
+ echo "not ok 3"
+fi
+
+# We cannot use keyfile2 anymore.
+geli attach -p -k $keyfile2 md${no} 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo "ok 4"
+else
+ echo "not ok 4"
+fi
+
+geli init -P -K $keyfile1 md${no}
+geli setkey -n 1 -p -k $keyfile1 -P -K $keyfile2 md${no}
+
+# Should be possible to attach with keyfile1.
+geli attach -p -k $keyfile1 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 5"
+else
+ echo "not ok 5"
+fi
+geli detach md${no}
+
+# Should be possible to attach with keyfile2.
+geli attach -p -k $keyfile2 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 6"
+else
+ echo "not ok 6"
+fi
+geli detach md${no}
+
+# Kill detached provider.
+geli kill md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 7"
+else
+ echo "not ok 7"
+fi
+
+# We cannot use keyfile1 anymore.
+geli attach -p -k $keyfile1 md${no} 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo "ok 8"
+else
+ echo "not ok 8"
+fi
+
+# We cannot use keyfile2 anymore.
+geli attach -p -k $keyfile2 md${no} 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo "ok 9"
+else
+ echo "not ok 9"
+fi
+
+mdconfig -d -u $no
+rm -f $keyfile1 $keyfile2
diff --git a/tools/regression/geom_eli/onetime-d.t b/tools/regression/geom_eli/onetime-d.t
new file mode 100644
index 0000000..d49cb64
--- /dev/null
+++ b/tools/regression/geom_eli/onetime-d.t
@@ -0,0 +1,33 @@
+#!/bin/sh
+# $FreeBSD$
+
+base=`basename $0`
+no=45
+sectors=100
+mdconfig -a -t malloc -s $sectors -u $no || exit 1
+
+echo "1..3"
+
+geli onetime -d md${no}
+if [ -c /dev/md${no}.eli ]; then
+ echo "ok 1"
+else
+ echo "not ok 1"
+fi
+# Be sure it doesn't detach on read.
+dd if=/dev/md${no}.eli of=/dev/null 2>/dev/null
+sleep 1
+if [ -c /dev/md${no}.eli ]; then
+ echo "ok 2"
+else
+ echo "not ok 2"
+fi
+true > /dev/md${no}.eli
+sleep 1
+if [ ! -c /dev/md${no}.eli ]; then
+ echo "ok 3"
+else
+ echo "not ok 3"
+fi
+
+mdconfig -d -u $no
diff --git a/tools/regression/geom_eli/onetime.t b/tools/regression/geom_eli/onetime.t
new file mode 100644
index 0000000..d52ef56
--- /dev/null
+++ b/tools/regression/geom_eli/onetime.t
@@ -0,0 +1,48 @@
+#!/bin/sh
+# $FreeBSD$
+
+base=`basename $0`
+no=45
+sectors=100
+rnd=`mktemp /tmp/$base.XXXXXX` || exit 1
+mdconfig -a -t malloc -s $sectors -u $no || exit 1
+
+echo "1..36"
+
+i=1
+for cipher in aes:0 aes:128 aes:192 aes:256 \
+ 3des:0 3des:192 \
+ blowfish:0 blowfish:128 blowfish:160 blowfish:192 blowfish:224 \
+ blowfish:256 blowfish:288 blowfish:320 blowfish:352 blowfish:384 \
+ blowfish:416 blowfish:448; do
+ algo=${cipher%%:*}
+ keylen=${cipher##*:}
+
+ dd if=/dev/random of=${rnd} bs=512 count=${sectors} >/dev/null 2>&1
+
+ geli onetime -a $algo -l $keylen md${no}
+
+ dd if=${rnd} of=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null
+
+ md_rnd=`dd if=${rnd} bs=512 count=${sectors} 2>/dev/null | md5`
+ md_ddev=`dd if=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null | md5`
+ md_edev=`dd if=/dev/md${no} bs=512 count=${sectors} 2>/dev/null | md5`
+
+ if [ ${md_rnd} = ${md_ddev} ]; then
+ echo "ok $i - ${cipher}"
+ else
+ echo "not ok $i - ${cipher}"
+ fi
+ i=$((i+1))
+ if [ ${md_rnd} != ${md_edev} ]; then
+ echo "ok $i - ${cipher}"
+ else
+ echo "not ok $i - ${cipher}"
+ fi
+ i=$((i+1))
+
+ geli detach md${no}
+done
+
+mdconfig -d -u $no
+rm -f $rnd
diff --git a/tools/regression/geom_eli/setkey.t b/tools/regression/geom_eli/setkey.t
new file mode 100644
index 0000000..a219188
--- /dev/null
+++ b/tools/regression/geom_eli/setkey.t
@@ -0,0 +1,156 @@
+#!/bin/sh
+# $FreeBSD$
+
+base=`basename $0`
+no=45
+sectors=100
+rnd=`mktemp /tmp/$base.XXXXXX` || exit 1
+keyfile1=`mktemp /tmp/$base.XXXXXX` || exit 1
+keyfile2=`mktemp /tmp/$base.XXXXXX` || exit 1
+keyfile3=`mktemp /tmp/$base.XXXXXX` || exit 1
+keyfile4=`mktemp /tmp/$base.XXXXXX` || exit 1
+keyfile5=`mktemp /tmp/$base.XXXXXX` || exit 1
+mdconfig -a -t malloc -s `expr $sectors + 1` -u $no || exit 1
+
+echo "1..16"
+
+dd if=/dev/random of=${rnd} bs=512 count=${sectors} >/dev/null 2>&1
+hash1=`dd if=${rnd} bs=512 count=${sectors} 2>/dev/null | md5`
+dd if=/dev/random of=${keyfile1} bs=512 count=16 >/dev/null 2>&1
+dd if=/dev/random of=${keyfile2} bs=512 count=16 >/dev/null 2>&1
+dd if=/dev/random of=${keyfile3} bs=512 count=16 >/dev/null 2>&1
+dd if=/dev/random of=${keyfile4} bs=512 count=16 >/dev/null 2>&1
+dd if=/dev/random of=${keyfile5} bs=512 count=16 >/dev/null 2>&1
+
+geli init -P -K $keyfile1 md${no}
+geli attach -p -k $keyfile1 md${no}
+
+dd if=${rnd} of=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null
+rm -f $rnd
+hash2=`dd if=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null | md5`
+
+# Change current key (0) for attached provider.
+geli setkey -P -K $keyfile2 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 1"
+else
+ echo "not ok 1"
+fi
+geli detach md${no}
+
+# We cannot use keyfile1 anymore.
+geli attach -p -k $keyfile1 md${no} 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo "ok 2"
+else
+ echo "not ok 2"
+fi
+
+# Attach with new key.
+geli attach -p -k $keyfile2 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 3"
+else
+ echo "not ok 3"
+fi
+hash3=`dd if=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null | md5`
+
+# Change key 1 for attached provider.
+geli setkey -n 1 -P -K $keyfile3 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 4"
+else
+ echo "not ok 4"
+fi
+geli detach md${no}
+
+# Attach with key 1.
+geli attach -p -k $keyfile3 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 5"
+else
+ echo "not ok 5"
+fi
+hash4=`dd if=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null | md5`
+geli detach md${no}
+
+# Change current (1) key for detached provider.
+geli setkey -p -k $keyfile3 -P -K $keyfile4 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 6"
+else
+ echo "not ok 6"
+fi
+
+# We cannot use keyfile3 anymore.
+geli attach -p -k $keyfile3 md${no} 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo "ok 7"
+else
+ echo "not ok 7"
+fi
+
+# Attach with key 1.
+geli attach -p -k $keyfile4 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 8"
+else
+ echo "not ok 8"
+fi
+hash5=`dd if=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null | md5`
+geli detach md${no}
+
+# Change key 0 for detached provider.
+geli setkey -n 0 -p -k $keyfile4 -P -K $keyfile5 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 9"
+else
+ echo "not ok 9"
+fi
+
+# We cannot use keyfile2 anymore.
+geli attach -p -k $keyfile2 md${no} 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo "ok 10"
+else
+ echo "not ok 10"
+fi
+
+# Attach with key 0.
+geli attach -p -k $keyfile5 md${no}
+if [ $? -eq 0 ]; then
+ echo "ok 11"
+else
+ echo "not ok 11"
+fi
+hash6=`dd if=/dev/md${no}.eli bs=512 count=${sectors} 2>/dev/null | md5`
+geli detach md${no}
+
+if [ ${hash1} = ${hash2} ]; then
+ echo "ok 12"
+else
+ echo "not ok 12"
+fi
+if [ ${hash1} = ${hash3} ]; then
+ echo "ok 13"
+else
+ echo "not ok 13"
+fi
+if [ ${hash1} = ${hash4} ]; then
+ echo "ok 14"
+else
+ echo "not ok 14"
+fi
+if [ ${hash1} = ${hash5} ]; then
+ echo "ok 15"
+else
+ echo "not ok 15"
+fi
+if [ ${hash1} = ${hash6} ]; then
+ echo "ok 16"
+else
+ echo "not ok 16"
+fi
+
+mdconfig -d -u $no
+rm -f $keyfile1 $keyfile2 $keyfile3 $keyfile4 $keyfile5
OpenPOWER on IntegriCloud