tests: Use only files known to git

Filename expansion can pick up junk files.  Use git-ls-files instead.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
tests: New helper function feed_input, for comment support

feed_input drops lines starting with a bar character '|', so they can
serve as comments.  Syntax chosen because such lines shouldn't be
needed in tests.  In particular, the server already ignores such lines
when it reads commands, because they get parsed as empty command with
a pipeline, and empty commands get ignored, regardless of
redirections.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
tests: Document log file normalization a bit better

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
commands: Trim obvious silly trailing space from output

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
edit: Trim unwanted trailing space from output

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
resource: Trim unwanted trailing space from output

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
maps: Trim unwanted trailing space from map decoration

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
tests: Normalize trailing white space away in test output

We don't really care for it there, and git's pre-commit hook flags it,
which is annoying.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Trim trailing white space from source code

Normally, git's pre-commit hook protects us from them.  However, when
expected test output contains trailing white space, we have to bypass
commit hooks.  Unwanted space can then slip in if you don't pay
attention.  I obviously didn't; clean up.

The previous commit should reduce the need for such hook suppression.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
order: Trim trailing space from usage string

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
info/show: Update example to current output

White space change only, actually.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
info: Nicer remaking of info subject index pages

Give quiet-command a more useful last argument.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
tests: Make helper begin_test accept any number of arguments

Zero arguments mean "read the script from stdin", so you can write
begin_test <<EOF...

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
info/toc: New; generated machine-readable table of contents

Next commit will put it to use.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
tests/info: New; checks info and code agree on commands

Replaces info/checklist.pl, which has been broken since
commit 56d9445, v4.3.0.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
accept: Resize thread stack to avoid stack smash for small worlds

I observed a stack overflow in news command on my x86_64 system
running Fedora 18.

Empire 2 settled on this formula for the stack size:

	    stacksize = 100000
    /* budget */  + MAX(WORLD_SZ() * sizeof(int) * 7,
    /* power */ MAXNOC * sizeof(struct powstr));

Obviously attempts to provide space for known configuration-dependent
stack hogs.

The first hog is allegedly budget.  Bogus since day one: its large
arrays were static in Empire 2, and became dynamically allocated in
Empire 3.

The second one makes some sense: powe() has a struct powstr[MAXNOC].
It also has an int[MAXNOC], which isn't accounted for.

Except for ridiculously small worlds, the second term is smaller, and
only the (bogus) first term matters.

Two hogs are missing: head() has a struct histstr[MAXNOC][MAXNOC], and
news() has a short[MAXNOC][MAXNOC].  It also calls head().

I looked for more hogs with "gcc -fstack-usage", and found none.

On my x86_64 system, a news command needs almost 107KiB of stack.
Only slightly less when compiled for 32 bit.  Stack overrun for worlds
with fewer than some 320 sectors, thus unlikely to bite in real games.

Increase player stack size to 1 MiB.  Using MAXNOC to size the stack
isn't worth the trouble.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
update: Set thread stack size to 512 KiB

Empire 2 settled on this formula for the stack size:

	stacksize = 100000 +
    /* finish_sects */ WORLD_X * WORLD_Y * (2 * sizeof(double) +
					    sizeof(char *));

Obviously attempts to provide space for a known configuration-
dependent stack hog.  The hog went away when finish_sects()'s arrays
became dynamically allocated in 4.2.0.

Adjusting for that by dropping the extra term might well do (I observe
only a few KiB of stack used on my system).  But let's set it to 512
KiB instead to be on the safe side.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
tests/fire: New; exercises fire command

Return fire not covered, yet.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>