From 6787f5239975b9fa65f36dadbd37486246827d1c Mon Sep 17 00:00:00 2001
From: hanzhijun <hanzhijun1@huawei.com>
Date: Mon, 6 May 2019 16:23:24 +0800
Subject: [PATCH] Fix blockwise compat and compat test failure

---
 tests/blockwise-compat |  2 +-
 tests/compat-test      | 15 ++++++++-------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/tests/blockwise-compat b/tests/blockwise-compat
index da94ce8..64870dd 100755
--- a/tests/blockwise-compat
+++ b/tests/blockwise-compat
@@ -65,7 +65,7 @@
 }
 
 falloc() {
-	fallocate -l"$1"m $2 2>/dev/null || dd if=/dev/zero of=$2 bs=1M count=$1 2> /dev/null
+	dd if=/dev/zero of=$2 bs=1M count=$1 2> /dev/null
 }
 
 run_all_in_fs() {
diff --git a/tests/compat-test b/tests/compat-test
--- a/tests/compat-test	2019-04-30 14:21:49.588000000 +0800
+++ b/tests/compat-test	2019-04-30 15:01:33.524000000 +0800
@@ -21,6 +21,7 @@
 PWD1="93R4P4pIqAH8"
 PWD2="mymJeD8ivEhE"
 PWD3="ocMakf3fAcQO"
+PWD4="hkj123HJGS12"
 PWDW="rUkL4RUryBom"
 VK_FILE="compattest_vkfile"
 
@@ -193,17 +194,17 @@
 echo -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey $IMG $FAST_PBKDF_OPT || fail
 echo -e "$PWD0\n$PWD1" | $CRYPTSETUP luksAddKey $IMG $FAST_PBKDF_OPT 2>/dev/null && fail
 echo "[4] change key"
-echo -e "$PWD1\n$PWD0\n" | $CRYPTSETUP luksChangeKey $FAST_PBKDF_OPT $IMG || fail
+echo -e "$PWD1\n$PWD4\n" | $CRYPTSETUP luksChangeKey $FAST_PBKDF_OPT $IMG || fail
 echo -e "$PWD1\n$PWD2\n" | $CRYPTSETUP luksChangeKey $FAST_PBKDF_OPT $IMG 2>/dev/null && fail
 [ $? -ne 2 ] && fail "luksChangeKey should return EPERM exit code"
 echo "[5] remove key"
-# delete active keys PWD0, PWD2
+# delete active keys PWD2, PWD4
 echo $PWD1 | $CRYPTSETUP luksRemoveKey $IMG 2>/dev/null && fail
 [ $? -ne 2 ] && fail "luksRemove should return EPERM exit code"
-echo $PWD0 | $CRYPTSETUP luksRemoveKey $IMG || fail
 echo $PWD2 | $CRYPTSETUP luksRemoveKey $IMG || fail
+echo $PWD4 | $CRYPTSETUP luksRemoveKey $IMG || fail
 # check if keys were deleted
-echo $PWD0 | $CRYPTSETUP luksOpen $IMG --test-passphrase 2>/dev/null && fail
+echo $PWD4 | $CRYPTSETUP luksOpen $IMG --test-passphrase 2>/dev/null && fail
 [ $? -ne 2 ] && fail "luksOpen should return EPERM exit code"
 echo $PWD2 | $CRYPTSETUP luksOpen $IMG --test-passphrase 2>/dev/null && fail
 [ $? -ne 2 ] && fail "luksOpen should return EPERM exit code"
@@ -803,16 +804,16 @@
 send "YES\n"
 expect timeout abort "Enter passphrase for $LOOPDEV:"
 sleep 0.1
-send "$PWD0\n"
+send "$PWD4\n"
 expect timeout abort "Verify passphrase:"
 sleep 0.1
-send "$PWD0\n"
+send "$PWD4\n"
 expect timeout abort "Command successful."
 expect timeout abort eof
 eval spawn $CRYPTSETUP luksOpen -v $LOOPDEV --test-passphrase
 expect timeout abort "Enter passphrase for $LOOPDEV:"
 sleep 0.1
-send "$PWD0\n"
+send "$PWD4\n"
 expect timeout abort "Command successful."
 expect timeout abort eof
 exit
