1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
summary: smoke test for the boot-state tool
details: |
Verify the boot-state tool works properly. This tool is used to
simplify the tests when working with the different boot managers.
backends: [google, qemu]
execute: |
# Check help
"$TESTSTOOLS"/boot-state | MATCH "usage: boot-state bootenv"
"$TESTSTOOLS"/boot-state -h | MATCH "usage: boot-state bootenv"
"$TESTSTOOLS"/boot-state --help | MATCH "usage: boot-state bootenv"
echo "Check the get-boot-path command"
case "$SPREAD_SYSTEM" in
ubuntu-core-16-arm-*|ubuntu-core-18-arm-*|ubuntu-core-20-arm-*|ubuntu-core-22-arm-*)
"$TESTSTOOLS"/boot-state boot-path | MATCH "/boot/uboot/"
;;
fedora-*|opensuse-*|amazon-*|centos-*)
"$TESTSTOOLS"/boot-state boot-path | MATCH "/boot/grub2/"
;;
*)
"$TESTSTOOLS"/boot-state boot-path | MATCH "/boot/grub/"
;;
esac
# ARM devices are not supported on ubuntu-core-18/20 due to fw_printenv/setenv are
# not provided by the system and as the devices boot with uboot so it is not
# possible to get any boot information as it is done with non arm devices.
if ( os.query is-core18 || os.query is-core20 ) && os.query is-arm; then
exit
fi
echo "Check the bootenv command is able to show all the variables"
case "$SPREAD_SYSTEM" in
ubuntu-core-16-*|ubuntu-core-18-*)
# check snap_core and snap_kernel vars are set in bootnev
"$TESTSTOOLS"/boot-state bootenv show | MATCH 'snap_core=core.*.snap'
"$TESTSTOOLS"/boot-state bootenv show | MATCH 'snap_kernel=.*-kernel_.*.snap'
;;
ubuntu-core-20-*|ubuntu-core-22-*)
# check kernel_status var is set in bootnev
"$TESTSTOOLS"/boot-state bootenv show | MATCH 'kernel_status='
;;
*)
# check bootnev command can be called
"$TESTSTOOLS"/boot-state bootenv show
;;
esac
echo "Check a new variable can be set with bootenv set command"
"$TESTSTOOLS"/boot-state bootenv show | NOMATCH 'snap_test_1='
"$TESTSTOOLS"/boot-state bootenv set snap_test_1 test_1
"$TESTSTOOLS"/boot-state bootenv show | MATCH 'snap_test_1=test_1$'
echo "Check a new variable is correctly displayed with bootenv show command"
"$TESTSTOOLS"/boot-state bootenv set snap_test_2 test_2
"$TESTSTOOLS"/boot-state bootenv show snap_test_1 | MATCH 'test_1'
"$TESTSTOOLS"/boot-state bootenv show snap_test_1 | NOMATCH 'test_2'
echo "Check a variable can be set even if it is already defined in bootenv"
"$TESTSTOOLS"/boot-state bootenv set snap_test_1 test_3
"$TESTSTOOLS"/boot-state bootenv show snap_test_1 | MATCH 'test_3'
test "$("$TESTSTOOLS"/boot-state bootenv show | grep -c snap_test_1)" -eq 1
echo "Check an existing variable can be unset with bootenv unset command"
"$TESTSTOOLS"/boot-state bootenv unset snap_test_1
"$TESTSTOOLS"/boot-state bootenv show | NOMATCH 'snap_test_1='
"$TESTSTOOLS"/boot-state bootenv show | MATCH 'snap_test_2=test_2$'
"$TESTSTOOLS"/boot-state bootenv unset snap_test_2
"$TESTSTOOLS"/boot-state bootenv show | NOMATCH 'snap_test_2='
echo "Check an inexistent var can be unset in bootenv"
"$TESTSTOOLS"/boot-state bootenv unset snap_boot_no_exist
echo "Check that the wait-core-post-boot command finishes inmediatly"
"$TESTSTOOLS"/boot-state wait-core-post-boot
# TODO: Test the scenario when the core reaches the timeout running wait-core-post-boot
echo "Check bootenv shows an error message if no subcommand is used"
"$TESTSTOOLS"/boot-state bootenv 2>&1 | MATCH "boot-state: unsupported bootenv sub-command"
"$TESTSTOOLS"/boot-state bootenv noexist 2>&1 | MATCH "boot-state: unsupported bootenv sub-command noexist"
echo "Check the bootenv set command shows an error message if variable and value are missing"
"$TESTSTOOLS"/boot-state bootenv set 2>&1 | MATCH "boot-state: variable and value required to set in bootenv"
"$TESTSTOOLS"/boot-state bootenv set justvar 2>&1 | MATCH "boot-state: variable and value required to set in bootenv"
echo "Check the bootenv unset command shows an error message if a variable is missing"
"$TESTSTOOLS"/boot-state bootenv unset 2>&1 | MATCH "boot-state: variable required to unset from bootenv"
|