]> Git Repo - qemu.git/blame - tests/qtest/tpm-tis-swtpm-test.c
test: tpm: pass optional machine options to swtpm test functions
[qemu.git] / tests / qtest / tpm-tis-swtpm-test.c
CommitLineData
70663851
SB
1/*
2 * QTest testcase for TPM TIS talking to external swtpm and swtpm migration
3 *
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
7 *
8 * Authors:
9 * Stefan Berger <[email protected]>
10 *
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.
13 */
14
15#include "qemu/osdep.h"
16#include <glib/gstdio.h>
17
18#include "libqtest.h"
0b8fa32f 19#include "qemu/module.h"
70663851
SB
20#include "tpm-tests.h"
21
22typedef struct TestState {
23 char *src_tpm_path;
24 char *dst_tpm_path;
25 char *uri;
26} TestState;
27
28static void tpm_tis_swtpm_test(const void *data)
29{
30 const TestState *ts = data;
31
551cabdf
EA
32 tpm_test_swtpm_test(ts->src_tpm_path, tpm_util_tis_transfer,
33 "tpm-tis", NULL);
70663851
SB
34}
35
36static void tpm_tis_swtpm_migration_test(const void *data)
37{
38 const TestState *ts = data;
39
40 tpm_test_swtpm_migration_test(ts->src_tpm_path, ts->dst_tpm_path, ts->uri,
551cabdf 41 tpm_util_tis_transfer, "tpm-tis", NULL);
70663851
SB
42}
43
44int main(int argc, char **argv)
45{
46 int ret;
47 TestState ts = { 0 };
48
49 ts.src_tpm_path = g_dir_make_tmp("qemu-tpm-tis-swtpm-test.XXXXXX", NULL);
50 ts.dst_tpm_path = g_dir_make_tmp("qemu-tpm-tis-swtpm-test.XXXXXX", NULL);
51 ts.uri = g_strdup_printf("unix:%s/migsocket", ts.src_tpm_path);
52
53 module_call_init(MODULE_INIT_QOM);
54 g_test_init(&argc, &argv, NULL);
55
56 qtest_add_data_func("/tpm/tis-swtpm/test", &ts, tpm_tis_swtpm_test);
57 qtest_add_data_func("/tpm/tis-swtpm-migration/test", &ts,
58 tpm_tis_swtpm_migration_test);
59 ret = g_test_run();
60
61 g_rmdir(ts.dst_tpm_path);
62 g_free(ts.dst_tpm_path);
63 g_rmdir(ts.src_tpm_path);
64 g_free(ts.src_tpm_path);
65 g_free(ts.uri);
66
67 return ret;
68}
This page took 0.115612 seconds and 4 git commands to generate.