aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Broz <gmazyland@gmail.com>2023-11-22 15:48:48 +0100
committerMilan Broz <gmazyland@gmail.com>2023-11-22 15:48:48 +0100
commitdfbb7752b55f122dc5fa55545529032713c49e71 (patch)
tree1118624274114dfeea2ea86bc742c5fbc47a2844
parent6b2cf68713f8a3264731a06d454ecc10792f1c4b (diff)
downloadcryptsetup-dfbb7752b55f122dc5fa55545529032713c49e71.tar.gz
tests: fail early if PSID reset does not work for device.
This should stop user from using wrong device for tests.
-rwxr-xr-xtests/compat-test-opal20
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/compat-test-opal b/tests/compat-test-opal
index 5b62e1ab..70f503a1 100755
--- a/tests/compat-test-opal
+++ b/tests/compat-test-opal
@@ -61,7 +61,8 @@ function remove_mapping()
function fail()
{
[ -n "$1" ] && echo "$1"
- remove_mapping_and_reset
+ remove_mapping
+ reset_device_psid_nofail
echo "FAILED backtrace:"
while caller $frame; do ((frame++)); done
exit 2
@@ -85,10 +86,15 @@ function skip()
exit 77
}
-function remove_mapping_and_reset()
+function reset_device_psid()
{
- remove_mapping
- $CRYPTSETUP_RAW luksErase --hw-opal-factory-reset --key-file $OPAL2_PSID_FILE $OPAL2_DEV -q
+ $CRYPTSETUP_RAW luksErase --hw-opal-factory-reset --key-file $OPAL2_PSID_FILE $OPAL2_DEV -q || \
+ fail "PSID reset fail, wrong device used?"
+}
+
+function reset_device_psid_nofail()
+{
+ $CRYPTSETUP_RAW luksErase --hw-opal-factory-reset --key-file $OPAL2_PSID_FILE $OPAL2_DEV -q 2>/dev/null
}
function prepare()
@@ -97,7 +103,8 @@ function prepare()
case "$2" in
reset)
- remove_mapping_and_reset
+ remove_mapping
+ reset_device_psid
;;
wipe)
$CRYPTSETUP_RAW isLuks --type luks2 $HEADER_IMG -q 2>/dev/null
@@ -1313,5 +1320,6 @@ test_device_detached_header $HEADER_IMG --hw-opal "-s 280 -c aes-ccm-random --in
# FIXME: Add partition based tests
-remove_mapping_and_reset
+remove_mapping
+reset_device_psid_nofail
exit 0