From 4f4ae80a14e2d369d529880613ef535e0175580e Mon Sep 17 00:00:00 2001 From: anth64 Date: Thu, 5 Mar 2026 00:10:06 +0100 Subject: [PATCH] test: add test_mod_dep build targets and update test_mod with metadata --- test/bmake.mk | 14 +++++++++----- test/gmake.mk | 11 ++++++++--- test/test_mod.c | 7 +++++-- test/test_mod_dep.c | 19 +++++++++++++++++++ 4 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 test/test_mod_dep.c diff --git a/test/bmake.mk b/test/bmake.mk index 223d9b3..2ac1fd2 100644 --- a/test/bmake.mk +++ b/test/bmake.mk @@ -22,23 +22,27 @@ test_program: test.c test_mod$(MODULE_EXT): test_mod.c $(CC) $(CFLAGS) -fPIC -shared -o $@ test_mod.c +test_mod_dep$(MODULE_EXT): test_mod_dep.c + $(CC) $(CFLAGS) -fPIC -shared -o $@ test_mod_dep.c + setup: @mkdir -p mods @cp -f test_mod$(MODULE_EXT) mods/ 2>/dev/null || true - @echo "Test environment ready: mods/ directory with test_mod$(MODULE_EXT)" + @cp -f test_mod_dep$(MODULE_EXT) mods/ 2>/dev/null || true + @echo "Test environment ready: mods/ directory with test modules" -run: test_program test_mod$(MODULE_EXT) setup +run: test_program test_mod$(MODULE_EXT) test_mod_dep$(MODULE_EXT) setup @echo "Running integration test (CTRL+C to exit)..." @./test_program -test: test_program test_mod$(MODULE_EXT) setup +test: test_program test_mod$(MODULE_EXT) test_mod_dep$(MODULE_EXT) setup @echo "=== stk Integration Test ===" @echo "1. Starting test program" - @echo "2. Will load test_mod$(MODULE_EXT) from mods/" + @echo "2. Will load test_mod and test_mod_dep from mods/" @echo "3. Press CTRL+C to exit" @echo "=============================" @./test_program || echo "Test completed." clean: - rm -f test_program test_mod$(MODULE_EXT) + rm -f test_program test_mod$(MODULE_EXT) test_mod_dep$(MODULE_EXT) rm -rf mods/ diff --git a/test/gmake.mk b/test/gmake.mk index 5bf3f03..3f7e137 100644 --- a/test/gmake.mk +++ b/test/gmake.mk @@ -23,16 +23,21 @@ test_program$(EXE_EXT): test.c test_mod$(MODULE_EXT): test_mod.c $(CC) $(CFLAGS) -fPIC -shared -o $@ test_mod.c +test_mod_dep$(MODULE_EXT): test_mod_dep.c + $(CC) $(CFLAGS) -fPIC -shared -o $@ test_mod_dep.c + setup: ifeq ($(OS),Windows_NT) @if not exist mods mkdir mods @if exist test_mod.dll copy /Y test_mod.dll mods\ >nul 2>&1 + @if exist test_mod_dep.dll copy /Y test_mod_dep.dll mods\ >nul 2>&1 else @mkdir -p mods @cp -f test_mod.so mods/ 2>/dev/null || true + @cp -f test_mod_dep.so mods/ 2>/dev/null || true endif -test: test_program$(EXE_EXT) test_mod$(MODULE_EXT) setup +test: test_program$(EXE_EXT) test_mod$(MODULE_EXT) test_mod_dep$(MODULE_EXT) setup ifeq ($(OS),Windows_NT) @set PATH=../bin/debug;%PATH% && cmd /C "test_program.exe" else @@ -41,9 +46,9 @@ endif clean: ifeq ($(OS),Windows_NT) - @del /Q test_program.exe test_mod.dll 2>nul || true + @del /Q test_program.exe test_mod.dll test_mod_dep.dll 2>nul || true @rmdir /S /Q mods 2>nul || true else - @rm -f test_program test_mod.so + @rm -f test_program test_mod.so test_mod_dep.so @rm -rf mods endif diff --git a/test/test_mod.c b/test/test_mod.c index 9025f6f..22944f8 100644 --- a/test/test_mod.c +++ b/test/test_mod.c @@ -2,8 +2,11 @@ int stk_mod_init(void) { - printf("test mod initialized!\n"); + printf("test_mod initialized!\n"); return 0; } -void stk_mod_shutdown(void) { printf("test mod shut down.\n"); } +void stk_mod_shutdown(void) { printf("test_mod shut down.\n"); } + +const char *stk_mod_name(void) { return "Test Module"; } +const char *stk_mod_version(void) { return "1.0.0"; } diff --git a/test/test_mod_dep.c b/test/test_mod_dep.c new file mode 100644 index 0000000..01cde6d --- /dev/null +++ b/test/test_mod_dep.c @@ -0,0 +1,19 @@ +#include + +typedef struct { + char id[64]; + char version[32]; +} dep_t; + +int stk_mod_init(void) +{ + printf("test_mod_dep initialized!\n"); + return 0; +} + +void stk_mod_shutdown(void) { printf("test_mod_dep shut down.\n"); } + +const char *stk_mod_name(void) { return "Dependent Test Module"; } +const char *stk_mod_version(void) { return "1.0.0"; } + +dep_t stk_mod_deps[] = {{"test_mod", ">=1.0.0"}, {"", ""}};