diff options
Diffstat (limited to 'lib9p/tests/test_server')
-rw-r--r-- | lib9p/tests/test_server/CMakeLists.txt | 3 | ||||
-rw-r--r-- | lib9p/tests/test_server/config/config.h | 3 | ||||
-rw-r--r-- | lib9p/tests/test_server/main.c | 11 | ||||
-rw-r--r-- | lib9p/tests/test_server/static/Documentation/x.txt (renamed from lib9p/tests/test_server/static/Documentation/x) | 2 |
4 files changed, 12 insertions, 7 deletions
diff --git a/lib9p/tests/test_server/CMakeLists.txt b/lib9p/tests/test_server/CMakeLists.txt index a107b75..74a759d 100644 --- a/lib9p/tests/test_server/CMakeLists.txt +++ b/lib9p/tests/test_server/CMakeLists.txt @@ -18,6 +18,7 @@ target_link_libraries(test_server_objs libmisc lib9p lib9p_util + libhw ) # Analyze the stack ############################################################ @@ -36,7 +37,7 @@ target_sources(test_server PRIVATE target_embed_sources(test_server_objs test_server static.h static/README.md - static/Documentation/x + static/Documentation/x.txt ) endif() diff --git a/lib9p/tests/test_server/config/config.h b/lib9p/tests/test_server/config/config.h index 67960ca..afe6dc0 100644 --- a/lib9p/tests/test_server/config/config.h +++ b/lib9p/tests/test_server/config/config.h @@ -1,4 +1,4 @@ -/* config.h - Compile-time configuration for srv9p +/* config.h - Compile-time configuration for lib9p/test/test_server * * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later @@ -12,7 +12,6 @@ /* 9P *************************************************************************/ -#define CONFIG_9P_PORT LIB9P_DEFAULT_PORT_9FS /** * This max-msg-size is sized so that a Twrite message can return * 8KiB of data. diff --git a/lib9p/tests/test_server/main.c b/lib9p/tests/test_server/main.c index c60dd71..074dbe7 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 = { @@ -130,7 +132,7 @@ enum { PATH_BASE = __COUNTER__ }; struct lib9p_srv_file root = STATIC_DIR("", STATIC_DIR("Documentation", - STATIC_FILE("x", Documentation_x), + STATIC_FILE("x", Documentation_x_txt), ), STATIC_FILE("README.md", README_md), lo_box_api_as_lib9p_srv_file(&(struct api_file){.pathnum = PATH_COUNTER}), @@ -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, }; diff --git a/lib9p/tests/test_server/static/Documentation/x b/lib9p/tests/test_server/static/Documentation/x.txt index b9b08d4..e85ee4e 100644 --- a/lib9p/tests/test_server/static/Documentation/x +++ b/lib9p/tests/test_server/static/Documentation/x.txt @@ -1,5 +1,5 @@ <!-- - Documentation/x - test static file + Documentation/x.txt - test static file Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> SPDX-License-Identifier: AGPL-3.0-or-later |