2 * QTest testcase for TPM CRB talking to external swtpm and swtpm migration
4 * Copyright (c) 2018 IBM Corporation
5 * with parts borrowed from migration-test.c that is:
6 * Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates
9 * Stefan Berger <stefanb@linux.vnet.ibm.com>
11 * This work is licensed under the terms of the GNU GPL, version 2 or later.
12 * See the COPYING file in the top-level directory.
15 #include "qemu/osdep.h"
16 #include <glib/gstdio.h>
19 #include "qemu/module.h"
20 #include "tpm-tests.h"
21 #include "hw/acpi/tpm.h"
23 /* Not used but needed for linking */
24 uint64_t tpm_tis_base_addr
= TPM_TIS_ADDR_BASE
;
26 typedef struct TestState
{
32 static void tpm_crb_swtpm_test(const void *data
)
34 const TestState
*ts
= data
;
36 tpm_test_swtpm_test(ts
->src_tpm_path
, tpm_util_crb_transfer
,
40 static void tpm_crb_swtpm_migration_test(const void *data
)
42 const TestState
*ts
= data
;
44 tpm_test_swtpm_migration_test(ts
->src_tpm_path
, ts
->dst_tpm_path
, ts
->uri
,
45 tpm_util_crb_transfer
, "tpm-crb", NULL
);
48 int main(int argc
, char **argv
)
53 ts
.src_tpm_path
= g_dir_make_tmp("qemu-tpm-crb-swtpm-test.XXXXXX", NULL
);
54 ts
.dst_tpm_path
= g_dir_make_tmp("qemu-tpm-crb-swtpm-test.XXXXXX", NULL
);
55 ts
.uri
= g_strdup_printf("unix:%s/migsocket", ts
.src_tpm_path
);
57 module_call_init(MODULE_INIT_QOM
);
58 g_test_init(&argc
, &argv
, NULL
);
60 qtest_add_data_func("/tpm/crb-swtpm/test", &ts
, tpm_crb_swtpm_test
);
61 qtest_add_data_func("/tpm/crb-swtpm-migration/test", &ts
,
62 tpm_crb_swtpm_migration_test
);
65 g_rmdir(ts
.dst_tpm_path
);
66 g_free(ts
.dst_tpm_path
);
67 g_rmdir(ts
.src_tpm_path
);
68 g_free(ts
.src_tpm_path
);