From 8d3991d6cca1a57ef5c48460313a07f709c89248 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sat, 22 Mar 2025 16:06:35 -0600 Subject: Enable running tests in parallel --- lib9p/tests/runtest | 5 +++-- lib9p/tests/test_server/main.c | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'lib9p/tests') 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 +#include /* for atoi() */ #include #include @@ -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, }; -- cgit v1.2.3-2-g168b From 999a5a51a0c00bac636adab86fc0033d0bbd98e0 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sat, 22 Mar 2025 03:08:05 -0600 Subject: make lint/unknown: Have unknown files be errors --- lib9p/tests/runtest | 6 +++--- lib9p/tests/test_server/CMakeLists.txt | 2 +- lib9p/tests/test_server/main.c | 2 +- lib9p/tests/test_server/static/Documentation/x | 7 ------- lib9p/tests/test_server/static/Documentation/x.txt | 7 +++++++ 5 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 lib9p/tests/test_server/static/Documentation/x create mode 100644 lib9p/tests/test_server/static/Documentation/x.txt (limited to 'lib9p/tests') diff --git a/lib9p/tests/runtest b/lib9p/tests/runtest index 3a46f28..a745f12 100755 --- a/lib9p/tests/runtest +++ b/lib9p/tests/runtest @@ -32,7 +32,7 @@ expect_lines \ out=$("${client[@]}" ls -l 'Documentation/') expect_lines \ - '--r--r--r-- M 0 root root 162 Oct 7 15:51 x' + '--r--r--r-- M 0 root root 166 Oct 7 15:51 x' out=$("${client[@]}" read 'README.md') expect_lines \ @@ -47,7 +47,7 @@ expect_lines \ out=$("${client[@]}" read 'Documentation/x') expect_lines \ ' -foo diff --git a/lib9p/tests/test_server/static/Documentation/x.txt b/lib9p/tests/test_server/static/Documentation/x.txt new file mode 100644 index 0000000..e85ee4e --- /dev/null +++ b/lib9p/tests/test_server/static/Documentation/x.txt @@ -0,0 +1,7 @@ + +foo -- cgit v1.2.3-2-g168b From e3cb318792bc8570869c93d8219306cf61b9b007 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Thu, 20 Mar 2025 19:27:04 -0600 Subject: lib9p: Add a test that generated macros compile --- lib9p/tests/test_compile.c | 95 ++++++++++++++++++++++++++++++++ lib9p/tests/test_compile.c.gen | 19 +++++++ lib9p/tests/test_compile_config/config.h | 38 +++++++++++++ 3 files changed, 152 insertions(+) create mode 100644 lib9p/tests/test_compile.c create mode 100755 lib9p/tests/test_compile.c.gen create mode 100644 lib9p/tests/test_compile_config/config.h (limited to 'lib9p/tests') diff --git a/lib9p/tests/test_compile.c b/lib9p/tests/test_compile.c new file mode 100644 index 0000000..989bf20 --- /dev/null +++ b/lib9p/tests/test_compile.c @@ -0,0 +1,95 @@ +/* lib9p/tests/test_compile.c - Generated by lib9p/tests/test_compile.c.gen. DO NOT EDIT! */ + +#include +int main(void) { + [[gnu::unused]] uint64_t x; + x = LIB9P_TAG_NOTAG; + x = LIB9P_FID_NOFID; + x = LIB9P_DM_DIR; + x = LIB9P_DM_APPEND; + x = LIB9P_DM_EXCL; + x = _LIB9P_DM_PLAN9_MOUNT; + x = LIB9P_DM_AUTH; + x = LIB9P_DM_TMP; + x = LIB9P_DM_DEVICE; + x = LIB9P_DM_NAMEDPIPE; + x = LIB9P_DM_SOCKET; + x = LIB9P_DM_SETUID; + x = LIB9P_DM_SETGID; + x = LIB9P_DM_OWNER_R; + x = LIB9P_DM_OWNER_W; + x = LIB9P_DM_OWNER_X; + x = LIB9P_DM_GROUP_R; + x = LIB9P_DM_GROUP_W; + x = LIB9P_DM_GROUP_X; + x = LIB9P_DM_OTHER_R; + x = LIB9P_DM_OTHER_W; + x = LIB9P_DM_OTHER_X; + x = LIB9P_DM_PERM_MASK; + x = LIB9P_QT_DIR; + x = LIB9P_QT_APPEND; + x = LIB9P_QT_EXCL; + x = _LIB9P_QT_PLAN9_MOUNT; + x = LIB9P_QT_AUTH; + x = LIB9P_QT_TMP; + x = LIB9P_QT_SYMLINK; + x = LIB9P_QT_FILE; + x = LIB9P_NUID_NONUID; + x = LIB9P_O_RCLOSE; + x = LIB9P_O_TRUNC; + x = LIB9P_O_mode_1; + x = LIB9P_O_mode_0; + x = LIB9P_O_READ; + x = LIB9P_O_WRITE; + x = LIB9P_O_RDWR; + x = LIB9P_O_EXEC; + x = LIB9P_O_MODE_MASK; + x = LIB9P_O_FLAG_MASK; + x = LIB9P_GETATTR_DATA_VERSION; + x = LIB9P_GETATTR_GEN; + x = LIB9P_GETATTR_BTIME; + x = LIB9P_GETATTR_BLOCKS; + x = LIB9P_GETATTR_SIZE; + x = LIB9P_GETATTR_INO; + x = LIB9P_GETATTR_CTIME; + x = LIB9P_GETATTR_MTIME; + x = LIB9P_GETATTR_ATIME; + x = LIB9P_GETATTR_RDEV; + x = LIB9P_GETATTR_GID; + x = LIB9P_GETATTR_UID; + x = LIB9P_GETATTR_NLINK; + x = LIB9P_GETATTR_MODE; + x = LIB9P_GETATTR_BASIC; + x = LIB9P_GETATTR_ALL; + x = LIB9P_SETATTR_MTIME_SET; + x = LIB9P_SETATTR_ATIME_SET; + x = LIB9P_SETATTR_CTIME; + x = LIB9P_SETATTR_MTIME; + x = LIB9P_SETATTR_ATIME; + x = LIB9P_SETATTR_SIZE; + x = LIB9P_SETATTR_GID; + x = LIB9P_SETATTR_UID; + x = LIB9P_SETATTR_MODE; + x = LIB9P_LOCK_TYPE_RDLCK; + x = LIB9P_LOCK_TYPE_WRLCK; + x = LIB9P_LOCK_TYPE_UNLCK; + x = LIB9P_LOCK_FLAGS_RECLAIM; + x = LIB9P_LOCK_FLAGS_BLOCK; + x = LIB9P_LOCK_STATUS_SUCCESS; + x = LIB9P_LOCK_STATUS_BLOCKED; + x = LIB9P_LOCK_STATUS_ERROR; + x = LIB9P_LOCK_STATUS_GRACE; + x = LIB9P_TMSG_MAX_IOV; + x = LIB9P_TMSG_MAX_IOV; + x = LIB9P_TMSG_MAX_COPY; + x = LIB9P_TMSG_MAX_COPY; + x = LIB9P_TMSG_MAX_COPY; + x = LIB9P_TMSG_MAX_COPY; + x = LIB9P_TMSG_MAX_COPY; + x = LIB9P_TMSG_MAX_COPY; + x = LIB9P_RMSG_MAX_IOV; + x = LIB9P_RMSG_MAX_IOV; + x = LIB9P_RMSG_MAX_IOV; + x = LIB9P_RMSG_MAX_COPY; + return 0; +} diff --git a/lib9p/tests/test_compile.c.gen b/lib9p/tests/test_compile.c.gen new file mode 100755 index 0000000..47046b3 --- /dev/null +++ b/lib9p/tests/test_compile.c.gen @@ -0,0 +1,19 @@ +#!/bin/sh +# lib9p/tests/test_compile.c.gen - Generate code to make sure all generated macros work +# +# Copyright (C) 2025 Luke T. Shumaker +# SPDX-License-Identifier: AGPL-3.0-or-later + +generated_h=$1 +outfile=$2 + +{ + echo "/* ${outfile} - Generated by $0. DO NOT EDIT! */" + echo + echo "#include " + echo 'int main(void) {' + echo ' [[gnu::unused]] uint64_t x;' + sed -nE 's/^\s*#\s*define\s*(\S[^ (]*)\s.*/ x = \1;/p' <"$generated_h" + echo ' return 0;' + echo '}' +} >"$outfile" diff --git a/lib9p/tests/test_compile_config/config.h b/lib9p/tests/test_compile_config/config.h new file mode 100644 index 0000000..38ab0c0 --- /dev/null +++ b/lib9p/tests/test_compile_config/config.h @@ -0,0 +1,38 @@ +/* config.h - Compile-time configuration for lib9p/test/test_compile + * + * Copyright (C) 2024-2025 Luke T. Shumaker + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +#ifndef _CONFIG_H_ +#define _CONFIG_H_ + +/* 9P *************************************************************************/ + +#define CONFIG_9P_MAX_MSG_SIZE ((4*1024)+24) +#define CONFIG_9P_MAX_HOSTMSG_SIZE CONFIG_9P_MAX_MSG_SIZE+16 +#define CONFIG_9P_MAX_ERR_SIZE 128 +#define CONFIG_9P_MAX_9P2000_e_WELEM 16 + +#define CONFIG_9P_SRV_MAX_FIDS 16 +#define CONFIG_9P_SRV_MAX_REQS 2 +#define CONFIG_9P_SRV_MAX_DEPTH 3 + +#define CONFIG_9P_ENABLE_9P2000 1 /* bool */ +#define CONFIG_9P_ENABLE_9P2000_u 1 /* bool */ +#define CONFIG_9P_ENABLE_9P2000_e 1 /* bool */ +#define CONFIG_9P_ENABLE_9P2000_L 1 /* bool */ +#define CONFIG_9P_ENABLE_9P2000_p9p 1 /* bool */ + +/* COROUTINE ******************************************************************/ + +#define CONFIG_COROUTINE_STACK_SIZE_DEFAULT (32*1024) +#define CONFIG_COROUTINE_NAME_LEN 16 +#define CONFIG_COROUTINE_MEASURE_STACK 1 /* bool */ +#define CONFIG_COROUTINE_PROTECT_STACK 1 /* bool */ +#define CONFIG_COROUTINE_DEBUG 0 /* bool */ +#define CONFIG_COROUTINE_VALGRIND 1 /* bool */ +#define CONFIG_COROUTINE_GDB 1 /* bool */ +#define CONFIG_COROUTINE_NUM 2 + +#endif /* _CONFIG_H_ */ -- cgit v1.2.3-2-g168b