tests/build: New; exercises build command
drnuke_const is not covered, yet. Random rounding causes some complications: sometimes build succeeds without materials. Troublesome spots are clearly marked in the test input. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
370b9d1c07
commit
cdfcc1a165
15 changed files with 7068 additions and 0 deletions
2
Make.mk
2
Make.mk
|
@ -261,10 +261,12 @@ _check: all
|
|||
ifeq ($(empthread),LWP)
|
||||
$(srcdir)/tests/smoke-test $(srcdir)
|
||||
$(srcdir)/tests/actofgod-test $(srcdir)
|
||||
$(srcdir)/tests/build-test $(srcdir)
|
||||
$(srcdir)/tests/fire-test $(srcdir)
|
||||
else
|
||||
@echo "$(srcdir)/tests/smoke-test SKIPPED"
|
||||
@echo "$(srcdir)/tests/actofgod-test SKIPPED"
|
||||
@echo "$(srcdir)/tests/build-test SKIPPED"
|
||||
@echo "$(srcdir)/tests/fire-test SKIPPED"
|
||||
endif
|
||||
|
||||
|
|
32
tests/build-test
Executable file
32
tests/build-test
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh -e
|
||||
# Build test for Empire
|
||||
|
||||
if [ $# -ne 1 ]
|
||||
then echo "Usage: $0 SRCDIR" >&2; exit 1
|
||||
fi
|
||||
|
||||
srcdir="$1"
|
||||
|
||||
. "$srcdir"/tests/test-common.sh
|
||||
|
||||
create_sandbox
|
||||
cat >>sandbox/etc/empire/econfig <<EOF
|
||||
WORLD_X 20
|
||||
WORLD_Y 12
|
||||
BRIDGETOWERS 1
|
||||
EOF
|
||||
# TODO cover drnuke_const 0.33
|
||||
|
||||
begin_test "$srcdir"/tests/build/setup-POGO
|
||||
feed_dir "$srcdir"/tests/build/units
|
||||
feed_dir "$srcdir"/tests/build/bridges-1
|
||||
stop_server
|
||||
cat >>sandbox/etc/empire/econfig <<EOF
|
||||
EASY_BRIDGES 0
|
||||
BRIDGETOWERS 0
|
||||
EOF
|
||||
start_server
|
||||
feed_dir "$srcdir"/tests/build/bridges-2
|
||||
end_test
|
||||
|
||||
cmp_out var/empire/server.log var/empire/journal.log final.xdump
|
33
tests/build/bridges-1/01-bridges-5
Normal file
33
tests/build/bridges-1/01-bridges-5
Normal file
|
@ -0,0 +1,33 @@
|
|||
|| bridge towers, BRIDGETOWERS on
|
||||
| insufficient tech
|
||||
build t -4,4 b
|
||||
|| bridge spans, EASY_BRIDGES on
|
||||
| no materials, inefficient
|
||||
build b 4:6,4 n
|
||||
| insufficient materials: short 1h
|
||||
move h 0,4 99 ggh
|
||||
build b -4,4 n
|
||||
| invalid direction
|
||||
move h 0,4 201 ggh
|
||||
move h 0,4 200 jjh
|
||||
build b -4,4 @
|
||||
| not sea
|
||||
build b -4,4 j
|
||||
| not next to land
|
||||
build b -4,4 b
|
||||
| success to tower
|
||||
build b
|
||||
-4,4
|
||||
g
|
||||
| success to land
|
||||
build b -4,4 n
|
||||
| -4,4 not enough avail, 4,4 success
|
||||
cens -4:4,4 ?des#w&hcm>0
|
||||
build b -4:4,4 ?des#c&des#w b
|
||||
| not enough money
|
||||
build b 4,4 n
|
||||
|| show results
|
||||
cens * ?des=#
|
||||
comm * ?des=#
|
||||
cens * ?des=@
|
||||
comm * ?des=@
|
3
tests/build/bridges-1/02-bridges-6
Normal file
3
tests/build/bridges-1/02-bridges-6
Normal file
|
@ -0,0 +1,3 @@
|
|||
|| bridge spans
|
||||
| insufficient tech
|
||||
build b 1,-1 g
|
28
tests/build/bridges-1/03-towers-9
Normal file
28
tests/build/bridges-1/03-towers-9
Normal file
|
@ -0,0 +1,28 @@
|
|||
|| bridge towers, BRIDGETOWERS on
|
||||
| not a bridge span, no materials, inefficient
|
||||
build t 0,-4 u
|
||||
build t -9:-8,-5:-4 b
|
||||
| insufficient materials: short 1h
|
||||
move h 0,-4 299 gyggbh
|
||||
build t -8,-4 g
|
||||
| invalid direction
|
||||
move h 0,-4 601 gyggbh
|
||||
move h 0,-4 600 gygbh
|
||||
build t -8,-4 @
|
||||
| not sea
|
||||
build t -8,-4 u
|
||||
| adjacent to land
|
||||
build t -6,-4 j
|
||||
| success
|
||||
build t
|
||||
-8,-4
|
||||
g
|
||||
| success
|
||||
build t -8,-4 b
|
||||
| -8,-4 not enough avail, -6,-4 success
|
||||
build t -8:-6,-4 n
|
||||
| not enough money
|
||||
build t -6,-4 b
|
||||
|| show results
|
||||
cens * ?des==
|
||||
comm * ?des==
|
33
tests/build/bridges-2/01-bridges-7
Normal file
33
tests/build/bridges-2/01-bridges-7
Normal file
|
@ -0,0 +1,33 @@
|
|||
|| bridge towers, BRIDGETOWERS off
|
||||
build t -4,-2 u
|
||||
|| bridge spans, EASY_BRIDGES off
|
||||
| not a bridge head, no materials, inefficient
|
||||
build b 0,-2 u
|
||||
build b 4:6,-2 u
|
||||
| insufficient materials: short 1h
|
||||
move h 0,-2 99 jh
|
||||
build b 2,-2 u
|
||||
| invalid direction
|
||||
move h 0,-2 201 jh
|
||||
move h 0,-2 200 jjh
|
||||
build b 2,-2 @
|
||||
| not sea
|
||||
build b 2,-2 g
|
||||
| success
|
||||
build b
|
||||
2,-2
|
||||
y
|
||||
| success
|
||||
build b 2,-2 n
|
||||
| success from tower
|
||||
build b -6,-2 b
|
||||
| 2,-2 not enough avail, 4,-2 success
|
||||
build b 2:4,-2
|
||||
n
|
||||
| not enough money
|
||||
build b 4,-2 n
|
||||
|| show results
|
||||
cens * ?des=#
|
||||
comm * ?des=#
|
||||
cens * ?des=@
|
||||
comm * ?des=@
|
1
tests/build/bridges-2/99-POGO
Normal file
1
tests/build/bridges-2/99-POGO
Normal file
|
@ -0,0 +1 @@
|
|||
cens * ?own=0&des#.
|
5409
tests/build/final.xdump
Normal file
5409
tests/build/final.xdump
Normal file
File diff suppressed because it is too large
Load diff
1211
tests/build/journal.log
Normal file
1211
tests/build/journal.log
Normal file
File diff suppressed because it is too large
Load diff
54
tests/build/server.log
Normal file
54
tests/build/server.log
Normal file
|
@ -0,0 +1,54 @@
|
|||
------------------------------------------------------
|
||||
Empire server (pid 42) started
|
||||
Configured for testing
|
||||
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 #2
|
||||
tester@127.0.0.1 logged in as country #2
|
||||
tester@127.0.0.1 logged out, country #2
|
||||
Connect from 127.0.0.1
|
||||
tester@127.0.0.1 using country #3
|
||||
tester@127.0.0.1 logged in as country #3
|
||||
tester@127.0.0.1 logged out, country #3
|
||||
Connect from 127.0.0.1
|
||||
tester@127.0.0.1 using country #4
|
||||
tester@127.0.0.1 logged in as country #4
|
||||
tester@127.0.0.1 logged out, country #4
|
||||
Connect from 127.0.0.1
|
||||
tester@127.0.0.1 using country #5
|
||||
tester@127.0.0.1 logged in as country #5
|
||||
tester@127.0.0.1 logged out, country #5
|
||||
Connect from 127.0.0.1
|
||||
tester@127.0.0.1 using country #6
|
||||
tester@127.0.0.1 logged in as country #6
|
||||
tester@127.0.0.1 logged out, country #6
|
||||
Connect from 127.0.0.1
|
||||
tester@127.0.0.1 using country #9
|
||||
tester@127.0.0.1 logged in as country #9
|
||||
tester@127.0.0.1 logged out, country #9
|
||||
Shutdown commencing (cleaning up threads.)
|
||||
Server shutting down on signal 15
|
||||
------------------------------------------------------
|
||||
Empire server (pid 42) started
|
||||
Configured for testing
|
||||
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 #7
|
||||
tester@127.0.0.1 logged in as country #7
|
||||
tester@127.0.0.1 logged out, country #7
|
||||
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
|
91
tests/build/setup-POGO
Normal file
91
tests/build/setup-POGO
Normal file
|
@ -0,0 +1,91 @@
|
|||
|| sectors
|
||||
des -3:-2,-2:4 c
|
||||
des -1:0,-2:4 w
|
||||
des 7,3 w
|
||||
edit l -8,4 e 100 s @ S @
|
||||
des -2,-4 c
|
||||
des 0,-4 w
|
||||
des -3,-5 #
|
||||
edit l -5,-5 e 100 s = S =
|
||||
edit l -7,-5 e 100 s @ S @
|
||||
give l * ?des=w 2000
|
||||
give h * ?des=w 2000
|
||||
give m * ?des=w 90
|
||||
give o * ?des=w 900
|
||||
give r * ?des=w 900
|
||||
| building sectors 100% 60% 59%
|
||||
des 2:6,0 h
|
||||
des 1:5,1 *
|
||||
des 2:6,2 !
|
||||
des 1:5,3 n
|
||||
des 2:6,4 -
|
||||
edit l -4,4 e 100 s = S =
|
||||
des 2:6,-2 #
|
||||
edit l -4,-2 e 100 s = S =
|
||||
edit l -6,-2 e 100 s @ S @
|
||||
give h -6,-2 100
|
||||
edit l -8,-4 e 100 s = S =
|
||||
edit l -6,-4 e 60 s = S =
|
||||
edit l -9,-5 e 59 s = S =
|
||||
edit l 3:4,-2:4 ?des#. e 60
|
||||
edit l 5:6,-2:4 ?des#. e 59
|
||||
edit l * ?des#.&eff=0 e 100
|
||||
edit l * ?des#. m 127
|
||||
| avail for 2 pt in h, 2 f2 in *, 2 linf in !, 2 10kt in n
|
||||
edit l * ?des=h a 35
|
||||
edit l * ?des=* a 11
|
||||
edit l * ?des=! a 11
|
||||
edit l * ?des=n a 146
|
||||
| avail for 2 = or 2 @ in bridge heads
|
||||
edit l * ?des=# a 119
|
||||
edit l * ?des=- a 119
|
||||
edit l * ?des== a 119
|
||||
edit l * ?des=@ a 119
|
||||
edit l * ?des==&yloc<0 a 359
|
||||
edit l 1,-1 a 119
|
||||
| plenty of materials in 59%ers
|
||||
give l * ?eff=59 500
|
||||
give h * ?eff=59 500
|
||||
give m * ?eff=59 50
|
||||
give o * ?eff=59 500
|
||||
give r * ?eff=59 500
|
||||
| populate
|
||||
give c * ?des#. 100
|
||||
|| country#1: builds ships, has money for 3 pt
|
||||
add 1 1 1 p
|
||||
edit c 1 c -2,0 s 4 b 640 M 239 T 100
|
||||
edit l -2:6,0 o 1 O 1
|
||||
|| country#2: builds planes, has money for 3 f2
|
||||
add 2 2 2 p
|
||||
edit c 2 c -3,1 s 4 b 640 M 159 T 100
|
||||
edit l -3:5,1 o 2 O 2
|
||||
|| country#3: builds lands, has money for 3 linf
|
||||
add 3 3 3 p
|
||||
edit c 3 c -2,2 s 4 b 640 M 119 T 100
|
||||
edit l -2:6,2 o 3 O 3
|
||||
|| country#4: builds nukes, has money for 3 10kt
|
||||
add 4 4 4 p
|
||||
edit c 4 c -3,3 s 4 b 640 M 39999 T 300
|
||||
edit l -3:7,3 o 4 O 4
|
||||
|| country#5: builds EASY_BRIDGES bridge spans, has money for 3
|
||||
| also tries a tower with insufficient tech
|
||||
add 5 5 5 p
|
||||
edit c 5 c -2,4 s 4 b 640 M 3999 T 99
|
||||
edit l -8:6,4 ?des#. o 5 O 5
|
||||
|| country#6: tries to build bridge spans, but has no tech
|
||||
add 6 6 6 p
|
||||
edit c 6 c -3,-1 s 4 b 640 M 10000 T 9
|
||||
edit l -3:-1,-1 o 6 O 6
|
||||
|| country#7: builds !EASY_BRIDGES bridge spans, has money for 4
|
||||
| also tries a tower with !BRIDGETOWERS
|
||||
add 7 7 7 p
|
||||
edit c 7 c -2,-2 s 4 b 640 M 4999 T 100
|
||||
edit l -6:6,-2 o 7 O 7
|
||||
|| country#9: builds bridge towers, has money for 3
|
||||
add 9 9 9 p
|
||||
edit c 9 c -2,-4 s 4 b 640 M 11999 T 100
|
||||
edit l -9:0,-5:-4 ?des#. o 9 O 9
|
||||
|| show initial state here to help maintainers
|
||||
cens * ?des#.
|
||||
comm * ?des#.
|
||||
map *
|
39
tests/build/units/01-ships-1
Normal file
39
tests/build/units/01-ships-1
Normal file
|
@ -0,0 +1,39 @@
|
|||
|| invalid
|
||||
build
|
||||
@
|
||||
|| ships
|
||||
| invalid type
|
||||
build s 0,0 @
|
||||
| insufficient tech
|
||||
build s 0,0 nuc
|
||||
| too many
|
||||
build s 0,0 pt 21
|
||||
n
|
||||
| pt needs 4l/2h/12av/$60, tech 40
|
||||
| asking for too high and too low tech
|
||||
build s 0,0 pt 1 101
|
||||
build s 0,0 pt 1 39
|
||||
| not a harbor, no materials, inefficient
|
||||
build s 0,0 pt
|
||||
build s 4:6,0 pt
|
||||
| insufficient materials: 2,0 short 1h, 4,0 short 1l
|
||||
move l 0,0 4 jh
|
||||
move h 0,0 1 jh
|
||||
move l 0,0 3 jjh
|
||||
move h 0,0 2 jjh
|
||||
build s 2:4,0 pt
|
||||
| build until out of avail/money
|
||||
| sectors can build 2 each, but out of money after 3 total
|
||||
move l 0,0 12 jh
|
||||
move h 0,0 7 jh
|
||||
move l 0,0 13 jjh
|
||||
move h 0,0 6 jjh
|
||||
build s
|
||||
2,0
|
||||
pt
|
||||
build s 2,0 pt
|
||||
build s 2:4,0 pt 21 90 y
|
||||
|| show results
|
||||
ship *
|
||||
cens * ?des=h
|
||||
comm * ?des=h
|
42
tests/build/units/02-planes-2
Normal file
42
tests/build/units/02-planes-2
Normal file
|
@ -0,0 +1,42 @@
|
|||
|| planes
|
||||
| invalid type
|
||||
build p -1,1 @
|
||||
| insufficient tech
|
||||
build p -1,1 sf
|
||||
| too many
|
||||
build p -1,1 f2 21
|
||||
n
|
||||
| f2 needs 0.8l/0.2h/1m/4av/$40, tech 80
|
||||
| asking for too high and too low tech
|
||||
build p -1,1 f2 1 101
|
||||
build p -1,1 f2 1 79
|
||||
| not an airfield, no materials, inefficient
|
||||
build p -1,1 f2
|
||||
| Note: fractional cms are randomly rounded, which can make build
|
||||
| succeed, upsetting the rest of the test
|
||||
build p 3:5,1 f2
|
||||
| insufficient materials: 1,1 short 1l/1h, 3,1 short 1m
|
||||
| Note: fractional cms are randomly rounded, which can make build
|
||||
| succeed in 1,1, upsetting the rest of the test
|
||||
move m -1,1 1 jh
|
||||
move l -1,1 1 jjh
|
||||
move h -1,1 1 jjh
|
||||
build p 1:3,1 f2
|
||||
| build until out of avail/money
|
||||
| sectors can build 2 each, but out of money after 3 total
|
||||
move m -1,1 3 jh
|
||||
move l -1,1 4 jh
|
||||
move h -1,1 4 jh
|
||||
move m -1,1 4 jjh
|
||||
move l -1,1 3 jjh
|
||||
move h -1,1 3 jjh
|
||||
build
|
||||
p
|
||||
1,1
|
||||
f2
|
||||
build p 1,1 f2
|
||||
build p 1:3,1 f2 3 90
|
||||
|| show results
|
||||
plan *
|
||||
cens * ?des=*
|
||||
comm * ?des=*
|
39
tests/build/units/03-lands-3
Normal file
39
tests/build/units/03-lands-3
Normal file
|
@ -0,0 +1,39 @@
|
|||
|| land units
|
||||
| invalid type
|
||||
build l 0,2 @
|
||||
| insufficient tech
|
||||
build l 0,2 rad
|
||||
| too many
|
||||
build l 0,2 linf 21
|
||||
n
|
||||
| linf needs 0.8l/0.4h/4av/$30, tech 40
|
||||
| asking for too high and too low tech
|
||||
build l 0,2 linf 1 101
|
||||
build l 0,2 linf 1 39
|
||||
| not an headquarters, no materials, inefficient
|
||||
| Note: fractional cms are randomly rounded, which can make build
|
||||
| succeed in 4,2, upsetting the rest of the test
|
||||
build l 0,2 linf
|
||||
build l 4:6,2 linf
|
||||
| insufficient materials: 2,2 short 1l, 4,2 short 1h
|
||||
| Note: fractional cms are randomly rounded, which can make build
|
||||
| succeed in either sector, upsetting the rest of the test
|
||||
move l 0,2 1 jjh
|
||||
move h 0,2 1 jh
|
||||
build l 2:4,2 linf
|
||||
| build until out of avail/money
|
||||
| sectors can build 2 each, but out of money after 3 total
|
||||
move l 0,2 4 jh
|
||||
move h 0,2 3 jh
|
||||
move l 0,2 3 jjh
|
||||
move h 0,2 4 jjh
|
||||
build
|
||||
l
|
||||
2,2
|
||||
linf
|
||||
build l 2,2 linf
|
||||
build l 2:4,2 linf 3 90
|
||||
|| show results
|
||||
land *
|
||||
cens * ?des=!
|
||||
comm * ?des=!
|
51
tests/build/units/04-nukes-4
Normal file
51
tests/build/units/04-nukes-4
Normal file
|
@ -0,0 +1,51 @@
|
|||
|| nukes
|
||||
| invalid type
|
||||
build n -1,3 @
|
||||
| insufficient tech
|
||||
build n -1,3 5mt
|
||||
| too many
|
||||
build n -1,3 10kt 21
|
||||
n
|
||||
| 10kt needs 50l/50h/25o/70r/10k$, tech 80
|
||||
| asking for too high and too low tech
|
||||
build n -1,3 10kt 1 301
|
||||
build n -1,3 10kt 1 279
|
||||
| not an nuclear plan, no materials, inefficient
|
||||
build n -1,3 10kt
|
||||
build n 3:5,3 10kt
|
||||
| insufficient materials: 1,3 short 1l, 3,3 short 1h
|
||||
move l -1,3 49 jh
|
||||
move l -1,3 50 jjh
|
||||
move h -1,3 50 jh
|
||||
move h -1,3 49 jjh
|
||||
move o -1,3 25 jh
|
||||
move o -1,3 25 jjh
|
||||
move r -1,3 70 jh
|
||||
move r -1,3 70 jjh
|
||||
build n 1:3,3 10kt
|
||||
| insufficient materials: 1,3 short 1o, 3,3 short 1r
|
||||
move l -1,3 1 jh
|
||||
move h -1,3 1 jjh
|
||||
move o 1,3 1 gh
|
||||
move r 3,3 1 ggh
|
||||
build n 1:3,3 10kt
|
||||
| build until out of avail/money
|
||||
| sectors can build 2 each, but out of money after 3 total
|
||||
move l -1,3 100 jh
|
||||
move l -1,3 100 jjh
|
||||
move h -1,3 100 jh
|
||||
move h -1,3 100 jjh
|
||||
move o -1,3 51 jh
|
||||
move o -1,3 50 jjh
|
||||
move r -1,3 140 jh
|
||||
move r 7,3 141 ggh
|
||||
build
|
||||
n
|
||||
1,3
|
||||
10kt
|
||||
build n 1,3 10kt
|
||||
build n 1:3,3 10kt 3 290
|
||||
|| show results
|
||||
nuke *
|
||||
cens * ?des=n
|
||||
comm * ?des=n
|
Loading…
Add table
Add a link
Reference in a new issue