tests/commandtest: skip the test4 and test18 if the testcase is run in the container env

Signed-off-by: AlexChen <alex.chen@huawei.com>
This commit is contained in:
AlexChen 2020-09-16 19:11:13 +08:00 committed by Fei Xu
parent 10700c86e8
commit c6f0aa1103
2 changed files with 77 additions and 1 deletions

View File

@ -0,0 +1,73 @@
From df5d95b8db5ec8a79dee223338a72a9f8897a538 Mon Sep 17 00:00:00 2001
From: AlexChen <alex.chen@huawei.com>
Date: Wed, 16 Sep 2020 15:53:57 +0800
Subject: [PATCH] tests/commandtest: skip the test4 if the testcase is run in
the container env
In a container environment without an init thread, the daemoned
process is not reclaimed, and Test4 loops forever, causing
the compilation to hung. So, skip it.
Signed-off-by: AlexChen <alex.chen@huawei.com>
---
tests/commandtest.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/tests/commandtest.c b/tests/commandtest.c
index d5092b7dd0..2cc27c64a1 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -259,6 +259,7 @@ static int test4(const void *unused G_GNUC_UNUSED)
char *pidfile = virPidFileBuildPath(abs_builddir, "commandhelper");
pid_t pid;
int ret = -1;
+ int count = 0;
if (!pidfile)
goto cleanup;
@@ -275,9 +276,14 @@ static int test4(const void *unused G_GNUC_UNUSED)
printf("cannot read pidfile\n");
goto cleanup;
}
- while (kill(pid, 0) != -1)
- g_usleep(100*1000);
-
+ while (kill(pid, 0) != -1) {
+ if (count++ >= 600) {
+ printf("check time exceeds 60s, it may be in container env, "
+ "skip this testcase!!!\n");
+ break;
+ }
+ g_usleep(100*1000); /* 100ms */
+ }
ret = checkoutput("test4", NULL);
cleanup:
@@ -734,6 +740,7 @@ static int test18(const void *unused G_GNUC_UNUSED)
char *pidfile = virPidFileBuildPath(abs_builddir, "commandhelper");
pid_t pid;
int ret = -1;
+ int count = 0;
if (!pidfile)
goto cleanup;
@@ -760,8 +767,14 @@ static int test18(const void *unused G_GNUC_UNUSED)
goto cleanup;
}
- while (kill(pid, SIGINT) != -1)
- g_usleep(100*1000);
+ while (kill(pid, SIGINT) != -1) {
+ if (count++ >= 600) {
+ printf("check time exceeds 60s, it may be in container env, "
+ "skip this testcase!!!\n");
+ break;
+ }
+ g_usleep(100*1000); /* 100ms */
+ }
ret = 0;
--
2.23.0

View File

@ -99,7 +99,7 @@
Summary: Library providing a simple virtualization API Summary: Library providing a simple virtualization API
Name: libvirt Name: libvirt
Version: 6.2.0 Version: 6.2.0
Release: 8 Release: 9
License: LGPLv2+ License: LGPLv2+
URL: https://libvirt.org/ URL: https://libvirt.org/
@ -132,6 +132,7 @@ Patch0021: libvirt-Substitute-security_context_t-with-char.patch
Patch0022: libvirt-conf-Don-t-format-http-cookies-unless-VIR_DOMAIN_DEF.patch Patch0022: libvirt-conf-Don-t-format-http-cookies-unless-VIR_DOMAIN_DEF.patch
Patch0023: libvirt-virstoragetest-testBackingParse-Use-VIR_DOMAIN_DEF_F.patch Patch0023: libvirt-virstoragetest-testBackingParse-Use-VIR_DOMAIN_DEF_F.patch
Patch0024: libvirt-support-aarch64-vtpm-with-parameter-tpm-tis-.patch Patch0024: libvirt-support-aarch64-vtpm-with-parameter-tpm-tis-.patch
Patch0025: libvirt-tests-commandtest-skip-the-test4-if-the-testcase-is-.patch
Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon = %{version}-%{release}
Requires: libvirt-daemon-config-network = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release}
@ -1864,6 +1865,8 @@ exit 0
%changelog %changelog
* Wed Aug 5 2020 AlexChen <alex.chen@huawei.com> - 6.2.0-9
- tests: skip the test4 if the testcase is run in the container env
* Wed Aug 5 2020 Jiang Fangjie <jiangfangjie@huawei.com> - 6.2.0-8 * Wed Aug 5 2020 Jiang Fangjie <jiangfangjie@huawei.com> - 6.2.0-8
- Libvirt supports aarch64 vtpm with parameter tpm-tis-device - Libvirt supports aarch64 vtpm with parameter tpm-tis-device
* Tue Aug 4 2020 Xu Yandong <xuyandong2@huawei.com> - 6.2.0-7 * Tue Aug 4 2020 Xu Yandong <xuyandong2@huawei.com> - 6.2.0-7