From 90f1624546b192df16deeff8a0bb5fe601ca0bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= <peckato1@fit.cvut.cz> Date: Thu, 1 May 2014 11:35:12 +0200 Subject: [PATCH] aconversion: run tests also on predefined automata - run tests on every automata stored as file examples/automaton/aconversion.test.*.xml --- examples/automaton/aconversion.test.1.xml | 59 +++++++++++++++++++++++ tests.aconversion.sh | 50 ++++++++++++++++--- 2 files changed, 101 insertions(+), 8 deletions(-) create mode 100644 examples/automaton/aconversion.test.1.xml diff --git a/examples/automaton/aconversion.test.1.xml b/examples/automaton/aconversion.test.1.xml new file mode 100644 index 0000000000..b51694077a --- /dev/null +++ b/examples/automaton/aconversion.test.1.xml @@ -0,0 +1,59 @@ +<automaton> + <states> + <state>one</state> + <state>two</state> + <state>three</state> + <state>four</state> + </states> + <inputAlphabet> + <symbol>0</symbol> + <symbol>1</symbol> + </inputAlphabet> + <transitions> + <transition> + <from>four</from> + <input>1</input> + <to>four</to> + </transition> + <transition> + <from>four</from> + <input>0</input> + <to>one</to> + </transition> + <transition> + <from>one</from> + <input>0</input> + <to>two</to> + </transition> + <transition> + <from>one</from> + <input>1</input> + <to>one</to> + </transition> + <transition> + <from>three</from> + <input>0</input> + <to>four</to> + </transition> + <transition> + <from>three</from> + <input>1</input> + <to>three</to> + </transition> + <transition> + <from>two</from> + <input>0</input> + <to>three</to> + </transition> + <transition> + <from>two</from> + <input>1</input> + <to>two</to> + </transition> + </transitions> + <initialStates> + <state>one</state> + </initialStates> + <finalStates> + </finalStates> +</automaton> diff --git a/tests.aconversion.sh b/tests.aconversion.sh index d2bd8dc192..67d0c0975d 100755 --- a/tests.aconversion.sh +++ b/tests.aconversion.sh @@ -12,6 +12,8 @@ RAND_ALPHABET=4 EXECUTABLES="arand aepsilon atrim adeterminize aminimize anormalize adiff.automaton aconversion" +TESTS_DIR="../examples/automaton" + # ---------------------------- for FILE in $EXECUTABLES; do @@ -42,19 +44,15 @@ function compare { return $RET } -# $1 = file to store nfa function generateNFA { - ./arand -d $RAND_DENSITY -n $(( $RANDOM % $RAND_STATES + 1 )) -a $(( $RANDOM % $RAND_ALPHABET + 1 )) > $1 2>/dev/null + ./arand -d $RAND_DENSITY -n $(( $RANDOM % $RAND_STATES + 1 )) -a $(( $RANDOM % $RAND_ALPHABET + 1 )) 2>/dev/null } # $1 = command for conversion. Output of such command must be (eps-)NFA !! +# $2 = automaton function runTest2 { TMPNFA="nfa.xml" - - $(generateNFA $TMPNFA) - if [ $? -eq 139 ]; then - return 3 - fi + echo "$2" > $TMPNFA TMP=$(timeout $TESTCASE_TIMEOUT bash -c "cat $TMPNFA | $1" 2>/dev/null) RETTMP=$? @@ -96,9 +94,44 @@ function runTest { echo $1 echo -ne "\t" + + # predefined tests first + for FILE in `ls $TESTS_DIR/aconversion.test*`; do + AUTOMATON=$(cat $FILE) + + runTest2 "$1" "$AUTOMATON" + TEST_EXITVALUE=$? + + if [ $TEST_EXITVALUE == 0 ]; then + echo -n "." + RES_GOOD=$((RES_GOOD + 1)) + elif [ $TEST_EXITVALUE == 1 ]; then + echo -n "x" + RES_FAIL=$((RES_FAIL + 1)) + elif [ $TEST_EXITVALUE == 2 ]; then + echo -n "T" + RES_TIMEOUT=$((RES_TIMEOUT + 1)) + elif [ $TEST_EXITVALUE == 3 ]; then + echo -n "F" + RES_SIGSEGV=$((RES_SIGSEGV + 1)) + else + echo -n "?" + fi + done + + echo -n " | " + + # random tests for i in $(seq 1 $TESTCASE_ITERATIONS ); do - runTest2 "$1" + RAND_AUTOMATON=$(generateNFA) + if [ $? -eq 139 ]; then + echo -n "F" + RES_SIGSEGV=$((RES_SIGSEGV + 1)) + continue + fi + + runTest2 "$1" "$RAND_AUTOMATON" TEST_EXITVALUE=$? if [ $TEST_EXITVALUE == 0 ]; then @@ -118,6 +151,7 @@ function runTest { fi done + # summary echo -ne "\n\t" echo "RES: GOOD:" $RES_GOOD ", BAD:" $RES_FAIL ", TIMEOUT:" $RES_TIMEOUT ", SIGSEGV:" $RES_SIGSEGV echo "" -- GitLab