I am not too familiar with the EVT testing here, but I remember that we had to add new events in test/py/tests/test_event_dump.py
Simon is that correct? Thanks /Ilias On Tue, 6 Oct 2026 at 18:52, Michael Haener <[email protected]> wrote: > > Enable CONFIG_TPM_AUTOSTART on sandbox and add two tests which send > EVT_LAST_STAGE_INIT: one checks that the TPM is started, the other that > the event does not fail when there is no TPM device. > > Signed-off-by: Michael Haener <[email protected]> > --- > Changes in v3: > - New patch, split out of patch 1 > > configs/sandbox_defconfig | 1 + > test/dm/tpm.c | 44 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 45 insertions(+) > > diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig > index a2708e6fb33..3efbdc6fdf1 100644 > --- a/configs/sandbox_defconfig > +++ b/configs/sandbox_defconfig > @@ -400,6 +400,7 @@ CONFIG_ECDSA=y > CONFIG_ECDSA_VERIFY=y > CONFIG_RSASSA_PSS=y > CONFIG_TPM=y > +CONFIG_TPM_AUTOSTART=y > CONFIG_ERRNO_STR=y > CONFIG_GETOPT=y > CONFIG_TEST_FDTDEC=y > diff --git a/test/dm/tpm.c b/test/dm/tpm.c > index 87c5c416daa..46e843787f1 100644 > --- a/test/dm/tpm.c > +++ b/test/dm/tpm.c > @@ -5,8 +5,11 @@ > */ > > #include <dm.h> > +#include <event.h> > #include <tpm_api.h> > +#include <dm/device-internal.h> > #include <dm/test.h> > +#include <dm/uclass-internal.h> > #include <test/test.h> > #include <test/ut.h> > > @@ -197,3 +200,44 @@ static int dm_test_tpm_autostart_reinit(struct > unit_test_state *uts) > return 0; > } > DM_TEST(dm_test_tpm_autostart_reinit, UTF_SCAN_FDT); > + > +/* Check that CONFIG_TPM_AUTOSTART starts the TPM from the init event */ > +static int dm_test_tpm_autostart_event(struct unit_test_state *uts) > +{ > + struct udevice *dev; > + char buf[50]; > + > + if (!IS_ENABLED(CONFIG_TPM_AUTOSTART)) > + return 0; > + > + ut_assertok(get_tpm_version(TPM_V2, &dev)); > + > + ut_assert(tpm_report_state(dev, buf, sizeof(buf))); > + ut_asserteq_str("init_done=0", buf); > + > + ut_assertok(event_notify_null(EVT_LAST_STAGE_INIT)); > + > + ut_assert(tpm_report_state(dev, buf, sizeof(buf))); > + ut_asserteq_str("init_done=1", buf); > + > + return 0; > +} > +DM_TEST(dm_test_tpm_autostart_event, UTF_SCAN_FDT); > + > +/* Check that a missing TPM does not make the init event fail */ > +static int dm_test_tpm_autostart_event_missing(struct unit_test_state *uts) > +{ > + struct udevice *dev; > + > + if (!IS_ENABLED(CONFIG_TPM_AUTOSTART)) > + return 0; > + > + while (!uclass_find_first_device(UCLASS_TPM, &dev) && dev) > + ut_assertok(device_unbind(dev)); > + > + ut_asserteq(-ENODEV, uclass_first_device_err(UCLASS_TPM, &dev)); > + ut_assertok(event_notify_null(EVT_LAST_STAGE_INIT)); > + > + return 0; > +} > +DM_TEST(dm_test_tpm_autostart_event_missing, UTF_SCAN_FDT); > -- > 2.55.0 >
