Files
DucielandClaude Opus 5.5 327c658587 In-game settings window and minimap button; live settings (0.9.0)
- DucielPerf addon embedded in the DLL (always served, listed in the addon
  list): minimap button and /ducielperf (/dperf) open a window with
  Performance, Diagnostics, Features (module switches, world markers on
  me/target/clear, interact key bindings, loot all corpses) and Status tabs.
- settings.cpp: one table of every ducielperf.cfg setting with live apply
  where possible; DucielPerf_SettingInfo / GetSetting / SetSetting.
  config_set_int writes ducielperf.cfg keeping comments and other keys.
- Live switches: decompression, file cache, Lua strings, SavedVariables
  buffering, frame raising and clickthrough keep their hooks and call the
  client's code while off. New keys: inflate, filecache, luastrings,
  alloctrack, worldmarkers, interact, clickthrough, transmogfix, exitfix,
  minimap, minimap_angle.
- Tests: test_config (cfg writing), test_addon (the addon on a mock WoW API
  in Lua 5.0).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 02:02:46 +01:00

83 lines
4.3 KiB
Bash

#!/usr/bin/env bash
# Builds and runs the host-side tests (no game needed).
#
# tests/run_tests.sh [fuzz_iterations] [patterns.txt subjects.txt]
#
# test_prefilter checks the Lua pattern prefilter against the real Lua 5.0.3
# string library (tests/lua50, unmodified upstream sources, MIT license).
set -euo pipefail
cd "$(dirname "$0")/.."
ZIG=tools/zig/zig.exe
[ -x "$ZIG" ] || ZIG=$(command -v zig || true)
[ -n "$ZIG" ] || { echo "Zig not found (tools/zig/zig.exe or PATH)"; exit 1; }
OUT=build/tests
mkdir -p "$OUT/obj"
LUA_C=(tests/lua50/src/*.c tests/lua50/lib/lauxlib.c tests/lua50/lib/lbaselib.c tests/lua50/lib/lstrlib.c)
objs=()
for src in "${LUA_C[@]}"; do
obj=$OUT/obj/$(basename "${src%.c}").o
[ "$obj" -nt "$src" ] || "$ZIG" cc -O2 -w -Itests/lua50/include -Itests/lua50/src -c "$src" -o "$obj"
objs+=("$obj")
done
"$ZIG" c++ -O2 -std=c++17 -Wall -Wno-nullability-completeness -Itests/lua50/include tests/test_prefilter.cpp "${objs[@]}" -o "$OUT/test_prefilter.exe"
# bench_alloctrack: 32-bit (it lays out the client's 32-bit Lua structures), with MinHook.
mh_objs=()
for src in third_party/minhook/src/buffer.c third_party/minhook/src/hook.c third_party/minhook/src/trampoline.c \
third_party/minhook/src/hde/hde32.c; do
obj=$OUT/obj/x86_$(basename "${src%.c}").o
[ "$obj" -nt "$src" ] || "$ZIG" cc -target x86-windows-gnu -O2 -w -Ithird_party/minhook/include -c "$src" -o "$obj"
mh_objs+=("$obj")
done
"$ZIG" c++ -target x86-windows-gnu -O2 -std=c++17 -Wall -Wno-nullability-completeness -Ithird_party/minhook/include \
tests/bench_alloctrack.cpp "${mh_objs[@]}" -o "$OUT/bench_alloctrack.exe"
# test_watchdog: 32-bit, per-frame counters and freeze watchdog with stubbed core services.
"$ZIG" c++ -target x86-windows-gnu -O2 -std=c++17 -fno-exceptions -fno-rtti -Wall -Wno-nullability-completeness \
-Wno-unused-function -DDP_TEST tests/test_watchdog.cpp src/modules/framestats.cpp src/modules/watchdog.cpp \
-o "$OUT/test_watchdog.exe"
# test_strbuf: 32-bit Lua 5.0.3 (512-byte luaL_Buffer like the client) with an
# allocation counter; lauxlib without inlining so its functions can be detoured.
lua32=()
for src in "${LUA_C[@]}" tests/lua50/lib/ltablib.c tests/lua50/lib/lmathlib.c; do
obj=$OUT/obj/x86_lua_$(basename "${src%.c}").o
flags="-O2"
case "$src" in *lauxlib.c) flags="-O1 -fno-inline" ;; esac
[ "$obj" -nt "$src" ] && [ "$obj" -nt tests/strbuf_alloc.h ] || "$ZIG" cc -target x86-windows-gnu $flags -w \
-Itests/lua50/include -Itests/lua50/src -include tests/strbuf_alloc.h \
"-Dl_realloc(b,os,s)=dp_test_realloc(b,os,s)" -c "$src" -o "$obj"
lua32+=("$obj")
done
"$ZIG" c++ -target x86-windows-gnu -O2 -std=c++17 -Wall -Wno-nullability-completeness -Itests/lua50/include \
-Ithird_party/minhook/include tests/test_strbuf.cpp "${lua32[@]}" "${mh_objs[@]}" -o "$OUT/test_strbuf.exe"
# test_svwrite: buffered SavedVariables writes (byte-identical output, fewer OS writes).
"$ZIG" c++ -target x86-windows-gnu -O2 -std=c++17 -Wall -Wno-nullability-completeness tests/test_svwrite.cpp \
-o "$OUT/test_svwrite.exe"
# test_framelevel: one-pass frame-level compaction against a port of the client's algorithm.
"$ZIG" c++ -target x86-windows-gnu -O2 -std=c++17 -Wall -Wno-nullability-completeness tests/test_framelevel.cpp \
-o "$OUT/test_framelevel.exe"
# test_config: ducielperf.cfg writing (comments and other keys kept).
"$ZIG" c++ -target x86-windows-gnu -O2 -std=c++17 -fno-exceptions -fno-rtti -Wall -Wno-nullability-completeness \
-Ithird_party/minhook/include tests/test_config.cpp src/core/core.cpp "${mh_objs[@]}" -o "$OUT/test_config.exe"
# test_addon: the embedded settings addon on a mock WoW API, in real Lua 5.0.
LUA_LIB=(tests/lua50/lib/lauxlib.c tests/lua50/lib/lbaselib.c tests/lua50/lib/lstrlib.c tests/lua50/lib/ltablib.c
tests/lua50/lib/lmathlib.c)
"$ZIG" cc -O1 -w -Itests/lua50/include -Itests/lua50/src tests/addon/luarun.c $(ls tests/lua50/src/*.c | grep -v ltests) \
"${LUA_LIB[@]}" -o "$OUT/luarun.exe"
"$OUT/test_prefilter.exe" "$@"
"$OUT/bench_alloctrack.exe"
"$OUT/test_watchdog.exe"
"$OUT/test_strbuf.exe"
"$OUT/test_svwrite.exe"
"$OUT/test_framelevel.exe"
"$OUT/test_config.exe"
"$OUT/luarun.exe" tests/addon/wow_mock.lua assets/addons/DucielPerf/DucielPerf.lua tests/addon/drive_ui.lua