Skip to content

Commit

Permalink
tests: fail early if PSID reset does not work for device.
Browse files Browse the repository at this point in the history
This should stop user from using wrong device for tests.
  • Loading branch information
mbroz committed Nov 22, 2023
1 parent 6b2cf68 commit dfbb775
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tests/compat-test-opal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit dfbb775

Please sign in to comment.