KVM: remove support for kernel-irqchip=off
[qemu.git] / tests / qtest / tpm-tis-device-test.c
blob3ddefb51ecf1dd10175296669b2b12c934a1281a
1 /*
2 * QTest testcase for SYSBUS TPM TIS
4 * Copyright (c) 2018 Red Hat, Inc.
5 * Copyright (c) 2018 IBM Corporation
7 * Authors:
8 * Marc-André Lureau <marcandre.lureau@redhat.com>
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>
18 #include "io/channel-socket.h"
19 #include "libqtest-single.h"
20 #include "qemu/module.h"
21 #include "tpm-emu.h"
22 #include "tpm-util.h"
23 #include "tpm-tis-util.h"
26 * As the Sysbus tpm-tis-device is instantiated on the ARM virt
27 * platform bus and it is the only sysbus device dynamically
28 * instantiated, it gets plugged at its base address
30 uint64_t tpm_tis_base_addr = 0xc000000;
32 int main(int argc, char **argv)
34 char *tmp_path = g_dir_make_tmp("qemu-tpm-tis-device-test.XXXXXX", NULL);
35 GThread *thread;
36 TPMTestState test;
37 char *args;
38 int ret;
40 module_call_init(MODULE_INIT_QOM);
41 g_test_init(&argc, &argv, NULL);
43 test.addr = g_new0(SocketAddress, 1);
44 test.addr->type = SOCKET_ADDRESS_TYPE_UNIX;
45 test.addr->u.q_unix.path = g_build_filename(tmp_path, "sock", NULL);
46 g_mutex_init(&test.data_mutex);
47 g_cond_init(&test.data_cond);
48 test.data_cond_signal = false;
49 test.tpm_version = TPM_VERSION_2_0;
51 thread = g_thread_new(NULL, tpm_emu_ctrl_thread, &test);
52 tpm_emu_test_wait_cond(&test);
54 args = g_strdup_printf(
55 "-machine virt,gic-version=max -accel tcg "
56 "-chardev socket,id=chr,path=%s "
57 "-tpmdev emulator,id=dev,chardev=chr "
58 "-device tpm-tis-device,tpmdev=dev",
59 test.addr->u.q_unix.path);
60 qtest_start(args);
62 qtest_add_data_func("/tpm-tis/test_check_localities", &test,
63 tpm_tis_test_check_localities);
65 qtest_add_data_func("/tpm-tis/test_check_access_reg", &test,
66 tpm_tis_test_check_access_reg);
68 qtest_add_data_func("/tpm-tis/test_check_access_reg_seize", &test,
69 tpm_tis_test_check_access_reg_seize);
71 qtest_add_data_func("/tpm-tis/test_check_access_reg_release", &test,
72 tpm_tis_test_check_access_reg_release);
74 qtest_add_data_func("/tpm-tis/test_check_transmit", &test,
75 tpm_tis_test_check_transmit);
77 ret = g_test_run();
79 qtest_end();
81 g_thread_join(thread);
82 g_unlink(test.addr->u.q_unix.path);
83 qapi_free_SocketAddress(test.addr);
84 g_rmdir(tmp_path);
85 g_free(tmp_path);
86 g_free(args);
87 return ret;