test: add test_mod_dep build targets and update test_mod with metadata

This commit is contained in:
2026-03-05 00:10:06 +01:00
parent 8e9007fdfe
commit 4f4ae80a14
4 changed files with 41 additions and 10 deletions
+9 -5
View File
@@ -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/
+8 -3
View File
@@ -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
+5 -2
View File
@@ -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"; }
+19
View File
@@ -0,0 +1,19 @@
#include <stdio.h>
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"}, {"", ""}};