3 CRYPTSETUP="../src/cryptsetup"
10 [ -b /dev/mapper/$DEV_NAME ] && dmsetup remove $DEV_NAME
11 udevadm settle >/dev/null 2>&1
12 if [ -d "$MNT_DIR" ] ; then
13 umount -f $MNT_DIR 2>/dev/null
14 rmdir $MNT_DIR 2>/dev/null
21 if [ -n "$1" ] ; then echo "FAIL $1" ; else echo "FAIL" ; fi
28 echo "TEST SKIPPED: $1"
33 format() # key_bits expected [forced]
35 dd if=/dev/zero of=$DEV bs=1M count=5 >/dev/null 2>&1
37 echo $PWD1 | $CRYPTSETUP luksFormat $DEV -q -i1 -c aes-cbc-essiv:sha256
38 [ $? -ne 0 ] && fail "Format failed."
40 # test some operation, just in case
41 echo -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey $DEV -i1 --key-slot 1
42 [ $? -ne 0 ] && fail "Keyslot add failed."
44 $CRYPTSETUP -q luksKillSlot $DEV 1
45 [ $? -ne 0 ] && fail "Keyslot removal failed."
48 if [ $(id -u) != 0 ]; then
49 echo "WARNING: You must be root to run this test, test skipped."
53 [ ! -d $MNT_DIR ] && mkdir $MNT_DIR
55 echo "[1] Using tmpfs for image"
56 DEV="$MNT_DIR/test.img"
57 mount -t tmpfs none $MNT_DIR || skip "Mounting tmpfs not available."
60 echo "[2] Kernel dmcrypt performace options"
61 echo -e "$PWD1" | $CRYPTSETUP open --type plain $DEV $DEV_NAME --perf-same_cpu_crypt >/dev/null 2>&1
62 if [ $? -ne 0 ] ; then
63 echo "TEST SKIPPED: dmcrypt options not available"
65 $CRYPTSETUP close $DEV_NAME || fail
67 echo -e "$PWD1" | $CRYPTSETUP open --type plain $DEV $DEV_NAME --perf-same_cpu_crypt --perf-submit_from_crypt_cpus || fail
68 $CRYPTSETUP status $DEV_NAME | grep -q same_cpu_crypt || fail
69 $CRYPTSETUP status $DEV_NAME | grep -q submit_from_crypt_cpus || fail
70 $CRYPTSETUP close $DEV_NAME || fail
71 echo -e "$PWD1" | $CRYPTSETUP open --type plain $DEV $DEV_NAME --perf-same_cpu_crypt --allow-discards || fail
72 $CRYPTSETUP status $DEV_NAME | grep -q same_cpu_crypt || fail
73 $CRYPTSETUP status $DEV_NAME | grep -q discards || fail
74 $CRYPTSETUP close $DEV_NAME || fail
76 echo -e "$PWD1" | $CRYPTSETUP open --type luks1 $DEV $DEV_NAME --perf-same_cpu_crypt --perf-submit_from_crypt_cpus || fail
77 $CRYPTSETUP status $DEV_NAME | grep -q same_cpu_crypt || fail
78 $CRYPTSETUP status $DEV_NAME | grep -q submit_from_crypt_cpus || fail
79 $CRYPTSETUP close $DEV_NAME || fail
80 echo -e "$PWD1" | $CRYPTSETUP open --type luks1 $DEV $DEV_NAME --perf-same_cpu_crypt --allow-discards || fail
81 $CRYPTSETUP status $DEV_NAME | grep -q same_cpu_crypt || fail
82 $CRYPTSETUP status $DEV_NAME | grep -q discards || fail
83 $CRYPTSETUP close $DEV_NAME || fail