-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add swtpm migration test for the TPM TIS interface
Add a test case for testing swtpm migration with the TPM TIS interface. Signed-off-by: Stefan Berger <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]>
- Loading branch information
1 parent
ea71a33
commit 7066385
Showing
4 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* QTest testcase for TPM TIS talking to external swtpm and swtpm migration | ||
* | ||
* Copyright (c) 2018 IBM Corporation | ||
* with parts borrowed from migration-test.c that is: | ||
* Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates | ||
* | ||
* Authors: | ||
* Stefan Berger <[email protected]> | ||
* | ||
* This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
* See the COPYING file in the top-level directory. | ||
*/ | ||
|
||
#include "qemu/osdep.h" | ||
#include <glib/gstdio.h> | ||
|
||
#include "libqtest.h" | ||
#include "tpm-tests.h" | ||
|
||
typedef struct TestState { | ||
char *src_tpm_path; | ||
char *dst_tpm_path; | ||
char *uri; | ||
} TestState; | ||
|
||
static void tpm_tis_swtpm_test(const void *data) | ||
{ | ||
const TestState *ts = data; | ||
|
||
tpm_test_swtpm_test(ts->src_tpm_path, tpm_util_tis_transfer, "tpm-tis"); | ||
} | ||
|
||
static void tpm_tis_swtpm_migration_test(const void *data) | ||
{ | ||
const TestState *ts = data; | ||
|
||
tpm_test_swtpm_migration_test(ts->src_tpm_path, ts->dst_tpm_path, ts->uri, | ||
tpm_util_tis_transfer, "tpm-tis"); | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int ret; | ||
TestState ts = { 0 }; | ||
|
||
ts.src_tpm_path = g_dir_make_tmp("qemu-tpm-tis-swtpm-test.XXXXXX", NULL); | ||
ts.dst_tpm_path = g_dir_make_tmp("qemu-tpm-tis-swtpm-test.XXXXXX", NULL); | ||
ts.uri = g_strdup_printf("unix:%s/migsocket", ts.src_tpm_path); | ||
|
||
module_call_init(MODULE_INIT_QOM); | ||
g_test_init(&argc, &argv, NULL); | ||
|
||
qtest_add_data_func("/tpm/tis-swtpm/test", &ts, tpm_tis_swtpm_test); | ||
qtest_add_data_func("/tpm/tis-swtpm-migration/test", &ts, | ||
tpm_tis_swtpm_migration_test); | ||
ret = g_test_run(); | ||
|
||
g_rmdir(ts.dst_tpm_path); | ||
g_free(ts.dst_tpm_path); | ||
g_rmdir(ts.src_tpm_path); | ||
g_free(ts.src_tpm_path); | ||
g_free(ts.uri); | ||
|
||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters