diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/common/test_autoboot.c | 6 | ||||
-rw-r--r-- | test/dm/of_platdata.c | 7 | ||||
-rw-r--r-- | test/py/tests/test_tpm2.py | 18 |
3 files changed, 27 insertions, 4 deletions
diff --git a/test/common/test_autoboot.c b/test/common/test_autoboot.c index 6564ac7049..42a1e4ab1f 100644 --- a/test/common/test_autoboot.c +++ b/test/common/test_autoboot.c @@ -16,13 +16,19 @@ static int check_for_input(struct unit_test_state *uts, const char *in, bool correct) { + bool old_val; /* The bootdelay is set to 1 second in test_autoboot() */ const char *autoboot_prompt = "Enter password \"a\" in 1 seconds to stop autoboot"; console_record_reset_enable(); console_in_puts(in); + + /* turn on keyed autoboot for the test, if possible */ + old_val = autoboot_set_keyed(true); autoboot_command("echo Autoboot password unlock not successful"); + old_val = autoboot_set_keyed(old_val); + ut_assert_nextline(autoboot_prompt); if (!correct) ut_assert_nextline("Autoboot password unlock not successful"); diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c index 0f89c7a7da..0463cf0b43 100644 --- a/test/dm/of_platdata.c +++ b/test/dm/of_platdata.c @@ -35,12 +35,13 @@ static int dm_test_of_plat_props(struct unit_test_state *uts) plat = dev_get_plat(dev); ut_assert(plat->boolval); ut_asserteq(1, plat->intval); - ut_asserteq(4, ARRAY_SIZE(plat->intarray)); + ut_asserteq(3, ARRAY_SIZE(plat->intarray)); ut_asserteq(2, plat->intarray[0]); ut_asserteq(3, plat->intarray[1]); ut_asserteq(4, plat->intarray[2]); - ut_asserteq(0, plat->intarray[3]); ut_asserteq(5, plat->byteval); + ut_asserteq(1, ARRAY_SIZE(plat->maybe_empty_int)); + ut_asserteq(0, plat->maybe_empty_int[0]); ut_asserteq(3, ARRAY_SIZE(plat->bytearray)); ut_asserteq(6, plat->bytearray[0]); ut_asserteq(0, plat->bytearray[1]); @@ -61,7 +62,6 @@ static int dm_test_of_plat_props(struct unit_test_state *uts) ut_asserteq(5, plat->intarray[0]); ut_asserteq(0, plat->intarray[1]); ut_asserteq(0, plat->intarray[2]); - ut_asserteq(0, plat->intarray[3]); ut_asserteq(8, plat->byteval); ut_asserteq(3, ARRAY_SIZE(plat->bytearray)); ut_asserteq(1, plat->bytearray[0]); @@ -80,6 +80,7 @@ static int dm_test_of_plat_props(struct unit_test_state *uts) ut_asserteq_str("one", plat->stringarray[0]); ut_asserteq_str("", plat->stringarray[1]); ut_asserteq_str("", plat->stringarray[2]); + ut_asserteq(1, plat->maybe_empty_int[0]); ut_assertok(uclass_next_device_err(&dev)); plat = dev_get_plat(dev); diff --git a/test/py/tests/test_tpm2.py b/test/py/tests/test_tpm2.py index 70f906da51..ac04f7191e 100644 --- a/test/py/tests/test_tpm2.py +++ b/test/py/tests/test_tpm2.py @@ -216,7 +216,9 @@ def test_tpm2_pcr_extend(u_boot_console): output = u_boot_console.run_command('echo $?') assert output.endswith('0') - read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % ram) + # Read the value back into a different place so we can still use 'ram' as + # our zero bytes + read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % (ram + 0x20)) output = u_boot_console.run_command('echo $?') assert output.endswith('0') assert 'f5 a5 fd 42 d1 6a 20 30 27 98 ef 6e d3 09 97 9b' in read_pcr @@ -226,6 +228,20 @@ def test_tpm2_pcr_extend(u_boot_console): new_updates = int(re.findall(r'\d+', str)[0]) assert (updates + 1) == new_updates + u_boot_console.run_command('tpm2 pcr_extend 0 0x%x' % ram) + output = u_boot_console.run_command('echo $?') + assert output.endswith('0') + + read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % (ram + 0x20)) + output = u_boot_console.run_command('echo $?') + assert output.endswith('0') + assert '7a 05 01 f5 95 7b df 9c b3 a8 ff 49 66 f0 22 65' in read_pcr + assert 'f9 68 65 8b 7a 9c 62 64 2c ba 11 65 e8 66 42 f5' in read_pcr + + str = re.findall(r'\d+ known updates', read_pcr)[0] + new_updates = int(re.findall(r'\d+', str)[0]) + assert (updates + 2) == new_updates + @pytest.mark.buildconfigspec('cmd_tpm_v2') def test_tpm2_cleanup(u_boot_console): """Ensure the TPM is cleared from password or test related configuration.""" |