test(backend): add RPT log output to server stub
- Stub now parses -profiles= arg and writes RPT entries to profilesDir/arma3server_x64_<timestamp>.rpt - RPT includes header (exe timestamp, computer name, OS) and periodic entries (MissionEditor, World, Server: Player) on each heartbeat cycle - New test TestStart_StubWritesRPTLog verifies RPT file creation and content via the profiles directory
This commit is contained in:
@@ -1,17 +1,39 @@
|
||||
#!/bin/sh
|
||||
# Stub arma3server binary for testing.
|
||||
# Logs binary path and all arguments, prints heartbeat every 5s.
|
||||
# Writes RPT log entries to the profiles directory (like the real server).
|
||||
# Use -t N to exit after N seconds (for auto-exit tests).
|
||||
|
||||
echo "[STUB] binary=$0 args=$*"
|
||||
|
||||
DURATION=0
|
||||
PROFILES_DIR=""
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-t) DURATION="$2"; shift 2 ;;
|
||||
-profiles=*) PROFILES_DIR="${1#-profiles=}"; shift ;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Create RPT file in profiles dir if provided
|
||||
RPT_FILE=""
|
||||
if [ -n "$PROFILES_DIR" ]; then
|
||||
mkdir -p "$PROFILES_DIR"
|
||||
RPT_FILE="$PROFILES_DIR/arma3server_x64_$(date +%Y%m%d_%H%M%S).rpt"
|
||||
echo "--- RPT log started ---" > "$RPT_FILE"
|
||||
echo "Exe timestamp: 2024/01/15 12:00:00" >> "$RPT_FILE"
|
||||
echo "Computer name: STUB-TEST" >> "$RPT_FILE"
|
||||
echo "Operating system: Linux" >> "$RPT_FILE"
|
||||
fi
|
||||
|
||||
write_rpt() {
|
||||
if [ -n "$RPT_FILE" ]; then
|
||||
echo "$1" >> "$RPT_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
TICK=0
|
||||
if [ "$DURATION" -gt 0 ] 2>/dev/null; then
|
||||
ELAPSED=0
|
||||
while [ "$ELAPSED" -lt "$DURATION" ]; do
|
||||
@@ -20,12 +42,21 @@ if [ "$DURATION" -gt 0 ] 2>/dev/null; then
|
||||
if [ "$REMAINING" -lt 5 ]; then WAIT=$REMAINING; fi
|
||||
sleep "$WAIT"
|
||||
ELAPSED=$((ELAPSED + WAIT))
|
||||
TICK=$((TICK + 1))
|
||||
echo "[STUB] heartbeat elapsed=${ELAPSED}s remaining=$((REMAINING - WAIT))s"
|
||||
write_rpt "$(date +%H:%M:%S) MissionEditor: Mission file selected: test_mission.Tanoa"
|
||||
write_rpt "$(date +%H:%M:%S) World: Avoid neighbor island: 0.00 ms (1.00 ms)"
|
||||
write_rpt "$(date +%H:%M:%S) Server: Player #1 connected (id=12345)"
|
||||
done
|
||||
write_rpt "$(date +%H:%M:%S) Server: Shutdown completed"
|
||||
echo "[STUB] server exiting after ${DURATION}s"
|
||||
else
|
||||
while true; do
|
||||
sleep 5
|
||||
TICK=$((TICK + 1))
|
||||
echo "[STUB] heartbeat running..."
|
||||
write_rpt "$(date +%H:%M:%S) MissionEditor: Mission file selected: test_mission.Tanoa"
|
||||
write_rpt "$(date +%H:%M:%S) World: Avoid neighbor island: 0.00 ms (1.00 ms)"
|
||||
write_rpt "$(date +%H:%M:%S) Server: Player #1 connected (id=12345)"
|
||||
done
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user