Skip to contentSkip to conversation

Fix / improve some unit tests

PATCH New Jan Kiszka 1 participant 4 messages May 8

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

v2 cover Fix / improve some unit tests

This is v2 for the 3rd patch in this series, properly setting up its internal --vm argument passing. The other two are a related fix and a refactoring.

Jan

Jan Kiszka (3):
testsuite/smokey/alchemytests: Fix garbage args in case no --vm option
is passed
testsuite/smokey: Use XENO_CPU_AFFINITY envvar for psostests and
vxworkstests as well
testsuite/smokey/psostests: Avoid timeouts in over virtual
environments

 testsuite/smokey/alchemytests/alchemytests.c |  3 +--
 testsuite/smokey/psostests/mq-3.c            | 10 ++++++++--
 testsuite/smokey/psostests/psostests.c       | 12 ++++++++++--
 testsuite/smokey/vxworkstests/vxworkstests.c | 10 +++++++++-
 4 files changed, 28 insertions(+), 7 deletions(-)
Signature · 1 line
2.47.3
author
#1 lore raw

PATCH v2 1/3 testsuite/smokey/alchemytests: Fix garbage args in case no --vm option is passed

From: Jan Kiszka <[email protected]>

We are no longer skipping over "--vm" here, args is only "--vm" by now.

Fixes 61fc9ff4b721 ("alchemytests: Set cpu-affinity by env var")
---
 testsuite/smokey/alchemytests/alchemytests.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
testsuite/smokey/alchemytests/alchemytests.c +1 -2
index edbafe6e71..b596a1e175 100644
@@ -52,8 +52,7 @@ static int run_alchemytests(struct smokey_test *t, int argc, char *const argv[])
 
 	for (size_t i = 0; i < ARRAY_SIZE(tests); i++) {
 		tmp = smokey_run_extprog(XENO_TEST_DIR, tests[i],
-					 smokey_on_vm ? args : args + 5,
-					 &test_ret);
+					 smokey_on_vm ? args : NULL, &test_ret);
 		if (test_ret)
 			ret = test_ret; /* Return the last failed test result */
 		if (tmp)
Signature · 1 line
2.47.3
author
#2 lore raw

PATCH v2 2/3 testsuite/smokey: Use XENO_CPU_AFFINITY envvar for psostests and vxworkstests as well

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

Aligns these two testcase sets with 61fc9ff4b721, for the same reasons.

---
 testsuite/smokey/psostests/psostests.c       | 10 +++++++++-
 testsuite/smokey/vxworkstests/vxworkstests.c | 10 +++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)
