2 * QTest testcase for ISA TPM TIS
4 * Copyright (c) 2018 Red Hat, Inc.
5 * Copyright (c) 2018 IBM Corporation
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"
23 #include "tpm-tis-util.h"
25 uint64_t tpm_tis_base_addr
= TPM_TIS_ADDR_BASE
;
27 int main(int argc
, char **argv
)
30 char *args
, *tmp_path
= g_dir_make_tmp("qemu-tpm-tis-test.XXXXXX", NULL
);
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;
44 thread
= g_thread_new(NULL
, tpm_emu_ctrl_thread
, &test
);
45 tpm_emu_test_wait_cond(&test
);
47 args
= g_strdup_printf(
48 "-chardev socket,id=chr,path=%s "
49 "-tpmdev emulator,id=dev,chardev=chr "
50 "-device tpm-tis,tpmdev=dev",
51 test
.addr
->u
.q_unix
.path
);
54 qtest_add_data_func("/tpm-tis/test_check_localities", &test
,
55 tpm_tis_test_check_localities
);
57 qtest_add_data_func("/tpm-tis/test_check_access_reg", &test
,
58 tpm_tis_test_check_access_reg
);
60 qtest_add_data_func("/tpm-tis/test_check_access_reg_seize", &test
,
61 tpm_tis_test_check_access_reg_seize
);
63 qtest_add_data_func("/tpm-tis/test_check_access_reg_release", &test
,
64 tpm_tis_test_check_access_reg_release
);
66 qtest_add_data_func("/tpm-tis/test_check_transmit", &test
,
67 tpm_tis_test_check_transmit
);
73 g_thread_join(thread
);
74 g_unlink(test
.addr
->u
.q_unix
.path
);
75 qapi_free_SocketAddress(test
.addr
);