tests/fire: New; exercises fire command

Return fire not covered, yet.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2014-01-06 15:54:13 +01:00
parent 0f84c009bf
commit 4dd38ddfe5
12 changed files with 7391 additions and 0 deletions

View file

@ -258,9 +258,11 @@ check: all
ifeq ($(empthread),LWP)
$(srcdir)/tests/smoke-test $(srcdir)
$(srcdir)/tests/actofgod-test $(srcdir)
$(srcdir)/tests/fire-test $(srcdir)
else
@echo "$(srcdir)/tests/smoke-test SKIPPED"
@echo "$(srcdir)/tests/actofgod-test SKIPPED"
@echo "$(srcdir)/tests/fire-test SKIPPED"
endif

45
tests/fire-test Executable file
View file

@ -0,0 +1,45 @@
#!/bin/sh -e
# Gun fire test for Empire
if [ $# -ne 1 ]
then echo "Usage: $0 SRCDIR" >&2; exit 1
fi
srcdir="$1"
. "$srcdir"/tests/test-common.sh
#
# Currently expected to work only with thread package LWP, because:
#
# - Thread scheduling is reliably deterministic only with LWP
# - Shell builtin kill appears not to do the job in MinGW
# - The Windows server tries to run as service when -d isn't
# specified
#
# TODO address these shortcomings.
#
if [ `sed -n 's/empthread *:= *\(.*\)/\1/p' <GNUmakefile` != LWP ]
then echo "Warning: test not expected to work with this thread package!" >&2
fi
create_sandbox
cat >>sandbox/etc/empire/econfig <<EOF
WORLD_X 32
WORLD_Y 16
EASY_BRIDGES 1
GODNEWS 0
EOF
begin_test "$srcdir"/tests/fire/init_script
for i in `git ls-files "$srcdir"/tests/fire | grep '/[0-9][0-9]-.*$'`
do
c="${i##*/??-}"
r=`echo $c | sed 's/^POGO$/peter/'`
feed_input "$c" "$r" "$i"
done
end_test
cmp_out var/empire/server.log var/empire/journal.log fire.xdump

89
tests/fire/01-1 Normal file
View file

@ -0,0 +1,89 @@
||| fire sector
| sector must be fort with eff>5%, mil>5, gun>0, shell>0
|
|| assets
cens * ?shell>0
comm * ?shell>0
|
|| fort not firing
| nonexistant sector
fire se 1,0 6,0
| 100% highway
fire se -4,0 6,0
| 4% fort
fire se -2,0 6,0
| 5% fort
| at itself
fire se 0,0 0,0
| at sector that doesn't exist
fire se 0,0 1,0
| at ship that doesn't exist
fire se 0,0 666
| at valid target, but with insufficient mil
move m 0,0 1 nh
fire se 0,0 6,0
move m 1,1 1 yh
| likewise no guns
move g 0,0 1 nh
fire se 0,0 6,0
move g 1,1 1 yh
| likewise no shells
move s 0,0 1 nh
fire se 0,0 6,0
move s 1,1 1 yh
|
|| fort firing nowhere (shell consumed)
| 100% fort
| at sea out of range
fire se 4,0 -12,0
| at ship out of range
fire se 4,0 0
| at sub, server pretends out of range
fire se 4,0 13
| likewise in port
fire se 4,0 12
|
|| fort firing at bogus target
| 100% fort
| at sea, fractional range, ~50% chance
fire se 4,0 14,0
fire se 4,0 14,0
fire se 4,0 14,0
fire se 4,0 14,0
fire se 4,0 14,0
fire se 4,0 14,0
| at sanctuary
fire se 4,0 2,-2
|
|| fort firing at undefended target
| 5% fort with one gun
| 100% fort with one gun
| 100% fort with plenty of guns
| at own empty highway
move s 2,0 20 gh
fire se 0,0 -2,-2
fire se 2,0 -2,-2
fire se 4,0 -2,-2
| at bridge, one splash
fire se 0,0 4,2
fire se 2,0 4,2
fire se 4,0 1,3
| at harbor with stuff
fire se 0,0 2,2
fire se 2,0 2,2
fire se 4,0 2,2
| at own cs
fire se 0,0 9
| at cs at sea, one retreat, one sinking
fire se 0,0 23
fire se 2,0 23
fire se 4,0 23
fire se 4,0 21
| at cs in port, one retreat, one sinking
fire se 0,0 22
fire se 2,0 22
fire se 4,0 22
fire se 4,0 20
|
|| show shell use
comm * ?shell>0

7
tests/fire/02-POGO Normal file
View file

@ -0,0 +1,7 @@
xdump sect * ?own#0
xdump ship *
xdump plane *
xdump land *
xdump nuke *
xdump news *
edit c 1 b 640

100
tests/fire/03-1 Normal file
View file

@ -0,0 +1,100 @@
||| fire ship
| ship must have mil>0, glim>0, gun>0, shell>0, eff>=60
|
|| assets
ship * ?shell>0
carg * ?shell>0
|
|| ship not firing
| nonexistant ship
fire sh 666 6,0
| 100% cs
fire sh 9 6,0
| 59% bb
fire sh 1 6,0
| 60% bb, at itself
fire sh 2 2
| at sector that doesn't exist
fire sh 2 1,0
| at ship that doesn't exist
fire sh 2 666
| at valid target, but no mil
unload m 2 13
fire sh 2 6,0
load m 2 13
| likewise no guns
unload g 2 10
fire sh 2 6,0
load g 2 10
| likewise no shells
unload s 2 200
fire sh 2 6,0
load s 2 200
|
|| ship firing nowhere (shells consumed)
| 100% bb
| at sea out of range
fire sh 3 -12,0
| at ship out of range
fire sh 3 0
| at sub, server pretends out of range
fire sh 3 13
| likewise in port
fire sh 3 12
|
|| ship firing at bogus target
| 100% bb
| at sea
fire sh 3 6,0
| at sanctuary
fire sh 3 2,-2
|
|| ship firing at undefended target
| 100% bb with 1, 2, 3 guns
| at empty highway
unload g 3 -1
fire sh 3 0,2
load g 3 1
fire sh 3 0,2
load g 3 1
fire sh 3 0,2
load g 3 7
| likewise 1, 2 shell (take care to avoid automatic supply)
unload s 3 -1
navi 3 jh
fire sh 3 0,2
navi 3 gh
load s 3 2
navi 3 jh
fire sh 3 0,2
navi 3 gh
load s 3 169
| likewise 1, 2, 3 mil
unload m 3 -1
fire sh 3 0,2
load m 3 1
fire sh 3 0,2
load m 3 1
fire sh 3 0,2
load m 3 10
| 60% bb
fire sh 2 0,2
| 100% bb
fire sh 3 0,2
| 100% dd
| at sub, two retreat, two sink
fire sh 5 13
fire sh 6 12
fire sh 5 11
fire sh 6 10
| at ship, fractional range, ~50% chance
navi 5 jh
fire sh 5 24
fire sh 5 24
fire sh 5 24
fire sh 5 24
fire sh 5 24
fire sh 5 24
|
|| show shell use
carg * ?shell>0

7
tests/fire/04-POGO Normal file
View file

@ -0,0 +1,7 @@
xdump sect * ?own#0
xdump ship *
xdump plane *
xdump land *
xdump nuke *
xdump news *
edit c 1 b 640

87
tests/fire/05-1 Normal file
View file

@ -0,0 +1,87 @@
||| fire land
| land must have mil>0, glim>0, gun>0, shell>0, eff>=40, and not on carrier
|
|| assets
land * ?shell>0
lcarg * ?shell>0
|
|| land not firing
| nonexistant land
fire la 666 6,0
| 100% tra
fire la 9 6,0
| 39% hat
fire la 1 6,0
| 40% hat, at itself
fire la 2 3,1
| at sector that doesn't exist
fire la 2 1,0
| at ship that doesn't exist
fire la 2 666
| at valid target, but no mil
lunload m 2 10
fire la 2 6,0
lload m 2 10
| likewise no guns
lunload g 2 12
fire la 2 6,0
lload g 2 12
| likewise no shells
lunload s 2 80
fire la 2 6,0
lload s 2 80
| likewise on ship
load land 9 2
fire la 2 6,0
unload land 9 2
| likewise on land
lload land 9 2
fire la 2 6,0
lunload land 9 2
|
|| land firing nowhere (shells consumed)
| 100% hat
| at sea out of range
fire la 3 -12,0
| at ship out of range
fire la 3 0
| at sub, server pretends out of range
fire la 3 13
| likewise in port
fire la 3 12
|
|| land firing at bogus target
| 100% hat
| at sea
fire la 3 6,0
| at sanctuary
fire la 3 2,-2
|
|| land firing at undefended target
| 100% hat with one gun
| at empty highway
lunload g 3 -1
fire la 3 0,2
lload g 3 11
| likewise one shell (take care to avoid automatic supply)
lunload s 3 -1
march 3 gh
fire la 3 0,2
march 3 jh
lload s 3 51
| 40% hat
fire la 2 0,2
| 100% hat
fire la 3 0,2
| 100% hat
| at sector, fractional range, ~50% chance
march 3 yyyh
fire la 3 0,2
fire la 3 0,2
fire la 3 0,2
fire la 3 0,2
fire la 3 0,2
fire la 3 0,2
|
|| show shell use
lcarg * ?shell>0

5
tests/fire/99-POGO Normal file
View file

@ -0,0 +1,5 @@
read 0
read 1
read 2
read 3
read 98

5578
tests/fire/fire.xdump Normal file

File diff suppressed because it is too large Load diff

119
tests/fire/init_script Normal file
View file

@ -0,0 +1,119 @@
|| pre-extend unit files
edit c 0 T 400
add 98 98 98 g
des 0,0 h
give m 0,0 100
edit l 0,0 o 98 O 98 a 9999
give l 0,0 9999
give h 0,0 9999
give o 0,0 9999
give r 0,0 9999
build s 0,0 frg
edit s 0 O 0 T 0
des 0,0 *
build p 0,0 f1
edit p 0 O 0 t 0
des 0,0 !
build l 0,0 cav
edit u 0 O 0 t 0
des 0,0 n
build n 0,0 10kt
edit n 0 O 0 t 0
edit l 2,0 L 0,0
|
|| an island
des @0,0:2 +
edit l 4,2 e 100 s = S =
edit l 1,3 e 20 s = S =
give c * ?des#. 100
|| country#1
add 1 1 1 p
des -2:4,0 f
des 1,-1 c
des 3,1 h
edit l * ?des#. o 1 O 1
give m -4:4,0 5
give g -4:4,0 1
give s -4:4,0 1
edit l -2,0 e 4
edit l 0,0 e 5
give g 4,0 6
give s 2:4,0 99
edit c 1 c 1,-1 s 4 b 640 M 25000 T 100
|| country#2
| target harbor, highways, a strong bridge, a weak bridge
des 2,2 h
add 2 2 2 p
edit l -2:4,2:3 ?des#. o 2 O 2
give l * ?own=2 100
give h * ?own=2 100
edit l * ?own=2 a 100 R 100 r 100 d 100
| make country active, so it gets bulletins
edit c 2 s 4 b 640 M 25000 T 100
|| country#3
| just a sanctuary @ 2,-2
des 2,-2 s
add 3 3 3 p
edit c 3 c 2,-2 b 640 M 25000
|| finishing touches to land
edit l * ?des#.&eff=0 e 100
edit l * ?des#.&des#h m 127
| note: no mob in harbor to avoid unwanted supply
|| relations
decl w 1 2
decl w 2 1
|| target ships
| frg far away
edit s 0 t frg L -12,0 O 2
| sub at sea and in port
edit s 10 t sb L 2,2 O 2 U 11 L 6,0
edit s 10 U 12 m 5 E 100 M 127 U 13 L 6,0
| cs at sea and in port
edit s 20 t cs L 2,2 O 2 l 100 h 100 U 21 L 6,0
edit s 20 U 22 m 5 E 100 M 127 U 23 L 6,0 U 24
retreat 11/13/23 j idh
retreat 10/12/22 n dh
|| target lands
| spy in target harbor
edit u 0 T spy L 2,2 O 2 e 100 M 127
| spy on target subs
edit u 0 U 10 S 10 U 11 S 11 U 12 S 12 U 13 S 13
| rad on target cs
edit u 20 T rad O 2 e 100 M 127 m 10 S 20 U 21 S 21 U 22 S 22 U 23 S 23
| train on weak target bridge
edit u 30 T tra L 1,3 O 2 e 100 m 10 l 100 h 100 M 127 U 32 L 2,2
| tra in target harbor
edit u 31 T rad O 2 e 100 M 127 m 10 Y 30 U 33 Y 32
|| target planes
| sam & jhb in target harbor, jhb ob weak target bridge
edit p 0 T sam l 2,2 O 2 e 100 m 127
edit p 1 T jhb l 2,2 O 2 e 100 m 127 U 2 l 1,3
| sam in target cs and rad
edit p 0 U 20 s 20 U 21 s 21 U 22 s 22 U 23 s 23
edit p 0 U 30 y 30 U 31 y 31 U 32 y 32 U 33 y 33
|| target nukes in target harbor and on target jhb
edit n 0 t 10kt L 2,2 O 2 U 1 p 1 U 2 p 2
|| firing ships
| bb range >=3, 59% 60% 100%
edit s 1 t bb T 150 L 3,1 O 1 E 59 M 127 m 13 g 10 s 200 U 2 E 60 U 3 E 100
| cs
edit s 9 t cs L 3,1 O 1 E 100 M 127 m 10 g 10 s 10
| dd range 1.5
edit s 5 t dd T 100 L 8,0 O 1 E 100 M 127 m 5 g 4 s 40
edit s 5 U 6 L 3,3
|| firing lands
| hat range 3.5 39% 40% 100%
edit u 1 T hat t 160 L 3,1 O 1 e 39 M 127 m 10 g 12 s 80 U 2 e 40 U 3 e 100
| tra
edit u 9 T tra L 3,1 O 1 e 100 m 10 g 10 s 10
| note: no mob in train to avoid unwanted supply
|| show initial state here to help maintainers
map *
cens * ?own#0
comm * ?own#0
ship *
carg *
land *
lcar *
plan *
nuke *

1320
tests/fire/journal.log Normal file

File diff suppressed because it is too large Load diff

32
tests/fire/server.log Normal file
View file

@ -0,0 +1,32 @@
------------------------------------------------------
Empire server (pid 42) started
Update schedule read
No update scheduled
Listening on 127.0.0.1
Connect from 127.0.0.1
Connect from 127.0.0.1
tester@127.0.0.1 using country #1
tester@127.0.0.1 logged in as country #1
tester@127.0.0.1 logged out, country #1
Connect from 127.0.0.1
tester@127.0.0.1 using country #0
tester@127.0.0.1 logged in as country #0
tester@127.0.0.1 logged out, country #0
Connect from 127.0.0.1
tester@127.0.0.1 using country #1
tester@127.0.0.1 logged in as country #1
tester@127.0.0.1 logged out, country #1
Connect from 127.0.0.1
tester@127.0.0.1 using country #0
tester@127.0.0.1 logged in as country #0
tester@127.0.0.1 logged out, country #0
Connect from 127.0.0.1
tester@127.0.0.1 using country #1
tester@127.0.0.1 logged in as country #1
tester@127.0.0.1 logged out, country #1
Connect from 127.0.0.1
tester@127.0.0.1 using country #0
tester@127.0.0.1 logged in as country #0
tester@127.0.0.1 logged out, country #0
Shutdown commencing (cleaning up threads.)
Server shutting down on signal 15