* [PATCH] tests/qtest/tpm: Clean up remainders of swtpm
@ 2022-10-12 8:43 Thomas Huth
2022-10-17 10:39 ` Stefan Berger
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Huth @ 2022-10-12 8:43 UTC (permalink / raw)
To: Stefan Berger, qemu-devel; +Cc: Laurent Vivier
After running "make check", there are remainders of the tpm
tests left in the /tmp directory, slowly filling it up.
Seems like "swtpm" leaves a ".lock" and a "tpm2-00.permall"
file behind, so that the g_rmdir() calls on the temporary
directories fail. Introduce a helper function to remove those
leftovers before doing the g_rmdir().
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/tpm-util.h | 1 +
tests/qtest/tpm-crb-swtpm-test.c | 5 ++---
tests/qtest/tpm-tis-device-swtpm-test.c | 5 ++---
tests/qtest/tpm-tis-swtpm-test.c | 5 ++---
tests/qtest/tpm-util.c | 19 +++++++++++++++++++
5 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/tests/qtest/tpm-util.h b/tests/qtest/tpm-util.h
index 3b97d69017..80720afac0 100644
--- a/tests/qtest/tpm-util.h
+++ b/tests/qtest/tpm-util.h
@@ -53,5 +53,6 @@ void tpm_util_migration_start_qemu(QTestState **src_qemu,
const char *machine_options);
void tpm_util_wait_for_migration_complete(QTestState *who);
+void tpm_util_rmdir(const char *path);
#endif /* TESTS_TPM_UTIL_H */
diff --git a/tests/qtest/tpm-crb-swtpm-test.c b/tests/qtest/tpm-crb-swtpm-test.c
index 55fdb5657d..40254f762f 100644
--- a/tests/qtest/tpm-crb-swtpm-test.c
+++ b/tests/qtest/tpm-crb-swtpm-test.c
@@ -13,7 +13,6 @@
*/
#include "qemu/osdep.h"
-#include <glib/gstdio.h>
#include "libqtest.h"
#include "qemu/module.h"
@@ -62,9 +61,9 @@ int main(int argc, char **argv)
tpm_crb_swtpm_migration_test);
ret = g_test_run();
- g_rmdir(ts.dst_tpm_path);
+ tpm_util_rmdir(ts.dst_tpm_path);
g_free(ts.dst_tpm_path);
- g_rmdir(ts.src_tpm_path);
+ tpm_util_rmdir(ts.src_tpm_path);
g_free(ts.src_tpm_path);
g_free(ts.uri);
diff --git a/tests/qtest/tpm-tis-device-swtpm-test.c b/tests/qtest/tpm-tis-device-swtpm-test.c
index 7b20035142..8c067fddd4 100644
--- a/tests/qtest/tpm-tis-device-swtpm-test.c
+++ b/tests/qtest/tpm-tis-device-swtpm-test.c
@@ -14,7 +14,6 @@
*/
#include "qemu/osdep.h"
-#include <glib/gstdio.h>
#include "libqtest.h"
#include "qemu/module.h"
@@ -66,9 +65,9 @@ int main(int argc, char **argv)
tpm_tis_swtpm_migration_test);
ret = g_test_run();
- g_rmdir(ts.dst_tpm_path);
+ tpm_util_rmdir(ts.dst_tpm_path);
g_free(ts.dst_tpm_path);
- g_rmdir(ts.src_tpm_path);
+ tpm_util_rmdir(ts.src_tpm_path);
g_free(ts.src_tpm_path);
g_free(ts.uri);
diff --git a/tests/qtest/tpm-tis-swtpm-test.c b/tests/qtest/tpm-tis-swtpm-test.c
index 90131cb3c4..11539c0a52 100644
--- a/tests/qtest/tpm-tis-swtpm-test.c
+++ b/tests/qtest/tpm-tis-swtpm-test.c
@@ -13,7 +13,6 @@
*/
#include "qemu/osdep.h"
-#include <glib/gstdio.h>
#include "libqtest.h"
#include "qemu/module.h"
@@ -61,9 +60,9 @@ int main(int argc, char **argv)
tpm_tis_swtpm_migration_test);
ret = g_test_run();
- g_rmdir(ts.dst_tpm_path);
+ tpm_util_rmdir(ts.dst_tpm_path);
g_free(ts.dst_tpm_path);
- g_rmdir(ts.src_tpm_path);
+ tpm_util_rmdir(ts.src_tpm_path);
g_free(ts.src_tpm_path);
g_free(ts.uri);
diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c
index e0dc5da0af..a7efe2d0d2 100644
--- a/tests/qtest/tpm-util.c
+++ b/tests/qtest/tpm-util.c
@@ -13,6 +13,7 @@
*/
#include "qemu/osdep.h"
+#include <glib/gstdio.h>
#include "hw/acpi/tpm.h"
#include "libqtest.h"
@@ -292,3 +293,21 @@ void tpm_util_migration_start_qemu(QTestState **src_qemu,
g_free(src_qemu_args);
g_free(dst_qemu_args);
}
+
+/* Remove directory with remainders of swtpm */
+void tpm_util_rmdir(const char *path)
+{
+ char *filename;
+ int ret;
+
+ filename = g_strdup_printf("%s/tpm2-00.permall", path);
+ g_unlink(filename);
+ g_free(filename);
+
+ filename = g_strdup_printf("%s/.lock", path);
+ g_unlink(filename);
+ g_free(filename);
+
+ ret = g_rmdir(path);
+ g_assert(!ret);
+}
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tests/qtest/tpm: Clean up remainders of swtpm
2022-10-12 8:43 [PATCH] tests/qtest/tpm: Clean up remainders of swtpm Thomas Huth
@ 2022-10-17 10:39 ` Stefan Berger
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Berger @ 2022-10-17 10:39 UTC (permalink / raw)
To: Thomas Huth, Stefan Berger, qemu-devel; +Cc: Laurent Vivier
On 10/12/22 04:43, Thomas Huth wrote:
> After running "make check", there are remainders of the tpm
> tests left in the /tmp directory, slowly filling it up.
> Seems like "swtpm" leaves a ".lock" and a "tpm2-00.permall"
> file behind, so that the g_rmdir() calls on the temporary
> directories fail. Introduce a helper function to remove those
> leftovers before doing the g_rmdir().
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
> ---
> tests/qtest/tpm-util.h | 1 +
> tests/qtest/tpm-crb-swtpm-test.c | 5 ++---
> tests/qtest/tpm-tis-device-swtpm-test.c | 5 ++---
> tests/qtest/tpm-tis-swtpm-test.c | 5 ++---
> tests/qtest/tpm-util.c | 19 +++++++++++++++++++
> 5 files changed, 26 insertions(+), 9 deletions(-)
>
> diff --git a/tests/qtest/tpm-util.h b/tests/qtest/tpm-util.h
> index 3b97d69017..80720afac0 100644
> --- a/tests/qtest/tpm-util.h
> +++ b/tests/qtest/tpm-util.h
> @@ -53,5 +53,6 @@ void tpm_util_migration_start_qemu(QTestState **src_qemu,
> const char *machine_options);
>
> void tpm_util_wait_for_migration_complete(QTestState *who);
> +void tpm_util_rmdir(const char *path);
>
> #endif /* TESTS_TPM_UTIL_H */
> diff --git a/tests/qtest/tpm-crb-swtpm-test.c b/tests/qtest/tpm-crb-swtpm-test.c
> index 55fdb5657d..40254f762f 100644
> --- a/tests/qtest/tpm-crb-swtpm-test.c
> +++ b/tests/qtest/tpm-crb-swtpm-test.c
> @@ -13,7 +13,6 @@
> */
>
> #include "qemu/osdep.h"
> -#include <glib/gstdio.h>
>
> #include "libqtest.h"
> #include "qemu/module.h"
> @@ -62,9 +61,9 @@ int main(int argc, char **argv)
> tpm_crb_swtpm_migration_test);
> ret = g_test_run();
>
> - g_rmdir(ts.dst_tpm_path);
> + tpm_util_rmdir(ts.dst_tpm_path);
> g_free(ts.dst_tpm_path);
> - g_rmdir(ts.src_tpm_path);
> + tpm_util_rmdir(ts.src_tpm_path);
> g_free(ts.src_tpm_path);
> g_free(ts.uri);
>
> diff --git a/tests/qtest/tpm-tis-device-swtpm-test.c b/tests/qtest/tpm-tis-device-swtpm-test.c
> index 7b20035142..8c067fddd4 100644
> --- a/tests/qtest/tpm-tis-device-swtpm-test.c
> +++ b/tests/qtest/tpm-tis-device-swtpm-test.c
> @@ -14,7 +14,6 @@
> */
>
> #include "qemu/osdep.h"
> -#include <glib/gstdio.h>
>
> #include "libqtest.h"
> #include "qemu/module.h"
> @@ -66,9 +65,9 @@ int main(int argc, char **argv)
> tpm_tis_swtpm_migration_test);
> ret = g_test_run();
>
> - g_rmdir(ts.dst_tpm_path);
> + tpm_util_rmdir(ts.dst_tpm_path);
> g_free(ts.dst_tpm_path);
> - g_rmdir(ts.src_tpm_path);
> + tpm_util_rmdir(ts.src_tpm_path);
> g_free(ts.src_tpm_path);
> g_free(ts.uri);
>
> diff --git a/tests/qtest/tpm-tis-swtpm-test.c b/tests/qtest/tpm-tis-swtpm-test.c
> index 90131cb3c4..11539c0a52 100644
> --- a/tests/qtest/tpm-tis-swtpm-test.c
> +++ b/tests/qtest/tpm-tis-swtpm-test.c
> @@ -13,7 +13,6 @@
> */
>
> #include "qemu/osdep.h"
> -#include <glib/gstdio.h>
>
> #include "libqtest.h"
> #include "qemu/module.h"
> @@ -61,9 +60,9 @@ int main(int argc, char **argv)
> tpm_tis_swtpm_migration_test);
> ret = g_test_run();
>
> - g_rmdir(ts.dst_tpm_path);
> + tpm_util_rmdir(ts.dst_tpm_path);
> g_free(ts.dst_tpm_path);
> - g_rmdir(ts.src_tpm_path);
> + tpm_util_rmdir(ts.src_tpm_path);
> g_free(ts.src_tpm_path);
> g_free(ts.uri);
>
> diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c
> index e0dc5da0af..a7efe2d0d2 100644
> --- a/tests/qtest/tpm-util.c
> +++ b/tests/qtest/tpm-util.c
> @@ -13,6 +13,7 @@
> */
>
> #include "qemu/osdep.h"
> +#include <glib/gstdio.h>
>
> #include "hw/acpi/tpm.h"
> #include "libqtest.h"
> @@ -292,3 +293,21 @@ void tpm_util_migration_start_qemu(QTestState **src_qemu,
> g_free(src_qemu_args);
> g_free(dst_qemu_args);
> }
> +
> +/* Remove directory with remainders of swtpm */
> +void tpm_util_rmdir(const char *path)
> +{
> + char *filename;
> + int ret;
> +
> + filename = g_strdup_printf("%s/tpm2-00.permall", path);
> + g_unlink(filename);
> + g_free(filename);
> +
> + filename = g_strdup_printf("%s/.lock", path);
> + g_unlink(filename);
> + g_free(filename);
> +
> + ret = g_rmdir(path);
> + g_assert(!ret);
> +}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-17 10:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-12 8:43 [PATCH] tests/qtest/tpm: Clean up remainders of swtpm Thomas Huth
2022-10-17 10:39 ` Stefan Berger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).