Skip to content

Commit e3b38f2

Browse files
committed
SERVER/PR: Add sys_testmode 2 for round 100 tests
1 parent 9e45d96 commit e3b38f2

5 files changed

Lines changed: 115 additions & 0 deletions

File tree

.github/workflows/map-tests.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: QuakeC Round 100 Tests
2+
on: [pull_request]
3+
jobs:
4+
Round-100-Tests:
5+
name: Run Round 100 Tests
6+
runs-on: ubuntu-latest
7+
container:
8+
image: ubuntu:24.10
9+
options: --shm-size=8192m
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
- name: Wait for GitHub to keep up..
14+
run: sleep 2s
15+
shell: bash
16+
- name: Run Round 100 Script
17+
run: |
18+
bash testing/run_map_tests.sh

source/client/main.qc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init =
163163
autocvar(in_aimassist, 0);
164164
autocvar(cl_hitmarkers, 1);
165165
autocvar(cl_textopacity, 0.20);
166+
167+
autocvar(sys_testmode, 2);
166168

167169
autocvar(scr_playerdebuginfo, 0);
168170
autocvar(scr_playerdebuginfo_x, 64);

source/server/ai/zombie_core.qc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,11 @@ void() zombie_attack2 =
740740
{
741741
if(vlen(self.enemy.origin - self.origin) < 64)
742742
{
743+
if (cvar("sys_testmode") == 2) {
744+
self.th_die();
745+
return;
746+
}
747+
743748
if (self.classname == "ai_dog")
744749
DamageHandler (self.enemy, self, 40, DMG_TYPE_ZOMBIESWIPE);
745750
else

source/server/rounds.qc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,20 @@ void() NewRound =
209209

210210
rounds = rounds + 1;
211211

212+
if (cvar("sys_testmode") == 2) {
213+
if (rounds >= 100) {
214+
localcmd("quit\n");
215+
} else if (rounds % 5 == 0) {
216+
#ifdef FTE
217+
print(sprintf(" + Reached round [%d]\n", rounds));
218+
#endif
219+
}
220+
}
221+
222+
if (rounds >= 100 && cvar("sys_testmode") == 2) {
223+
localcmd("quit\n");
224+
}
225+
212226
#ifdef FTE
213227

214228
// FTE-Specific - alert CSQC of the round increment for HUD display

testing/run_map_tests.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
#
3+
# Nazi Zombies: Portable
4+
# QuakeC Round 100 test runs on every bundled map.
5+
# ----
6+
# This is intended to be used via a Docker
7+
# container running ubuntu:24.10.
8+
#
9+
set -o errexit
10+
11+
# tzdata will try to display an interactive install prompt by
12+
# default, so make sure we define our system as non-interactive.
13+
export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
14+
15+
WORKING_DIRECTORY="/working"
16+
OUTPUT_LOG="${WORKING_DIRECTORY}/run.log"
17+
REPO_PWD=$(pwd)
18+
19+
function setup_container()
20+
{
21+
echo "[INFO]: Installing dependancies.."
22+
apt update -y
23+
apt install libsdl2-dev wget zip python3 python3-pip -y
24+
wget https://raw.githubusercontent.com/nzp-team/QCHashTableGenerator/main/requirements.txt
25+
pip install -r requirements.txt --break-system-packages
26+
rm requirements.txt
27+
mkdir -p "${WORKING_DIRECTORY}"
28+
}
29+
30+
function download_nzp()
31+
{
32+
echo "[INFO]: Obtaining latest Nazi Zombies: Portable Linux x86_64 release.."
33+
cd "${WORKING_DIRECTORY}"
34+
wget https://github.com/nzp-team/nzportable/releases/download/nightly/nzportable-linux64.zip
35+
mkdir nzportable-linux64
36+
unzip nzportable-linux64.zip -d nzportable-linux64/
37+
chmod +x nzportable-linux64/nzportable64-sdl
38+
}
39+
40+
function build_quakec()
41+
{
42+
echo "[INFO]: Building QuakeC.."
43+
cd "${REPO_PWD}/tools"
44+
local cmd="./qc-compiler-gnu.sh"
45+
${cmd}
46+
47+
echo "[INFO]: Moving QuakeC to game download.."
48+
cp "${REPO_PWD}/build/fte/qwprogs.dat" "${WORKING_DIRECTORY}/nzportable-linux64/nzp/"
49+
}
50+
51+
function run_test()
52+
{
53+
echo "[INFO]: Running tests.."
54+
cd "${WORKING_DIRECTORY}/nzportable-linux64/"
55+
56+
# Iterate through every map..
57+
while read -r map; do
58+
local pretty_name=$(basename ${map} .bsp)
59+
echo "[INFO]: Running [${pretty_name}].."
60+
61+
local cmd="./nzportable64-sdl +map ${pretty_name} +vid_renderer headless +sys_testmode 2 +slowmo 100"
62+
${cmd}
63+
done < <(find nzp/maps/ -type f -name "*.bsp")
64+
65+
echo "[INFO]: TEST PASSED."
66+
}
67+
68+
function main()
69+
{
70+
setup_container;
71+
download_nzp;
72+
build_quakec;
73+
run_test;
74+
}
75+
76+
main;

0 commit comments

Comments
 (0)