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
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 "tpm-tests.h"
21 typedef struct TestState
{
27 static void tpm_tis_swtpm_test(const void *data
)
29 const TestState
*ts
= data
;
31 tpm_test_swtpm_test(ts
->src_tpm_path
, tpm_util_tis_transfer
, "tpm-tis");
34 static void tpm_tis_swtpm_migration_test(const void *data
)
36 const TestState
*ts
= data
;
38 tpm_test_swtpm_migration_test(ts
->src_tpm_path
, ts
->dst_tpm_path
, ts
->uri
,
39 tpm_util_tis_transfer
, "tpm-tis");
42 int main(int argc
, char **argv
)
47 ts
.src_tpm_path
= g_dir_make_tmp("qemu-tpm-tis-swtpm-test.XXXXXX", NULL
);
48 ts
.dst_tpm_path
= g_dir_make_tmp("qemu-tpm-tis-swtpm-test.XXXXXX", NULL
);
49 ts
.uri
= g_strdup_printf("unix:%s/migsocket", ts
.src_tpm_path
);
51 module_call_init(MODULE_INIT_QOM
);
52 g_test_init(&argc
, &argv
, NULL
);
54 qtest_add_data_func("/tpm/tis-swtpm/test", &ts
, tpm_tis_swtpm_test
);
55 qtest_add_data_func("/tpm/tis-swtpm-migration/test", &ts
,
56 tpm_tis_swtpm_migration_test
);
59 g_rmdir(ts
.dst_tpm_path
);
60 g_free(ts
.dst_tpm_path
);
61 g_rmdir(ts
.src_tpm_path
);
62 g_free(ts
.src_tpm_path
);