accel: Declare AccelClass::cpu_common_[un]realize() handlers
[qemu/armbru.git] / tests / qtest / tpm-tis-test.c
bloba4a25ba7452741735713aa92fb0f609ce2c1ad77
1 /*
2 * QTest testcase for ISA 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 "hw/acpi/tpm.h"
19 #include "io/channel-socket.h"
20 #include "libqtest-single.h"
21 #include "qemu/module.h"
22 #include "tpm-emu.h"
23 #include "tpm-tis-util.h"
25 uint64_t tpm_tis_base_addr = TPM_TIS_ADDR_BASE;
27 int main(int argc, char **argv)
29 int ret;
30 char *args, *tmp_path = g_dir_make_tmp("qemu-tpm-tis-test.XXXXXX", NULL);
31 GThread *thread;
32 TPMTestState test;
34 module_call_init(MODULE_INIT_QOM);
35 g_test_init(&argc, &argv, NULL);
37 test.addr = g_new0(SocketAddress, 1);
38 test.addr->type = SOCKET_ADDRESS_TYPE_UNIX;
39 test.addr->u.q_unix.path = g_build_filename(tmp_path, "sock", NULL);
40 g_mutex_init(&test.data_mutex);
41 g_cond_init(&test.data_cond);
42 test.data_cond_signal = false;
43 test.tpm_version = TPM_VERSION_2_0;
45 thread = g_thread_new(NULL, tpm_emu_ctrl_thread, &test);
46 tpm_emu_test_wait_cond(&test);
48 args = g_strdup_printf(
49 "-chardev socket,id=chr,path=%s "
50 "-tpmdev emulator,id=dev,chardev=chr "
51 "-device tpm-tis,tpmdev=dev",
52 test.addr->u.q_unix.path);
53 qtest_start(args);
55 qtest_add_data_func("/tpm-tis/test_check_localities", &test,
56 tpm_tis_test_check_localities);
58 qtest_add_data_func("/tpm-tis/test_check_access_reg", &test,
59 tpm_tis_test_check_access_reg);
61 qtest_add_data_func("/tpm-tis/test_check_access_reg_seize", &test,
62 tpm_tis_test_check_access_reg_seize);
64 qtest_add_data_func("/tpm-tis/test_check_access_reg_release", &test,
65 tpm_tis_test_check_access_reg_release);
67 qtest_add_data_func("/tpm-tis/test_check_transmit", &test,
68 tpm_tis_test_check_transmit);
70 ret = g_test_run();
72 qtest_end();
74 g_thread_join(thread);
75 g_unlink(test.addr->u.q_unix.path);
76 qapi_free_SocketAddress(test.addr);
77 g_rmdir(tmp_path);
78 g_free(tmp_path);
79 g_free(args);
80 return ret;