OpenCoD2-Plus
Call of Duty 2 client & server, rebuilt
Loading...
Searching...
No Matches
opencod2_smoke Namespace Reference

Functions

 parse_results (text)
 load_expected (path)
 compare (results, expected, flaky=frozenset())
 write_launcher (directory, wine, exe)
 strict_port (launcher, game_dir)
 smoke_args (game_dir, binary, protocol, stock)
 main ()

Variables

 ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 RESULT = re.compile(r'^(ok |FAIL) (?P<name>.+?)( \‍(.*\‍))?$')
str HEADER = '# Fallos esperados de smoke_test.py con el servidor de opencod2; solo se achica.\n'
tuple WINE_HEADER
dict DEFAULT_BINARY = {115: 'build/check-linux-10/cod2_lnxded', 118: 'build/check-linux/cod2_lnxded'}
str LAUNCHER

Detailed Description

Runs smoke_test.py against this repo's server and compares its failures with a list.

    python3 scripts/opencod2_smoke.py /path/to/CoD2 --protocol {115|118} [--binary PATH] [--wine WINE] [--update]

smoke_test.py comes unchanged from CoD2rev-Plus, so it also checks features this
server does not have yet. Those failures are listed in
test/smoke_expected_failures_<protocol>.txt. Exit codes: 0 when the failures
match the list, 1 when a check not on the list fails, 2 when a listed check now
passes (the list only shrinks: run again with --update), 3 when smoke_test.py
printed no results. The checks in test/smoke_flaky.txt are timing-dependent
with this server and count neither way.

With --wine, --binary is the Windows server (cod2_win32_ded.exe) and WINE the
command that runs it (scripts/portable_wine.sh). smoke_test.py runs a launcher
that gives wine the paths as Windows sees them; the list is then
test/smoke_expected_failures_wine.txt, since the Windows server prints only to
its console window and a signal does not reach it as one under wine.
net_strictPort, which smoke_test.py checks in the output, is checked here in
its console log instead: the failed bind and no other port tried.

Function Documentation

◆ compare()

opencod2_smoke.compare ( results,
expected,
flaky = frozenset() )
(failures not on the list, listed checks that no longer fail or no longer exist), flaky ones aside.

◆ load_expected()

opencod2_smoke.load_expected ( path)
The check names in a list file, one per line; blank lines and # comments are skipped.

◆ main()

opencod2_smoke.main ( )

◆ parse_results()

opencod2_smoke.parse_results ( text)
{check name: passed} for every ok/FAIL line of smoke_test.py's output.

◆ smoke_args()

opencod2_smoke.smoke_args ( game_dir,
binary,
protocol,
stock )
smoke_test.py's command line: the 1.3 builds are OpenCoD2-Plus Server's Plus
variant (--plus) unless built with -DCOD2_PLUS_PROTOCOL=OFF (stock).

◆ strict_port()

opencod2_smoke.strict_port ( launcher,
game_dir )
net_strictPort 1 under wine: on a busy port the server fails to bind
it and tries no other (without net_strictPort it takes the next one). Its
fatal error goes to a message box, where it waits, not to its console
log, so it is ended here once the log shows the failed bind and nothing
after it.

◆ write_launcher()

opencod2_smoke.write_launcher ( directory,
wine,
exe )

Variable Documentation

◆ DEFAULT_BINARY

dict opencod2_smoke.DEFAULT_BINARY = {115: 'build/check-linux-10/cod2_lnxded', 118: 'build/check-linux/cod2_lnxded'}

◆ HEADER

str opencod2_smoke.HEADER = '# Fallos esperados de smoke_test.py con el servidor de opencod2; solo se achica.\n'

◆ LAUNCHER

str opencod2_smoke.LAUNCHER
Initial value:
1= r"""#!/bin/bash
2# runs {exe} under wine with smoke_test.py's arguments, the paths in
3# fs_basepath and fs_homepath as Windows sees them (drive Z: is /)
4args=()
5prev=
6for a in "$@"; do
7 if [ "$prev" = fs_basepath ] || [ "$prev" = fs_homepath ]; then
8 args+=("Z:$(realpath -m -- "$a" | tr / '\\')")
9 else
10 args+=("$a")
11 fi
12 prev=$a
13done
14# no debugger window for a crash
15export WINEDLLOVERRIDES=winedbg.exe=d
16exec {wine} {exe} "${{args[@]}}"
17"""

◆ RESULT

opencod2_smoke.RESULT = re.compile(r'^(ok |FAIL) (?P<name>.+?)( \‍(.*\‍))?$')

◆ ROOT

opencod2_smoke.ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

◆ WINE_HEADER

tuple opencod2_smoke.WINE_HEADER
Initial value:
1= ('# Fallos esperados de smoke_test.py con el servidor de Windows bajo wine; solo se achica.\n'
2 '# Bajo wine el servidor no recibe seƱales como tales, e imprime solo en su ventana.\n')