tests/qtest: migration: Add migrate_incoming_qmp helper
[qemu/armbru.git] / tests / qtest / tpm-tis-swtpm-test.c
blob105e42e21d6075e130b271b5df2fc96ce0d22083
1 /*
2 * QTest testcase for TPM TIS 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
8 * Authors:
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"
17 #include "libqtest.h"
18 #include "qemu/module.h"
19 #include "tpm-tests.h"
20 #include "tpm-tis-util.h"
21 #include "hw/acpi/tpm.h"
23 uint64_t tpm_tis_base_addr = TPM_TIS_ADDR_BASE;
25 typedef struct TestState {
26 char *src_tpm_path;
27 char *dst_tpm_path;
28 char *uri;
29 } TestState;
31 static void tpm_tis_swtpm_test(const void *data)
33 const TestState *ts = data;
35 tpm_test_swtpm_test(ts->src_tpm_path, tpm_tis_transfer,
36 "tpm-tis", NULL);
39 static void tpm_tis_swtpm_migration_test(const void *data)
41 const TestState *ts = data;
43 tpm_test_swtpm_migration_test(ts->src_tpm_path, ts->dst_tpm_path, ts->uri,
44 tpm_tis_transfer, "tpm-tis", NULL);
47 int main(int argc, char **argv)
49 int ret;
50 TestState ts = { 0 };
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);
56 module_call_init(MODULE_INIT_QOM);
57 g_test_init(&argc, &argv, NULL);
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();
64 tpm_util_rmdir(ts.dst_tpm_path);
65 g_free(ts.dst_tpm_path);
66 tpm_util_rmdir(ts.src_tpm_path);
67 g_free(ts.src_tpm_path);
68 g_free(ts.uri);
70 return ret;