linux-user: Add strace support for printing arguments of some clock and time functions
[qemu/ar7.git] / tests / qtest / tpm-tis-device-swtpm-test.c
blobf7126eff9e742098697f0d3f66668fa3b0e06be0
1 /*
2 * QTest testcase for Sysbus TPM TIS talking to external swtpm and swtpm
3 * migration
5 * Copyright (c) 2018 IBM Corporation
6 * with parts borrowed from migration-test.c that is:
7 * Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates
9 * Authors:
10 * Stefan Berger <stefanb@linux.vnet.ibm.com>
12 * This work is licensed under the terms of the GNU GPL, version 2 or later.
13 * See the COPYING file in the top-level directory.
16 #include "qemu/osdep.h"
17 #include <glib/gstdio.h>
19 #include "libqos/libqtest.h"
20 #include "qemu/module.h"
21 #include "tpm-tests.h"
22 #include "hw/acpi/tpm.h"
24 uint64_t tpm_tis_base_addr = 0xc000000;
25 #define MACHINE_OPTIONS "-machine virt,gic-version=max -accel tcg"
27 typedef struct TestState {
28 char *src_tpm_path;
29 char *dst_tpm_path;
30 char *uri;
31 } TestState;
33 static void tpm_tis_swtpm_test(const void *data)
35 const TestState *ts = data;
37 tpm_test_swtpm_test(ts->src_tpm_path, tpm_util_tis_transfer,
38 "tpm-tis-device", MACHINE_OPTIONS);
41 static void tpm_tis_swtpm_migration_test(const void *data)
43 const TestState *ts = data;
45 tpm_test_swtpm_migration_test(ts->src_tpm_path, ts->dst_tpm_path, ts->uri,
46 tpm_util_tis_transfer, "tpm-tis-device",
47 MACHINE_OPTIONS);
50 int main(int argc, char **argv)
52 int ret;
53 TestState ts = { 0 };
55 ts.src_tpm_path = g_dir_make_tmp("qemu-tpm-tis-device-swtpm-test.XXXXXX",
56 NULL);
57 ts.dst_tpm_path = g_dir_make_tmp("qemu-tpm-tis-device-swtpm-test.XXXXXX",
58 NULL);
59 ts.uri = g_strdup_printf("unix:%s/migsocket", ts.src_tpm_path);
61 module_call_init(MODULE_INIT_QOM);
62 g_test_init(&argc, &argv, NULL);
64 qtest_add_data_func("/tpm/tis-swtpm/test", &ts, tpm_tis_swtpm_test);
65 qtest_add_data_func("/tpm/tis-swtpm-migration/test", &ts,
66 tpm_tis_swtpm_migration_test);
67 ret = g_test_run();
69 g_rmdir(ts.dst_tpm_path);
70 g_free(ts.dst_tpm_path);
71 g_rmdir(ts.src_tpm_path);
72 g_free(ts.src_tpm_path);
73 g_free(ts.uri);
75 return ret;