summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-22 16:06:35 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-22 16:17:55 -0600
commit8d3991d6cca1a57ef5c48460313a07f709c89248 (patch)
tree0e2eabd84834c086364bdb707c1254fe71bfa072
parent2774e918b6ced670f80036532052189d568e5c5c (diff)
Enable running tests in parallel
-rw-r--r--GNUmakefile5
-rwxr-xr-xlib9p/tests/runtest5
-rw-r--r--lib9p/tests/test_server/main.c9
3 files changed, 14 insertions, 5 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 1311b6e..bae7357 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -74,6 +74,9 @@ generate-clean:
platforms := rp2040 host # $(shell sed -nE 's/if *\(PICO_PLATFORM STREQUAL "(.*)"\)/\1/p' cmd/*/CMakeLists.txt)
build_types = Debug Release RelWithDebInfo MinSizeRel
+export CTEST_PARALLEL_LEVEL = 0
+export CTEST_OUTPUT_ON_FAILURE = 1
+
build: $(foreach t,$(build_types),$(foreach p,$(platforms),build/$p-$t/build))
.PHONY: build
@@ -89,7 +92,7 @@ check: build
.PHONY: check
$(foreach t,$(build_types),$(foreach p,$(platforms),build/$p-$t/check)): build/%/check: build/%/Makefile
- CTEST_OUTPUT_ON_FAILURE=1 $(MAKE) -C $(<D) test
+ $(MAKE) -C $(<D) test
.PHONY: $(foreach t,$(build_types),$(foreach p,$(platforms),build/$p-$t/check))
# `lint` and `format` ##########################################################
diff --git a/lib9p/tests/runtest b/lib9p/tests/runtest
index c2f6c41..3a46f28 100755
--- a/lib9p/tests/runtest
+++ b/lib9p/tests/runtest
@@ -7,11 +7,12 @@
set -euE -o pipefail
set -x
-valgrind --error-exitcode=2 ./tests/test_server/test_server &
+port=$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()')
+valgrind --error-exitcode=2 ./tests/test_server/test_server "$port" &
server_pid=$!
# shellcheck disable=SC2064
trap "kill $server_pid || true; wait $server_pid || true" EXIT
-server_addr='localhost:9000'
+server_addr="localhost:${port}"
client=(9p -a "$server_addr")
diff --git a/lib9p/tests/test_server/main.c b/lib9p/tests/test_server/main.c
index c60dd71..59a21ec 100644
--- a/lib9p/tests/test_server/main.c
+++ b/lib9p/tests/test_server/main.c
@@ -5,6 +5,7 @@
*/
#include <error.h>
+#include <stdlib.h> /* for atoi() */
#include <lib9p/srv.h>
#include <libcr/coroutine.h>
@@ -32,6 +33,7 @@ static lo_interface lib9p_srv_file get_root(struct lib9p_srv_ctx *, struct lib9p
const char *hexdig = "0123456789abcdef";
struct {
+ uint16_t port;
struct hostnet_tcp_listener listeners[CONFIG_SRV9P_NUM_CONNS];
struct lib9p_srv srv;
} globals = {
@@ -146,7 +148,7 @@ static COROUTINE read_cr(void *_i) {
int i = *((int *)_i);
cr_begin();
- hostnet_tcp_listener_init(&globals.listeners[i], 9000);
+ hostnet_tcp_listener_init(&globals.listeners[i], globals.port);
lib9p_srv_read_cr(&globals.srv, lo_box_hostnet_tcplist_as_net_stream_listener(&globals.listeners[i]));
@@ -172,7 +174,10 @@ static COROUTINE init_cr(void *) {
cr_exit();
}
-int main() {
+int main(int argc, char *argv[]) {
+ if (argc != 2)
+ error(2, 0, "usage: %s PORT_NUMBER", argv[0]);
+ globals.port = atoi(argv[1]);
struct hostclock clock_monotonic = {
.clock_id = CLOCK_MONOTONIC,
};