tests: Add test cases for TPM 1.2 ACPI tables
v3 cover tests: Add test cases for TPM 1.2 ACPI tables
This series of patches adds test case for TPM 1.2 ACPI tables.
Stefan
v3:
- Define enum TPMVersion for when CONFIG_TPM is not defined affected patches 2 and 6
v2:
- Proper handling of renaming of files holding expected ACPI data
Stefan Berger (9):
tests: Rename TestState to TPMTestState
tests: Add tpm_version field to TPMTestState and fill it
tests: acpi: Prepare for renaming of TPM2 related ACPI files
tests: Add suffix 'tpm2' or 'tpm12' to ACPI table files
tests: acpi: tpm2: Add the renamed ACPI files and drop old ones
tests: tpm: Create TPM 1.2 response in TPM emulator
tests: acpi: prepare for new TPM 1.2 related tables
tests: acpi: Add test cases for TPM 1.2 with TCPA table
tests: acpi: tpm1.2: Add expected TPM 1.2 ACPI blobs
tests/data/acpi/q35/DSDT.tis.tpm12 | Bin 0 -> 8465 bytes
.../data/acpi/q35/{DSDT.tis => DSDT.tis.tpm2} | Bin
tests/data/acpi/q35/TCPA.tis.tpm12 | Bin 0 -> 50 bytes
.../data/acpi/q35/{TPM2.tis => TPM2.tis.tpm2} | Bin
tests/qtest/bios-tables-test.c | 20 ++++++++++-----
tests/qtest/tpm-crb-test.c | 5 ++--
tests/qtest/tpm-emu.c | 24 +++++++++++++-----
tests/qtest/tpm-emu.h | 18 ++++++++++---
tests/qtest/tpm-tis-device-test.c | 3 ++-
tests/qtest/tpm-tis-test.c | 3 ++-
tests/qtest/tpm-tis-util.c | 2 +-
11 files changed, 55 insertions(+), 20 deletions(-)
create mode 100644 tests/data/acpi/q35/DSDT.tis.tpm12
rename tests/data/acpi/q35/{DSDT.tis => DSDT.tis.tpm2} (100%)
create mode 100644 tests/data/acpi/q35/TCPA.tis.tpm12
rename tests/data/acpi/q35/{TPM2.tis => TPM2.tis.tpm2} (100%)Signature · 1 line
2.31.1
PATCH v3 1/9 tests: Rename TestState to TPMTestState
--- tests/qtest/bios-tables-test.c | 2 +- tests/qtest/tpm-crb-test.c | 4 ++-- tests/qtest/tpm-emu.c | 6 +++--- tests/qtest/tpm-emu.h | 6 +++--- tests/qtest/tpm-tis-device-test.c | 2 +- tests/qtest/tpm-tis-test.c | 2 +- tests/qtest/tpm-tis-util.c | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-)
tests/qtest/bios-tables-test.c +1 -1
@@ -1098,7 +1098,7 @@ static void test_acpi_tcg_tpm(const char *machine, const char *tpm_if,gchar *tmp_dir_name =g_strdup_printf ("qemu-test_acpi_%s_tcg_%s.XXXXXX" , machine, tpm_if);char *tmp_path =g_dir_make_tmp (tmp_dir_name,NULL ); -TestState test; +TPMTestState test;test_data data;GThread *thread;char *args, *variant =g_strdup_printf (".%s" , tpm_if);
tests/qtest/tpm-crb-test.c +2 -2
@@ -26,7 +26,7 @@ uint64_t tpm_tis_base_addr = TPM_TIS_ADDR_BASE;static void tpm_crb_test (const void *data) { -const TestState *s = data; +const TPMTestState *s = data;uint32_t intfid =readl (TPM_CRB_ADDR_BASE +A_CRB_INTF_ID );uint32_t csize =readl (TPM_CRB_ADDR_BASE +A_CRB_CTRL_CMD_SIZE );uint64_t caddr =readq (TPM_CRB_ADDR_BASE +A_CRB_CTRL_CMD_LADDR );
@@ -145,7 +145,7 @@ int main(int argc, char **argv)int ret;char *args, *tmp_path =g_dir_make_tmp ("qemu-tpm-crb-test.XXXXXX" ,NULL );GThread *thread; -TestState test; +TPMTestState test;module_call_init (MODULE_INIT_QOM );g_test_init (&argc, &argv,NULL );
tests/qtest/tpm-emu.c +3 -3
@@ -18,7 +18,7 @@#include "qapi/error.h" #include "tpm-emu.h" -void tpm_emu_test_wait_cond (TestState *s) +void tpm_emu_test_wait_cond (TPMTestState *s) {gint64 end_time =g_get_monotonic_time () +5 *G_TIME_SPAN_SECOND ;
@@ -36,7 +36,7 @@ void tpm_emu_test_wait_cond(TestState *s)static void *tpm_emu_tpm_thread (void *data) { -TestState *s = data; +TPMTestState *s = data;QIOChannel *ioc = s->tpm_ioc; s->tpm_msg = g_new(struct tpm_hdr, 1);
@@ -71,7 +71,7 @@ static void *tpm_emu_tpm_thread(void *data)void *tpm_emu_ctrl_thread (void *data) { -TestState *s = data; +TPMTestState *s = data;QIOChannelSocket *lioc =qio_channel_socket_new ();QIOChannel *ioc;
tests/qtest/tpm-emu.h +3 -3
@@ -26,7 +26,7 @@ struct tpm_hdr {char buffer[]; }QEMU_PACKED ; -typedef struct TestState { +typedef struct TPMTestState { GMutex data_mutex; GCond data_cond; bool data_cond_signal;
@@ -34,9 +34,9 @@ typedef struct TestState {QIOChannel *tpm_ioc;GThread *emu_tpm_thread; struct tpm_hdr *tpm_msg; -} TestState; +} TPMTestState; -void tpm_emu_test_wait_cond (TestState *s); +void tpm_emu_test_wait_cond (TPMTestState *s);void *tpm_emu_ctrl_thread (void *data);#endif /* TESTS_TPM_EMU_H */
tests/qtest/tpm-tis-device-test.c +1 -1
@@ -33,7 +33,7 @@ int main(int argc, char **argv) {char *tmp_path =g_dir_make_tmp ("qemu-tpm-tis-device-test.XXXXXX" ,NULL );GThread *thread; -TestState test; +TPMTestState test;char *args;int ret;
tests/qtest/tpm-tis-test.c +1 -1
@@ -29,7 +29,7 @@ int main(int argc, char **argv)int ret;char *args, *tmp_path =g_dir_make_tmp ("qemu-tpm-tis-test.XXXXXX" ,NULL );GThread *thread; -TestState test; +TPMTestState test;module_call_init (MODULE_INIT_QOM );g_test_init (&argc, &argv,NULL );
tests/qtest/tpm-tis-util.c +1 -1
@@ -373,7 +373,7 @@ void tpm_tis_test_check_access_reg_release(const void *data)*/ void tpm_tis_test_check_transmit (const void *data) { -const TestState *s = data; +const TPMTestState *s = data;uint8_t access;uint32_t sts;uint16_t bcount;
Signature · 1 line
2.31.1
PATCH v3 2/9 tests: Add tpm_version field to TPMTestState and fill it
In reply to Stefan Berger---
v3:
- Added enum TPMVersion for when CONFIG_TPM is not defined
--- tests/qtest/bios-tables-test.c | 5 +++-- tests/qtest/tpm-crb-test.c | 1 + tests/qtest/tpm-emu.c | 13 ++++++++++--- tests/qtest/tpm-emu.h | 8 ++++++++ tests/qtest/tpm-tis-device-test.c | 1 + tests/qtest/tpm-tis-test.c | 1 + 6 files changed, 24 insertions(+), 5 deletions(-)
tests/qtest/bios-tables-test.c +3 -2
@@ -1092,7 +1092,7 @@ static void test_acpi_piix4_tcg_numamem(void)uint64_t tpm_tis_base_addr;static void test_acpi_tcg_tpm (const char *machine,const char *tpm_if, -uint64_t base) +uint64_t base,enum TPMVersion tpm_version) {#ifdef CONFIG_TPM gchar *tmp_dir_name = g_strdup_printf("qemu-test_acpi_%s_tcg_%s.XXXXXX",
@@ -1113,6 +1113,7 @@ static void test_acpi_tcg_tpm(const char *machine, const char *tpm_if,g_mutex_init (&test.data_mutex);g_cond_init (&test.data_cond); test.data_cond_signal = false; + test.tpm_version = tpm_version; thread =g_thread_new (NULL , tpm_emu_ctrl_thread, &test);tpm_emu_test_wait_cond (&test);
@@ -1145,7 +1146,7 @@ static void test_acpi_tcg_tpm(const char *machine, const char *tpm_if,static void test_acpi_q35_tcg_tpm_tis (void ) { -test_acpi_tcg_tpm ("q35" ,"tis" ,0xFED40000 ); +test_acpi_tcg_tpm ("q35" ,"tis" ,0xFED40000 ,TPM_VERSION_2_0 ); }static void test_acpi_tcg_dimm_pxm (const char *machine)
tests/qtest/tpm-crb-test.c +1 -0
@@ -156,6 +156,7 @@ int main(int argc, char **argv)g_mutex_init (&test.data_mutex);g_cond_init (&test.data_cond); test.data_cond_signal = false; + test.tpm_version =TPM_VERSION_2_0 ; thread =g_thread_new (NULL , tpm_emu_ctrl_thread, &test);tpm_emu_test_wait_cond (&test);
tests/qtest/tpm-emu.c +10 -3
@@ -56,9 +56,16 @@ static void *tpm_emu_tpm_thread(void *data) s->tpm_msg->code =be32_to_cpu (s->tpm_msg->code);/* reply error */ - s->tpm_msg->tag =cpu_to_be16 (TPM2_ST_NO_SESSIONS ); - s->tpm_msg->len =cpu_to_be32 (sizeof (struct tpm_hdr )); - s->tpm_msg->code =cpu_to_be32 (TPM_RC_FAILURE ); +switch (s->tpm_version) { +case TPM_VERSION_2_0 : + s->tpm_msg->tag =cpu_to_be16 (TPM2_ST_NO_SESSIONS ); + s->tpm_msg->len =cpu_to_be32 (sizeof (struct tpm_hdr )); + s->tpm_msg->code =cpu_to_be32 (TPM_RC_FAILURE ); +break ; +default : +g_debug ("unsupport TPM version %u" , s->tpm_version); +g_assert_not_reached (); + }qio_channel_write (ioc, (char *)s->tpm_msg,be32_to_cpu (s->tpm_msg->len), &error_abort); }
tests/qtest/tpm-emu.h +8 -0
@@ -18,6 +18,7 @@#include "qemu/sockets.h" #include "io/channel.h" +#include "sysemu/tpm.h" struct tpm_hdr {uint16_t tag;
@@ -26,6 +27,12 @@ struct tpm_hdr {char buffer[]; }QEMU_PACKED ; +#ifndef CONFIG_TPM +enum TPMVersion { +TPM_VERSION_2_0 =2 , +}; +#endif + typedef struct TPMTestState { GMutex data_mutex; GCond data_cond;
@@ -34,6 +41,7 @@ typedef struct TPMTestState {QIOChannel *tpm_ioc;GThread *emu_tpm_thread;struct tpm_hdr *tpm_msg; +enum TPMVersion tpm_version; } TPMTestState;void tpm_emu_test_wait_cond (TPMTestState *s);
tests/qtest/tpm-tis-device-test.c +1 -0
@@ -46,6 +46,7 @@ int main(int argc, char **argv)g_mutex_init (&test.data_mutex);g_cond_init (&test.data_cond); test.data_cond_signal = false; + test.tpm_version =TPM_VERSION_2_0 ; thread =g_thread_new (NULL , tpm_emu_ctrl_thread, &test);tpm_emu_test_wait_cond (&test);
tests/qtest/tpm-tis-test.c +1 -0
@@ -40,6 +40,7 @@ int main(int argc, char **argv)g_mutex_init (&test.data_mutex);g_cond_init (&test.data_cond); test.data_cond_signal = false; + test.tpm_version =TPM_VERSION_2_0 ; thread =g_thread_new (NULL , tpm_emu_ctrl_thread, &test);tpm_emu_test_wait_cond (&test);
Signature · 1 line
2.31.1
PATCH v3 3/9 tests: acpi: Prepare for renaming of TPM2 related ACPI files
In reply to Stefan Berger--- tests/data/acpi/q35/DSDT.tis.tpm2 | 0 tests/data/acpi/q35/TPM2.tis.tpm2 | 0 tests/qtest/bios-tables-test-allowed-diff.h | 2 ++ 3 files changed, 2 insertions(+) create mode 100644 tests/data/acpi/q35/DSDT.tis.tpm2 create mode 100644 tests/data/acpi/q35/TPM2.tis.tpm2
tests/data/acpi/q35/DSDT.tis.tpm2 new file +0 -0
tests/data/acpi/q35/TPM2.tis.tpm2 new file +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +2 -0
@@ -1 +1,3 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DSDT.tis.tpm2" , +"tests/data/acpi/q35/TPM2.tis.tpm2",
Signature · 1 line
2.31.1
PATCH v3 4/9 tests: Add suffix 'tpm2' or 'tpm12' to ACPI table files
In reply to Stefan Berger--- tests/qtest/bios-tables-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/qtest/bios-tables-test.c +2 -1
@@ -1101,7 +1101,8 @@ static void test_acpi_tcg_tpm(const char *machine, const char *tpm_if,TPMTestState test;test_data data;GThread *thread; -char *args, *variant =g_strdup_printf (".%s" , tpm_if); +const char *suffix = tpm_version ==TPM_VERSION_2_0 ?"tpm2" :"tpm12" ; +char *args, *variant =g_strdup_printf (".%s.%s" , tpm_if, suffix); tpm_tis_base_addr = base;
Signature · 1 line
2.31.1
PATCH v3 5/9 tests: acpi: tpm2: Add the renamed ACPI files and drop old ones
In reply to Stefan Berger--- tests/data/acpi/q35/DSDT.tis | Bin 8465 -> 0 bytes tests/data/acpi/q35/DSDT.tis.tpm2 | Bin 0 -> 8465 bytes tests/data/acpi/q35/TPM2.tis | Bin 76 -> 0 bytes tests/data/acpi/q35/TPM2.tis.tpm2 | Bin 0 -> 76 bytes tests/qtest/bios-tables-test-allowed-diff.h | 2 -- 5 files changed, 2 deletions(-) delete mode 100644 tests/data/acpi/q35/DSDT.tis delete mode 100644 tests/data/acpi/q35/TPM2.tis
tests/data/acpi/q35/DSDT.tis deleted binary +0 -0
tests/data/acpi/q35/DSDT.tis.tpm2 binary +0 -0
tests/data/acpi/q35/TPM2.tis deleted binary +0 -0
tests/data/acpi/q35/TPM2.tis.tpm2 binary +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +0 -2
@@ -1,3 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/DSDT.tis.tpm2" , -"tests/data/acpi/q35/TPM2.tis.tpm2",
Signature · 1 line
2.31.1
PATCH v3 6/9 tests: tpm: Create TPM 1.2 response in TPM emulator
In reply to Stefan Berger---
v3:
- Added TPM_VERSION_1_2 enum for when CONFIG_TPM is not defined
--- tests/qtest/tpm-emu.c | 5 +++++ tests/qtest/tpm-emu.h | 4 ++++ 2 files changed, 9 insertions(+)
tests/qtest/tpm-emu.c +5 -0
@@ -62,6 +62,11 @@ static void *tpm_emu_tpm_thread(void *data) s->tpm_msg->len =cpu_to_be32 (sizeof (struct tpm_hdr )); s->tpm_msg->code =cpu_to_be32 (TPM_RC_FAILURE );break ; +case TPM_VERSION_1_2 : + s->tpm_msg->tag =cpu_to_be16 (TPM_TAG_RSP_COMMAND ); + s->tpm_msg->len =cpu_to_be32 (sizeof (struct tpm_hdr )); + s->tpm_msg->code =cpu_to_be32 (TPM_FAIL ); +break ;default :g_debug ("unsupport TPM version %u" , s->tpm_version);g_assert_not_reached ();
tests/qtest/tpm-emu.h +4 -0
@@ -16,6 +16,9 @@#define TPM_RC_FAILURE 0x101#define TPM2_ST_NO_SESSIONS 0x8001 +#define TPM_FAIL 9 +#define TPM_TAG_RSP_COMMAND 0xc4 +#include "qemu/sockets.h" #include "io/channel.h" #include "sysemu/tpm.h"
@@ -29,6 +32,7 @@ struct tpm_hdr {#ifndef CONFIG_TPM enum TPMVersion { +TPM_VERSION_1_2 =1 ,TPM_VERSION_2_0 =2 , };#endif
Signature · 1 line
2.31.1
PATCH v3 7/9 tests: acpi: prepare for new TPM 1.2 related tables
In reply to Stefan Berger--- tests/data/acpi/q35/DSDT.tis.tpm12 | 0 tests/data/acpi/q35/TCPA.tis.tpm12 | 0 tests/qtest/bios-tables-test-allowed-diff.h | 2 ++ 3 files changed, 2 insertions(+) create mode 100644 tests/data/acpi/q35/DSDT.tis.tpm12 create mode 100644 tests/data/acpi/q35/TCPA.tis.tpm12
tests/data/acpi/q35/DSDT.tis.tpm12 new file +0 -0
tests/data/acpi/q35/TCPA.tis.tpm12 new file +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +2 -0
@@ -1 +1,3 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DSDT.tis.tpm12" , +"tests/data/acpi/q35/TCPA.tis.tpm12",
Signature · 1 line
2.31.1
PATCH v3 8/9 tests: acpi: Add test cases for TPM 1.2 with TCPA table
In reply to Stefan Berger--- tests/qtest/bios-tables-test.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
tests/qtest/bios-tables-test.c +8 -2
@@ -1145,11 +1145,16 @@ static void test_acpi_tcg_tpm(const char *machine, const char *tpm_if,#endif } -static void test_acpi_q35_tcg_tpm_tis (void ) +static void test_acpi_q35_tcg_tpm2_tis (void ) {test_acpi_tcg_tpm ("q35" ,"tis" ,0xFED40000 ,TPM_VERSION_2_0 ); } +static void test_acpi_q35_tcg_tpm12_tis (void ) +{ +test_acpi_tcg_tpm ("q35" ,"tis" ,0xFED40000 ,TPM_VERSION_1_2 ); +} +static void test_acpi_tcg_dimm_pxm (const char *machine) {test_data data;
@@ -1518,7 +1523,8 @@ int main(int argc, char *argv[])return ret; }qtest_add_func ("acpi/q35/oem-fields" , test_acpi_oem_fields_q35); -qtest_add_func ("acpi/q35/tpm-tis" , test_acpi_q35_tcg_tpm_tis); +qtest_add_func ("acpi/q35/tpm2-tis" , test_acpi_q35_tcg_tpm2_tis); +qtest_add_func ("acpi/q35/tpm12-tis" , test_acpi_q35_tcg_tpm12_tis);qtest_add_func ("acpi/piix4" , test_acpi_piix4_tcg);qtest_add_func ("acpi/oem-fields" , test_acpi_oem_fields_pc);qtest_add_func ("acpi/piix4/bridge" , test_acpi_piix4_tcg_bridge);
Signature · 1 line
2.31.1
PATCH v3 9/9 tests: acpi: tpm1.2: Add expected TPM 1.2 ACPI blobs
In reply to Stefan BergerThe TCPA.tis.tpm12 file contains the following:
[000h 0000 4] Signature : "TCPA" [Trusted Computing Platform Alliance table] [004h 0004 4] Table Length : 00000032 [008h 0008 1] Revision : 02 [009h 0009 1] Checksum : 32 [00Ah 0010 6] Oem ID : "BOCHS " [010h 0016 8] Oem Table ID : "BXPC " [018h 0024 4] Oem Revision : 00000001 [01Ch 0028 4] Asl Compiler ID : "BXPC" [020h 0032 4] Asl Compiler Revision : 00000001
[024h 0036 2] Platform Class : 0000 [026h 0038 4] Min Event Log Length : 00010000 [02Ah 0042 8] Event Log Address : 0000000007FF0000
--- tests/data/acpi/q35/DSDT.tis.tpm12 | Bin 0 -> 8465 bytes tests/data/acpi/q35/TCPA.tis.tpm12 | Bin 0 -> 50 bytes tests/qtest/bios-tables-test-allowed-diff.h | 2 -- 3 files changed, 2 deletions(-)
tests/data/acpi/q35/DSDT.tis.tpm12 binary +0 -0
tests/data/acpi/q35/TCPA.tis.tpm12 binary +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +0 -2
@@ -1,3 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/DSDT.tis.tpm12" , -"tests/data/acpi/q35/TCPA.tis.tpm12",
Signature · 1 line
2.31.1
Hi Stefan,
Quoted 7 lines · Stefan Berger
This series of patches adds test case for TPM 1.2 ACPI tables.
Stefan
v3:
- Define enum TPMVersion for whenCONFIG_TPMis not defined affected patches 2 and 6
I think in 11fb99e6f48..e542b71805d we missed an extra patch for qtests. Probably (untested):
-- >8 --
tests/qtest/meson.build +0 -0
@@ -60,10 +60,14 @@ (config_all_devices.has_key('CONFIG_USB_UHCI') and \ config_all_devices.has_key('CONFIG_USB_EHCI') ?
['usb-hcd-ehci-test'] : []) + \
(config_all_devices.has_key('CONFIG_USB_XHCI_NEC') ?
['usb-hcd-xhci-test'] : []) + \
- (config_all_devices.has_key('CONFIG_TPM_CRB') ? ['tpm-crb-test'] :
[]) + \
- (config_all_devices.has_key('CONFIG_TPM_CRB') ?
['tpm-crb-swtpm-test'] : []) + \
- (config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ? ['tpm-tis-test']
: []) + \
- (config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ?
['tpm-tis-swtpm-test'] : []) + \
+ (config_host.has_key('CONFIG_TPM') and \
+ config_all_devices.has_key('CONFIG_TPM_CRB') ? ['tpm-crb-test'] :
[]) + \
+ (config_host.has_key('CONFIG_TPM') and \
+ config_all_devices.has_key('CONFIG_TPM_CRB') ?
['tpm-crb-swtpm-test'] : []) + \
+ (config_host.has_key('CONFIG_TPM') and \
+ config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ? ['tpm-tis-test']
: []) + \
+ (config_host.has_key('CONFIG_TPM') and \
+ config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ?
['tpm-tis-swtpm-test'] : []) + \
(config_all_devices.has_key('CONFIG_RTL8139_PCI') ? ['rtl8139-test']
: []) + \
(config_all_devices.has_key('CONFIG_E1000E_PCI_EXPRESS') ?
['fuzz-e1000e-test'] : []) + \
(config_all_devices.has_key('CONFIG_ESP_PCI') ? ['am53c974-test'] :
[]) + \
---
Cc'ing Paolo/Thomas because there surely exists a clever way to do it...
Quoted 5 lines · Philippe Mathieu-Daudé
Hi Stefan,
Quoted 2 lines · Stefan Berger
This series of patches adds test case for TPM 1.2 ACPI tables.
Quoted 7 lines
Quoted 5 lines
Stefan
v3:
- Define enum TPMVersion for whenCONFIG_TPMis not defined affected patches 2 and 6I think in
11fb99e6f48..e542b71805dwe missed an extra patch for qtests. Probably (untested):
Shouldn't we have seen test compilation errors already?
I didn't go down this route for the build system (as you show below) because in this series we are testing ACPI tables and I introduce the reference to enum TPMVersion here, which wasn't needed before. The alternative may be to go into 8/9 and eliminate all TPM code if CONFIG_TPM is not set. The introduction of the enum now passes the tests with --enable-tpm and --disable-tpm.
Otherwise the BIOS test are skipped due to this here:
static void test_acpi_tcg_tpm(const char *machine, const char *tpm_if, uint64_t base, enum TPMVersion tpm_version) {
#ifdef CONFIG_TPM
[...]
#else
g_test_skip("TPM disabled");
#endif
}
So I didn't want to clutter this code with more #ifdef CONFIG_TPM but maybe that would be the right solution.
Stefan
Quoted 43 lines
-- >8 --
tests/qtest/meson.build +0
-3@@ -60,10 +60,14 @@ (config_all_devices.has_key('CONFIG_USB_UHCI') and \ config_all_devices.has_key('CONFIG_USB_EHCI') ? ['usb-hcd-ehci-test'] : []) + \ (config_all_devices.has_key('CONFIG_USB_XHCI_NEC') ? ['usb-hcd-xhci-test'] : []) + \ - (config_all_devices.has_key('CONFIG_TPM_CRB') ? ['tpm-crb-test'] : []) + \ - (config_all_devices.has_key('CONFIG_TPM_CRB') ? ['tpm-crb-swtpm-test'] : []) + \ - (config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ? ['tpm-tis-test']: []) + \
- (config_all_devices.has_key('CONFIG_TPM_TIS_ISA')?
['tpm-tis-swtpm-test'] : []) + \tests/qtest/meson.build +2
-0+ (config_host.has_key('CONFIG_TPM') and \ + config_all_devices.has_key('CONFIG_TPM_CRB') ? ['tpm-crb-test'] :[]) + \
tests/qtest/meson.build +2
-0+ (config_host.has_key('CONFIG_TPM') and \ + config_all_devices.has_key('CONFIG_TPM_CRB') ?['tpm-crb-swtpm-test'] : []) + \
tests/qtest/meson.build +2
-0+ (config_host.has_key('CONFIG_TPM') and \ + config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ? ['tpm-tis-test']: []) + \
tests/qtest/meson.build +2
-0+ (config_host.has_key('CONFIG_TPM') and \ + config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ?['tpm-tis-swtpm-test'] : []) + \ (config_all_devices.has_key('CONFIG_RTL8139_PCI') ? ['rtl8139-test'] : []) + \ (config_all_devices.has_key('CONFIG_E1000E_PCI_EXPRESS') ? ['fuzz-e1000e-test'] : []) + \ (config_all_devices.has_key('CONFIG_ESP_PCI') ? ['am53c974-test'] :[]) + \
---Cc'ing Paolo/Thomas because there surely exists a clever way to do it...
+Markus
Quoted 33 lines · Stefan Berger
Quoted 5 lines · Philippe Mathieu-Daudé
Hi Stefan,
Quoted 2 lines · Stefan Berger
This series of patches adds test case for TPM 1.2 ACPI tables.
Quoted 7 lines
Quoted 5 lines
Stefan
v3:
- Define enum TPMVersion for whenCONFIG_TPMis not defined affected patches 2 and 6I think in
11fb99e6f48..e542b71805dwe missed an extra patch for qtests. Probably (untested):Shouldn't we have seen test compilation errors already?
I didn't go down this route for the build system (as you show below) because in this series we are testing ACPI tables and I introduce the reference to enum TPMVersion here, which wasn't needed before. The alternative may be to go into 8/9 and eliminate all TPM code if
CONFIG_TPMis not set. The introduction of the enum now passes the tests with --enable-tpm and --disable-tpm.Otherwise the BIOS test are skipped due to this here:
static void
test_acpi_tcg_tpm(const char *machine, const char *tpm_if, uint64_t base, enum TPMVersion tpm_version){
#ifdefCONFIG_TPM
[...]
Quoted 7 lines
#else
g_test_skip("TPM disabled");
#endif
}So I didn't want to clutter this code with more #ifdef
CONFIG_TPMbut maybe that would be the right solution.
IMO the "right" solution is to check via QMP if TMP is supported or not. This is now doable since commit caff255a546 ("tpm: Return QMP error when TPM is disabled in build").
Long term we'd like to decouple the tests/ build from the various QEMU configurations, and build the tests once.
Quoted 43 lines
Quoted 42 lines
-- >8 --
tests/qtest/meson.build +0
-0@@ -60,10 +60,14 @@(
config_all_devices.has_key('CONFIG_USB_UHCI')and
\
config_all_devices.has_key('CONFIG_USB_EHCI')? ['usb-hcd-ehci-test'] : []) + \
(config_all_devices.has_key('CONFIG_USB_XHCI_NEC')? ['usb-hcd-xhci-test'] : []) + \
- (config_all_devices.has_key('CONFIG_TPM_CRB')? ['tpm-crb-test'] :
[]) + \
- (config_all_devices.has_key('CONFIG_TPM_CRB')? ['tpm-crb-swtpm-test'] : []) + \
- (config_all_devices.has_key('CONFIG_TPM_TIS_ISA')? ['tpm-tis-test'] : []) + \
- (config_all_devices.has_key('CONFIG_TPM_TIS_ISA')? ['tpm-tis-swtpm-test'] : []) + \
+ (config_host.has_key('CONFIG_TPM')and \
+config_all_devices.has_key('CONFIG_TPM_CRB')? ['tpm-crb-test'] :
[]) + \
+ (config_host.has_key('CONFIG_TPM')and \
+config_all_devices.has_key('CONFIG_TPM_CRB')? ['tpm-crb-swtpm-test'] : []) + \
+ (config_host.has_key('CONFIG_TPM')and \
+config_all_devices.has_key('CONFIG_TPM_TIS_ISA')? ['tpm-tis-test'] : []) + \
+ (config_host.has_key('CONFIG_TPM')and \
+config_all_devices.has_key('CONFIG_TPM_TIS_ISA')? ['tpm-tis-swtpm-test'] : []) + \
(config_all_devices.has_key('CONFIG_RTL8139_PCI')? ['rtl8139-test'] : []) + \
(config_all_devices.has_key('CONFIG_E1000E_PCI_EXPRESS')? ['fuzz-e1000e-test'] : []) + \
(config_all_devices.has_key('CONFIG_ESP_PCI')? ['am53c974-test'] :
[]) + \
---Cc'ing Paolo/Thomas because there surely exists a clever way to do it...
Quoted 39 lines · Philippe Mathieu-Daudé
+Markus
Quoted 36 lines · Stefan Berger
Quoted 5 lines · Philippe Mathieu-Daudé
Hi Stefan,
Quoted 2 lines · Stefan Berger
This series of patches adds test case for TPM 1.2 ACPI tables.
Quoted 7 lines
Quoted 5 lines
Stefan
v3:
- Define enum TPMVersion for whenCONFIG_TPMis not defined affected patches 2 and 6I think in
11fb99e6f48..e542b71805dwe missed an extra patch for qtests. Probably (untested):Shouldn't we have seen test compilation errors already?
I didn't go down this route for the build system (as you show below) because in this series we are testing ACPI tables and I introduce the reference to enum TPMVersion here, which wasn't needed before. The alternative may be to go into 8/9 and eliminate all TPM code if
CONFIG_TPMis not set. The introduction of the enum now passes the tests with --enable-tpm and --disable-tpm.Otherwise the BIOS test are skipped due to this here:
static void test_acpi_tcg_tpm(const char *machine, const char
*tpm_if,
uint64_tbase, enum TPMVersiontpm_version)
{
#ifdefCONFIG_TPM
[...]#else
g_test_skip("TPM disabled");
#endif
}
Quoted 5 lines
Quoted 2 lines
So I didn't want to clutter this code with more #ifdef
CONFIG_TPMbut maybe that would be the right solution.IMO the "right" solution is to check via QMP if TMP is supported or not. This is now doable since commit
caff255a546("tpm: Return QMP error when TPM is disabled in build").
That above g_test_skip() could be moved to the top of the function and be preceded by a QMP check for whether TPM is supported.
Quoted 44 lines · Philippe Mathieu-Daudé
+Markus
Quoted 33 lines · Stefan Berger
Quoted 5 lines · Philippe Mathieu-Daudé
Hi Stefan,
Quoted 2 lines · Stefan Berger
This series of patches adds test case for TPM 1.2 ACPI tables.
Quoted 7 lines
Quoted 5 lines
Stefan
v3:
- Define enum TPMVersion for whenCONFIG_TPMis not defined affected patches 2 and 6I think in
11fb99e6f48..e542b71805dwe missed an extra patch for qtests. Probably (untested):Shouldn't we have seen test compilation errors already?
I didn't go down this route for the build system (as you show below) because in this series we are testing ACPI tables and I introduce the reference to enum TPMVersion here, which wasn't needed before. The alternative may be to go into 8/9 and eliminate all TPM code if
CONFIG_TPMis not set. The introduction of the enum now passes the tests with --enable-tpm and --disable-tpm.Otherwise the BIOS test are skipped due to this here:
static void
test_acpi_tcg_tpm(const char *machine, const char *tpm_if, uint64_t base, enum TPMVersion tpm_version){
#ifdefCONFIG_TPM
[...]Quoted 7 lines
#else
g_test_skip("TPM disabled");
#endif
}So I didn't want to clutter this code with more #ifdef
CONFIG_TPMbut maybe that would be the right solution.
Quoted 6 lines
IMO the "right" solution is to check via QMP if TMP is supported or not. This is now doable since commit
caff255a546("tpm: Return QMP error when TPM is disabled in build").Long term we'd like to decouple the tests/ build from the various QEMU configurations, and build the tests once.
This argument applies only to macros from target-specific headers like $TARGET-config-target.h, not to macros from config-host.h. #ifdef CONFIG_TPM should be fine, shouldn't it?
Quoted 50 lines · Markus Armbruster
Quoted 48 lines · Philippe Mathieu-Daudé
+Markus
Quoted 33 lines · Stefan Berger
Quoted 5 lines · Philippe Mathieu-Daudé
Hi Stefan,
Quoted 2 lines · Stefan Berger
This series of patches adds test case for TPM 1.2 ACPI tables.
Quoted 7 lines
Quoted 5 lines
Stefan
v3:
- Define enum TPMVersion for whenCONFIG_TPMis not defined affected patches 2 and 6I think in
11fb99e6f48..e542b71805dwe missed an extra patch for qtests. Probably (untested):Shouldn't we have seen test compilation errors already?
I didn't go down this route for the build system (as you show below) because in this series we are testing ACPI tables and I introduce the reference to enum TPMVersion here, which wasn't needed before. The alternative may be to go into 8/9 and eliminate all TPM code if
CONFIG_TPMis not set. The introduction of the enum now passes the tests with --enable-tpm and --disable-tpm.Otherwise the BIOS test are skipped due to this here:
static void
test_acpi_tcg_tpm(const char *machine, const char *tpm_if, uint64_t base, enum TPMVersion tpm_version){
#ifdefCONFIG_TPM
[...]Quoted 7 lines
#else
g_test_skip("TPM disabled");
#endif
}So I didn't want to clutter this code with more #ifdef
CONFIG_TPMbut maybe that would be the right solution.IMO the "right" solution is to check via QMP if TMP is supported or not. This is now doable since commit
caff255a546("tpm: Return QMP error when TPM is disabled in build").
Quoted 6 lines
Quoted 2 lines
Long term we'd like to decouple the tests/ build from the various QEMU configurations, and build the tests once.
This argument applies only to macros from target-specific headers like $TARGET-config-target.h, not to macros from
config-host.h. #ifdefCONFIG_TPMshould be fine, shouldn't it?
Some definitions depend on the host (OS, libraries installed, ...), others depend on the --enable/--disable ./configure options.
IMO it would be nice if we could get qtests independent of the latter.
I suppose config-host.h holds both kinds.
Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Markus Armbruster
Quoted 1 line · Philippe Mathieu-Daudé
+Markus
[...]
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
IMO the "right" solution is to check via QMP if TMP is supported or not. This is now doable since commit
caff255a546("tpm: Return QMP error when TPM is disabled in build").Long term we'd like to decouple the tests/ build from the various QEMU configurations, and build the tests once.
Quoted 8 lines
Quoted 3 lines
This argument applies only to macros from target-specific headers like $TARGET-config-target.h, not to macros from
config-host.h. #ifdefCONFIG_TPMshould be fine, shouldn't it?Some definitions depend on the host (OS, libraries installed, ...), others depend on the --enable/--disable ./configure options.
IMO it would be nice if we could get qtests independent of the latter.
Why?
Quoted 1 line
I suppose
config-host.hholds both kinds.
Yes.
Quoted 20 lines · On Thu, 15 Jul 2021 07:49:13 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Markus Armbruster
Quoted 1 line · Philippe Mathieu-Daudé
+Markus
[...]
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
IMO the "right" solution is to check via QMP if TMP is supported or not. This is now doable since commit
caff255a546("tpm: Return QMP error when TPM is disabled in build").Long term we'd like to decouple the tests/ build from the various QEMU configurations, and build the tests once.
This argument applies only to macros from target-specific headers like $TARGET-config-target.h, not to macros from
config-host.h. #ifdefCONFIG_TPMshould be fine, shouldn't it?
Quoted 6 lines
Quoted 4 lines
Some definitions depend on the host (OS, libraries installed, ...), others depend on the --enable/--disable ./configure options.
IMO it would be nice if we could get qtests independent of the latter.
Why?
In another mail-thread Philippe mentioned that there is desire to use qtest out of tree to test other QEMU binaries.
However, just probing for features at runtime aren't going to help with the goal as tests are tailored for the latest CLI/QMP/ABI. To make it work we would have practically introduce versioned tests.
So I wonder why one external acceptance-tests suite is not sufficient, that we would want to hijack relatively simple internal qtest at expense of increased resources needed to run/write unit tests.
Quoted 5 lines
Quoted 1 line
I suppose
config-host.hholds both kinds.Yes.
Quoted 38 lines · Igor Mammedov
Quoted 20 lines · On Thu, 15 Jul 2021 07:49:13 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Markus Armbruster
Quoted 1 line · Philippe Mathieu-Daudé
+Markus
[...]
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
IMO the "right" solution is to check via QMP if TMP is supported or not. This is now doable since commit
caff255a546("tpm: Return QMP error when TPM is disabled in build").Long term we'd like to decouple the tests/ build from the various QEMU configurations, and build the tests once.
This argument applies only to macros from target-specific headers like $TARGET-config-target.h, not to macros from
config-host.h. #ifdefCONFIG_TPMshould be fine, shouldn't it?Quoted 6 lines
Quoted 4 lines
Some definitions depend on the host (OS, libraries installed, ...), others depend on the --enable/--disable ./configure options.
IMO it would be nice if we could get qtests independent of the latter.
Why?
In another mail-thread Philippe mentioned that there is desire to use qtest out of tree to test other QEMU binaries.
However, just probing for features at runtime aren't going to help with the goal as tests are tailored for the latest CLI/QMP/ABI. To make it work we would have practically introduce versioned tests.
Quoted 4 lines
So I wonder why one external acceptance-tests suite is not sufficient, that we would want to hijack relatively simple internal qtest at expense of increased resources needed to run/write unit tests.
Yes. qtest was not designed for use with anything but HEAD, and I doubt we can make it fit such uses at reasonable expense.
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
I suppose
config-host.hholds both kinds.Yes.
Quoted 31 lines · Markus Armbruster
Quoted 30 lines · Igor Mammedov
Quoted 13 lines · On Thu, 15 Jul 2021 07:49:13 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 10 lines
Quoted 6 lines
IMO the "right" solution is to check via QMP if TMP is supported or not. This is now doable since commit
caff255a546("tpm: Return QMP error when TPM is disabled in build").Long term we'd like to decouple the tests/ build from the various QEMU configurations, and build the tests once.
This argument applies only to macros from target-specific headers like $TARGET-config-target.h, not to macros from
config-host.h. #ifdefCONFIG_TPMshould be fine, shouldn't it?Quoted 6 lines
Quoted 4 lines
Some definitions depend on the host (OS, libraries installed, ...), others depend on the --enable/--disable ./configure options.
IMO it would be nice if we could get qtests independent of the latter.
Why?
In another mail-thread Philippe mentioned that there is desire to use qtest out of tree to test other QEMU binaries.
However, just probing for features at runtime aren't going to help with the goal as tests are tailored for the latest CLI/QMP/ABI. To make it work we would have practically introduce versioned tests.
Quoted 7 lines
Quoted 4 lines
So I wonder why one external acceptance-tests suite is not sufficient, that we would want to hijack relatively simple internal qtest at expense of increased resources needed to run/write unit tests.
Yes. qtest was not designed for use with anything but HEAD, and I doubt we can make it fit such uses at reasonable expense.
One HEAD but multiple configurations...
If you want to simplify human time, can we simply run qtests once per arch/OS but with all features enabled? Otherwise skip qtests?
Quoted 37 lines · On Mon, 19 Jul 2021 15:56:16 +0200 Philippe Mathieu-Daudé <[email protected]>…
Quoted 36 lines · Markus Armbruster
Quoted 34 lines · Igor Mammedov
Quoted 13 lines · On Thu, 15 Jul 2021 07:49:13 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 10 lines
Quoted 6 lines
IMO the "right" solution is to check via QMP if TMP is supported or not. This is now doable since commit
caff255a546("tpm: Return QMP error when TPM is disabled in build").Long term we'd like to decouple the tests/ build from the various QEMU configurations, and build the tests once.
This argument applies only to macros from target-specific headers like $TARGET-config-target.h, not to macros from
config-host.h. #ifdefCONFIG_TPMshould be fine, shouldn't it?Quoted 6 lines
Quoted 4 lines
Some definitions depend on the host (OS, libraries installed, ...), others depend on the --enable/--disable ./configure options.
IMO it would be nice if we could get qtests independent of the latter.
Why?
In another mail-thread Philippe mentioned that there is desire to use qtest out of tree to test other QEMU binaries.
However, just probing for features at runtime aren't going to help with the goal as tests are tailored for the latest CLI/QMP/ABI. To make it work we would have practically introduce versioned tests.
So I wonder why one external acceptance-tests suite is not sufficient, that we would want to hijack relatively simple internal qtest at expense of increased resources needed to run/write unit tests.
Quoted 4 lines
Quoted 2 lines
Yes. qtest was not designed for use with anything but HEAD, and I doubt we can make it fit such uses at reasonable expense.
One HEAD but multiple configurations...
Even assuming reconfigure won't cause world rebuild,
It will be a win only if number of configuration probes
is small.
However it doesn't scale for large numbers and it might be
faster to rebuild affected tests in the end. (worst case: #probes * #targets) I wonder if we can do probing once & cache it somewhere to avoid ^^^.
Quoted 3 lines
If you want to simplify human time, can we simply run qtests once per
arch/OSbut with all features enabled? Otherwise skip qtests?
Quoted 43 lines · Igor Mammedov
Quoted 40 lines · On Mon, 19 Jul 2021 15:56:16 +0200 Philippe Mathieu-Daudé <[email protected]>…
Quoted 38 lines · Markus Armbruster
Quoted 30 lines · Igor Mammedov
Quoted 13 lines · On Thu, 15 Jul 2021 07:49:13 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 10 lines
Quoted 6 lines
IMO the "right" solution is to check via QMP if TMP is supported or not. This is now doable since commit
caff255a546("tpm: Return QMP error when TPM is disabled in build").Long term we'd like to decouple the tests/ build from the various QEMU configurations, and build the tests once.
This argument applies only to macros from target-specific headers like $TARGET-config-target.h, not to macros from
config-host.h. #ifdefCONFIG_TPMshould be fine, shouldn't it?Quoted 6 lines
Quoted 4 lines
Some definitions depend on the host (OS, libraries installed, ...), others depend on the --enable/--disable ./configure options.
IMO it would be nice if we could get qtests independent of the latter.
Why?
In another mail-thread Philippe mentioned that there is desire to use qtest out of tree to test other QEMU binaries.
However, just probing for features at runtime aren't going to help with the goal as tests are tailored for the latest CLI/QMP/ABI. To make it work we would have practically introduce versioned tests.
Quoted 4 lines
So I wonder why one external acceptance-tests suite is not sufficient, that we would want to hijack relatively simple internal qtest at expense of increased resources needed to run/write unit tests.
Yes. qtest was not designed for use with anything but HEAD, and I doubt we can make it fit such uses at reasonable expense.
Quoted 8 lines
Quoted 1 line
One HEAD but multiple configurations...
Even assuming reconfigure won't cause world rebuild,
It will be a win only if number of configuration probes
is small.
However it doesn't scale for large numbers and it might be
faster to rebuild affected tests in the end. (worst case: #probes * #targets) I wonder if we can do probing once & cache it somewhere to avoid ^^^.
As far as I can tell, the time to compile these tests is dwarved several times over by the time to run them. In other words, most of the waste to optimize out hides in the test programs, not in compiling them.
Quoted 2 lines
Quoted 2 lines
If you want to simplify human time, can we simply run qtests once per
arch/OSbut with all features enabled? Otherwise skip qtests?
How build configuration and tests interact is poorly understood. We instead use brute force: run all the tests for all configurations, always. To do better without sacrificing coverage, we need to understand better. Sadly, I don't see that happening.