summaryrefslogtreecommitdiff
path: root/sim/src/regression.sh
blob: 7e045ddb197a3875606c85785e5a10a7bf89ae29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
# Copyright 2005-2006 Nanorex, Inc.  See LICENSE file for details. 

# run regression tests
#
# how to make a regression test:
#
# Inside one of the directories listed below, you need to create three files.
# I'm going to call them test_000X.* here.  Just number them sequentially
# although that doesn't really matter.
#
# The first file is the input data file for the test run.  It will
# usually be called test_000X.mmp.  If it's called something else, or
# there are more than one of them (or zero of them), you can specify
# that using the INPUT directive in the .test file.
#
# The second file is the test description file: test_000X.test.
# This file describes the inputs, outputs, and program arguments
# for the test.  The default values should be fine for minimizer tests.
# For dynamics runs you'll need to specify the program arguments:
#
# PROGRAM simulator -f900 -x test_000X.mmp
#
# See runtest.sh for a complete description.
#
# The third file is the expected output.  Generate this using
# runtest.sh like this (in the test directory):
#
# ../../runtest.sh test_000X.test > test_000X.out
#
# You can change the list of output files to be included
# using the OUTPUT directive in the .test file.
#
# Check this file to make sure the output looks reasonable, then
# rerun regression.sh before checking in the test_000X.* files.

TESTDIRS="tests/minimize tests/dynamics tests/rigid_organics"

RET=0
GEN=0
if [ "x$1" = "x--generate" ]; then
    GEN=1
fi

rm -f /tmp/testsimulator
ln -s $PWD/simulator /tmp/testsimulator

for dir in $TESTDIRS; do
    for i in $dir/*.test; do
	echo Running $i
	base=`basename $i .test`
	out=$dir/$base.out
	./runtest.sh $i > $out.new
	if [ ! -f $out -a $GEN -ne 0 ]; then
	    echo Generated new $out
	    cp $out.new $out
	fi
	if cmp -s $out $out.new ; then
	    rm $out.new
	else
	    echo Test failed: $i 1>&2
	    diff $out $out.new > $out.diff
	    RET=1
	fi
    done
done

rm -f /tmp/testsimulator

exit $RET