diff options
author | Adrian Thurston <thurston@colm.net> | 2019-12-20 07:39:42 +0200 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2019-12-20 07:39:42 +0200 |
commit | 4349c06704d77832ce23df5806ac3110a97d875b (patch) | |
tree | a454f8e4c1c72f8356a12b27343c8165538d2811 | |
parent | a60a18880ecd3549aaafbb199abb6d159a4941a1 (diff) | |
download | colm-4349c06704d77832ce23df5806ac3110a97d875b.tar.gz |
testing: merged runtests and timed, removed system variation from some tests
-rw-r--r-- | test/aapl.d/test_bsttable.cpp | 7 | ||||
-rw-r--r-- | test/aapl.d/test_bsttable.exp | 4 | ||||
-rw-r--r-- | test/aapl.d/test_sbsttable.cpp | 7 | ||||
-rw-r--r-- | test/aapl.d/test_sbsttable.exp | 4 | ||||
-rw-r--r-- | test/ragel.d/nfa1.rl | 12 | ||||
-rw-r--r-- | test/ragel.d/nfa2.rl | 12 | ||||
-rwxr-xr-x | test/runtests | 77 | ||||
-rwxr-xr-x | test/timed | 66 |
8 files changed, 102 insertions, 87 deletions
diff --git a/test/aapl.d/test_bsttable.cpp b/test/aapl.d/test_bsttable.cpp index e9476218..9c4d21ae 100644 --- a/test/aapl.d/test_bsttable.cpp +++ b/test/aapl.d/test_bsttable.cpp @@ -142,8 +142,11 @@ int testBstTable3() { BstMap<KeyStruct, int, KeyStructCompare > tbl; - cout << "ins res = " << ( tbl.insert(KeyStruct(0), 1) != 0 ) << endl; - cout << "ins res = " << ( tbl.insert(KeyStruct(1), 1) != 0 ) << endl; + BstMapEl<KeyStruct, int> *res1 = tbl.insert(KeyStruct(0), 1); + BstMapEl<KeyStruct, int> *res2 = tbl.insert(KeyStruct(1), 1); + + cout << "ins res = " << ( res1 != 0 ) << endl; + cout << "ins res = " << ( res2 != 0 ) << endl; return 0; } diff --git a/test/aapl.d/test_bsttable.exp b/test/aapl.d/test_bsttable.exp index bb0c1052..8060318c 100644 --- a/test/aapl.d/test_bsttable.exp +++ b/test/aapl.d/test_bsttable.exp @@ -6,12 +6,12 @@ (2, 2) maps to 10 KeyStruct(0) KeyStruct(KeyStruct &) -ins res = 1 ~KeyStruct = {0} KeyStruct(1) KeyStruct(KeyStruct &) -ins res = 1 ~KeyStruct = {1} +ins res = 1 +ins res = 1 ~KeyStruct = {0} ~KeyStruct = {1} 6 diff --git a/test/aapl.d/test_sbsttable.cpp b/test/aapl.d/test_sbsttable.cpp index cdba3c58..ad20e502 100644 --- a/test/aapl.d/test_sbsttable.cpp +++ b/test/aapl.d/test_sbsttable.cpp @@ -142,8 +142,11 @@ int testBstTable3() { SBstMap<KeyStruct, int, KeyStructCompare > tbl; - cout << "ins res = " << ( tbl.insert(KeyStruct(0), 1) != 0 ) << endl; - cout << "ins res = " << ( tbl.insert(KeyStruct(1), 1) != 0 ) << endl; + SBstMapEl<KeyStruct, int> *res1 = tbl.insert(KeyStruct(0), 1); + SBstMapEl<KeyStruct, int> *res2 = tbl.insert(KeyStruct(1), 1); + + cout << "ins res = " << ( res1 != 0 ) << endl; + cout << "ins res = " << ( res2 != 0 ) << endl; return 0; } diff --git a/test/aapl.d/test_sbsttable.exp b/test/aapl.d/test_sbsttable.exp index 9986c721..f5e9e8bb 100644 --- a/test/aapl.d/test_sbsttable.exp +++ b/test/aapl.d/test_sbsttable.exp @@ -6,12 +6,12 @@ (2, 2) maps to 10 KeyStruct(0) KeyStruct(KeyStruct &) -ins res = 1 ~KeyStruct = {0} KeyStruct(1) KeyStruct(KeyStruct &) -ins res = 1 ~KeyStruct = {1} +ins res = 1 +ins res = 1 ~KeyStruct = {0} ~KeyStruct = {1} 6 diff --git a/test/ragel.d/nfa1.rl b/test/ragel.d/nfa1.rl index 38732a98..284f1228 100644 --- a/test/ragel.d/nfa1.rl +++ b/test/ragel.d/nfa1.rl @@ -1,6 +1,6 @@ /* * @LANG: c - * @FILTER: sort + * @FILTER: LC_ALL=C sort */ #include <string.h> @@ -125,12 +125,7 @@ int main( ) -1 -1002000000002 -12 -12321 -2123 -222222 -99 -> fail -> fail @@ -142,4 +137,9 @@ int main( ) -> fail -> fail -> fail +1 +1002000000002 +12 +2123 +222222 saw 80808080 diff --git a/test/ragel.d/nfa2.rl b/test/ragel.d/nfa2.rl index 1f4f104b..b2da6542 100644 --- a/test/ragel.d/nfa2.rl +++ b/test/ragel.d/nfa2.rl @@ -1,6 +1,6 @@ # # @LANG: asm -# @FILTER: sort +# @FILTER: LC_ALL=C sort # %%{ @@ -283,14 +283,14 @@ nfa_len: .section .note.GNU-stack,"",@progbits ##### OUTPUT ##### -1 -1002000000002 -12 -12321 -2123 -222222 -99 -> FAIL -> FAIL -> FAIL +1 +1002000000002 +12 +2123 +222222 saw 80808080 diff --git a/test/runtests b/test/runtests index 7c075b25..97528852 100755 --- a/test/runtests +++ b/test/runtests @@ -1,3 +1,78 @@ #!/bin/bash -time bash $(dirname $0)/timed "$@" +#time bash $(dirname $0)/timed "$@" + +timed() +{ + # Default to all .d direcories. + DIRS=$(find -type d -name '*.d' | sort) + + CORES=$(awk '/cpu cores/ { print $4; exit }' /proc/cpuinfo) + + if ! echo $CORES | grep -q '^[1-9][0-9]\?$'; then + echo "warning: could not determine number of cores, using 2" + CORES=2 + fi + + HERE=$(basename $(pwd)) + if [ "${HERE%.d}" != "$HERE" ]; then + # In a test directory. Set DIR to . and pass any arguments to the local + # gentests. + DIRS=. + ARGS="$@" + elif [ $# != 0 ]; then + # Args on the command line, but not in .d. Assume they are test cases. + DIRS=$(find "$@" -type d -name '*.d') + fi + + GENTEST_LOG=`mktemp /tmp/gentest.XXXXXX` + + for D in $DIRS; do + cd $D + echo ---- in $D + ./gentests $ARGS 2>> $GENTEST_LOG | xargs -n1 -P$CORES bash + WORKING="$WORKING $D/working" + cd $OLDPWD + done + + CASES=`find $WORKING -name '*.sh' -not -size 0 | wc -l` + FAILURES=`find $WORKING -name '*.diff' -not -size 0 | wc -l` + + find $WORKING -name '*.diff' -not -size 0 + + echo ---- cases + echo $CASES + echo ---- failures + echo $FAILURES + + INTERNAL_ERRORS="" + + if [ -s $GENTEST_LOG ]; then + echo ---- internal errors + cat $GENTEST_LOG + fi + + if test -s $GENTEST_LOG; then + INTERNAL_ERRORS="yes" + fi + + rm -f $GENTEST_LOG + + # + # Exit with 1 if runtests experienced some internal error. Exit with 2 if a + # test failed. Otherwise 0. + # + + if [ "$INTERNAL_ERRORS" = yes ]; then + exit 1; + elif [ "$FAILURES" != "0" ]; then + exit 2 + fi + +} + +if [ "$0" = 'timed' ]; then + timed "$@" +else + time bash -c ". $0" timed "$@" +fi diff --git a/test/timed b/test/timed deleted file mode 100755 index d74b956e..00000000 --- a/test/timed +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash - -# Default to all .d direcories. -DIRS=$(find -type d -name '*.d' | sort) - -CORES=$(awk '/cpu cores/ { print $4; exit }' /proc/cpuinfo) - -if ! echo $CORES | grep -q '^[1-9][0-9]\?$'; then - echo "warning: could not determine number of cores, using 2" - CORES=2 -fi - -HERE=$(basename $(pwd)) -if [ "${HERE%.d}" != "$HERE" ]; then - # In a test directory. Set DIR to . and pass any arguments to the local - # gentests. - DIRS=. - ARGS="$@" -elif [ $# != 0 ]; then - # Args on the command line, but not in .d. Assume they are test cases. - DIRS=$(find "$@" -type d -name '*.d') -fi - -GENTEST_LOG=`mktemp /tmp/gentest.XXXXXX` - -for D in $DIRS; do - cd $D - echo ---- in $D - ./gentests $ARGS 2>> $GENTEST_LOG | xargs -n1 -P$CORES bash - WORKING="$WORKING $D/working" - cd $OLDPWD -done - -CASES=`find $WORKING -name '*.sh' -not -size 0 | wc -l` -FAILURES=`find $WORKING -name '*.diff' -not -size 0 | wc -l` - -find $WORKING -name '*.diff' -not -size 0 - -echo ---- cases -echo $CASES -echo ---- failures -echo $FAILURES - -INTERNAL_ERRORS="" - -if [ -s $GENTEST_LOG ]; then - echo ---- internal errors - cat $GENTEST_LOG -fi - -if test -s $GENTEST_LOG; then - INTERNAL_ERRORS="yes" -fi - -rm -f $GENTEST_LOG - -# -# Exit with 1 if runtests experienced some internal error. Exit with 2 if a -# test failed. Otherwise 0. -# - -if [ "$INTERNAL_ERRORS" = yes ]; then - exit 1; -elif [ "$FAILURES" != "0" ]; then - exit 2 -fi |