1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#include "qemu/osdep.h"
16#include <glib/gstdio.h>
17
18#include "libqos/libqtest.h"
19#include "qemu/module.h"
20#include "tpm-tests.h"
21#include "hw/acpi/tpm.h"
22
23uint64_t tpm_tis_base_addr = TPM_TIS_ADDR_BASE;
24
25typedef struct TestState {
26 char *src_tpm_path;
27 char *dst_tpm_path;
28 char *uri;
29} TestState;
30
31static void tpm_tis_swtpm_test(const void *data)
32{
33 const TestState *ts = data;
34
35 tpm_test_swtpm_test(ts->src_tpm_path, tpm_util_tis_transfer,
36 "tpm-tis", NULL);
37}
38
39static void tpm_tis_swtpm_migration_test(const void *data)
40{
41 const TestState *ts = data;
42
43 tpm_test_swtpm_migration_test(ts->src_tpm_path, ts->dst_tpm_path, ts->uri,
44 tpm_util_tis_transfer, "tpm-tis", NULL);
45}
46
47int main(int argc, char **argv)
48{
49 int ret;
50 TestState ts = { 0 };
51
52 ts.src_tpm_path = g_dir_make_tmp("qemu-tpm-tis-swtpm-test.XXXXXX", NULL);
53 ts.dst_tpm_path = g_dir_make_tmp("qemu-tpm-tis-swtpm-test.XXXXXX", NULL);
54 ts.uri = g_strdup_printf("unix:%s/migsocket", ts.src_tpm_path);
55
56 module_call_init(MODULE_INIT_QOM);
57 g_test_init(&argc, &argv, NULL);
58
59 qtest_add_data_func("/tpm/tis-swtpm/test", &ts, tpm_tis_swtpm_test);
60 qtest_add_data_func("/tpm/tis-swtpm-migration/test", &ts,
61 tpm_tis_swtpm_migration_test);
62 ret = g_test_run();
63
64 g_rmdir(ts.dst_tpm_path);
65 g_free(ts.dst_tpm_path);
66 g_rmdir(ts.src_tpm_path);
67 g_free(ts.src_tpm_path);
68 g_free(ts.uri);
69
70 return ret;
71}
72