testsuite/smokey/psostests/psostests.c +9 -1
index 9d9639d441..a28ceea056 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <string.h>
+#include <stdlib.h>
 #include <smokey/smokey.h>
 
 static const char * const tests[] = {
@@ -51,9 +52,16 @@ static int run_psostests(struct smokey_test *t, int argc, char *const argv[])
 	int ret = 0;
 	int tmp;
 
+	ret = setenv("XENO_CPU_AFFINITY", "0", 0);
+	if (ret != 0) {
+		fprintf(stderr, "%s failed to set XENO_CPU_AFFINITY: %m\n",
+			__func__);
+		return ret;
+	}
+
 	for (size_t i = 0; i < ARRAY_SIZE(tests); i++) {
 		tmp = smokey_run_extprog(XENO_TEST_DIR, tests[i],
-					 "--cpu-affinity=0", &test_ret);
+					 NULL, &test_ret);
 		if (test_ret)
 			ret = test_ret; /* Return the last failed test result */
 		if (tmp)
testsuite/smokey/vxworkstests/vxworkstests.c +9 -1
index 26cd58c694..78068a4d15 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <string.h>
+#include <stdlib.h>
 #include <smokey/smokey.h>
 
 static const char * const tests[] = {
@@ -28,9 +29,16 @@ static int run_vxworkstests(struct smokey_test *t, int argc, char *const argv[])
 	int ret = 0;
 	int tmp;
 
+	ret = setenv("XENO_CPU_AFFINITY", "0", 0);
+	if (ret != 0) {
+		fprintf(stderr, "%s failed to set XENO_CPU_AFFINITY: %m\n",
+			__func__);
+		return ret;
+	}
+
 	for (size_t i = 0; i < ARRAY_SIZE(tests); i++) {
 		tmp = smokey_run_extprog(XENO_TEST_DIR, tests[i],
-					 "--cpu-affinity=0", &test_ret);
+					 NULL, &test_ret);
 		if (test_ret)
 			ret = test_ret; /* Return the last failed test result */
 		if (tmp)
Signature · 1 line
2.47.3
author
#3 lore raw

PATCH v2 3/3 testsuite/smokey/psostests: Avoid timeouts in over virtual environments

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

This was seen over QEMU:

2026-05-03T09:42:36 [2] at mq-3.c:31
2026-05-03T09:42:36    0\"071.079| BUG in __traceobj_assert_failed(): [TSKA] trace assertion failed:
2026-05-03T09:42:36               mq-3.c:32 => \"ret == 0\"
2026-05-03T09:42:36 [1] at mq-3.c:27
2026-05-03T09:42:36 test psostests_mq3 failed: 256

It's most likely that we ran into a timeout here due to QEMU not being able to deliver the messages to all receivers in time. Just wait infinitely in such cases to avoid spurious testsuite errors.

---
 testsuite/smokey/psostests/mq-3.c      | 10 ++++++++--
 testsuite/smokey/psostests/psostests.c |  4 ++--
 2 files changed, 10 insertions(+), 4 deletions(-)
testsuite/smokey/psostests/mq-3.c +8 -2
index 1171a70544..4b6f2dcf35 100644
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <copperplate/traceobj.h>
 #include <psos/psos.h>
 
@@ -12,6 +14,8 @@ static int tseq[] = {
 
 static u_long tidA, tidB, qid;
 
+static bool on_vm;
+
 static void task_A(u_long a0, u_long a1, u_long a2, u_long a3)
 {
 	u_long msgbuf[4];
@@ -27,7 +31,7 @@ static void task_A(u_long a0, u_long a1, u_long a2, u_long a3)
 	traceobj_mark(&trobj, 1);
 
 	for (n = 0; n < 3; n++) {
-		ret = q_receive(qid, Q_WAIT, 10, msgbuf);
+		ret = q_receive(qid, Q_WAIT, on_vm ? 0 : 10, msgbuf);
 		traceobj_mark(&trobj, 2);
 		traceobj_assert(&trobj, ret == SUCCESS);
 		traceobj_assert(&trobj, msgbuf[0] == n + 1);
@@ -56,7 +60,7 @@ static void task_B(u_long a0, u_long a1, u_long a2, u_long a3)
 	traceobj_mark(&trobj, 4);
 
 	for (n = 0; n < 3; n++) {
-		ret = q_receive(qid, Q_WAIT, 10, msgbuf);
+		ret = q_receive(qid, Q_WAIT, on_vm ? 0 : 10, msgbuf);
 		traceobj_mark(&trobj, 5);
 		traceobj_assert(&trobj, ret == SUCCESS);
 		traceobj_assert(&trobj, msgbuf[0] == n + 1);
@@ -75,6 +79,8 @@ int main(int argc, char *const argv[])
 	u_long args[] = { 1, 2, 3, 4 }, msgbuf[4], count;
 	int ret, n;
 
+	on_vm = argc > 1 && strcmp(argv[1], "--vm") == 0;
+
 	traceobj_init(&trobj, argv[0], sizeof(tseq) / sizeof(int));
 
 	ret = q_create("QUEUE", Q_NOLIMIT, 0, &qid);
testsuite/smokey/psostests/psostests.c +2 -2
index a28ceea056..289d563ac3 100644
@@ -48,6 +48,7 @@ static int run_psostests(struct smokey_test *t, int argc, char *const argv[])
 	smokey_note("psostests skipped. --enable-lores-clock missing.");
 	return 0;
 #else
+	const char *args = "--vm";
 	int test_ret = 0;
 	int ret = 0;
 	int tmp;
@@ -61,7 +62,7 @@ static int run_psostests(struct smokey_test *t, int argc, char *const argv[])
 
 	for (size_t i = 0; i < ARRAY_SIZE(tests); i++) {
 		tmp = smokey_run_extprog(XENO_TEST_DIR, tests[i],
-					 NULL, &test_ret);
+					 smokey_on_vm ? args : NULL, &test_ret);
 		if (test_ret)
 			ret = test_ret; /* Return the last failed test result */
 		if (tmp)
@@ -72,4 +73,3 @@ static int run_psostests(struct smokey_test *t, int argc, char *const argv[])
 #endif
 }
 smokey_test_plugin(psostests, SMOKEY_NOARGS, "Run external psostests");
-
Signature · 1 line
2.47.3