diff --git a/makefile b/makefile index e1dbaf12847315974cf9cbee9ea639049966c193..d7bfa1e30f7b11c0e3ba908c674a988cf1c6e385 100644 --- a/makefile +++ b/makefile @@ -4,6 +4,13 @@ APPPATH = /usr/bin LIBPATH = /usr/lib BINFOLDER = bin +MAKE_PID := $(shell echo $$PPID) +JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)"))) +JOBS := $(subst -j,,$(JOB_FLAG)) +ifndef JOBS +JOBS := 1 +endif + STD_LIB = alib2std DATA_LIB = alib2data COMMON_LIB = alib2common @@ -104,13 +111,13 @@ debug: all-debug for dir in $(SUBDIRS_BINS); do \ cp $$dir/bin-debug/* $(addsuffix -debug, $(BINFOLDER)); \ done - ./tests.examples.sh debug - ./tests.adeterminize.sh debug - ./tests.aconversion.sh debug - ./tests.aderivation.aintegral.sh debug - ./tests.astringology.sh debug - ./tests.anormalize.sh debug - ./tests.aarbology.sh debug + ./tests.examples.sh debug $(JOBS) + ./tests.adeterminize.sh debug $(JOBS) + ./tests.aconversion.sh debug $(JOBS) + ./tests.aderivation.aintegral.sh debug $(JOBS) + ./tests.astringology.sh debug $(JOBS) + ./tests.anormalize.sh debug $(JOBS) + ./tests.aarbology.sh debug $(JOBS) release: all-release if [ ! -w $(addsuffix -release, $(BINFOLDER)) ] && [ $(USE_RAMDISK) -eq 1 ]; then\ @@ -128,13 +135,13 @@ release: all-release for dir in $(SUBDIRS_BINS); do \ cp $$dir/bin-release/* $(addsuffix -release, $(BINFOLDER)); \ done - ./tests.examples.sh release - ./tests.adeterminize.sh release - ./tests.aconversion.sh release - ./tests.aderivation.aintegral.sh release - ./tests.astringology.sh release - ./tests.anormalize.sh release - ./tests.aarbology.sh release + ./tests.examples.sh release $(JOBS) + ./tests.adeterminize.sh release $(JOBS) + ./tests.aconversion.sh release $(JOBS) + ./tests.aderivation.aintegral.sh release $(JOBS) + ./tests.astringology.sh release $(JOBS) + ./tests.anormalize.sh release $(JOBS) + ./tests.aarbology.sh release $(JOBS) clean : clean-debug clean-release $(RM) -r bin-debug bin-release diff --git a/tests.aarbology.sh b/tests.aarbology.sh index 792efe4916a81fb4f733fb72336d9b85b29e6a58..73c22ee1fc1ca179fe0b9570add67d159f277605 100755 --- a/tests.aarbology.sh +++ b/tests.aarbology.sh @@ -36,6 +36,8 @@ done cd bin-$1/ rm -f $LOGFILE +JOBS=$2 + # ---------------------------- # $1 = conv command @@ -82,16 +84,21 @@ function runTest2 { log "$2" $RET "$3" "$4" "$OUT" fi + rm $3 + rm $4 + if [ $RET == 124 ]; then # timeout + registerResult 2 return 2 elif [ $RET -ge 124 ]; then #segv + registerResult 3 return 3 - fi - - if [ $RET != 0 ] || [ $RET2 != 0 ]; then # fail + elif [ $RET != 0 ] || [ $RET2 != 0 ]; then # fail + registerResult 1 return 1 else MATCHES=$(($MATCHES + $OUT2)) + registerResult 0 return 0 fi } @@ -147,32 +154,36 @@ function runTestSubtree { # predefined tests first for SUBJECT_FILE in `ls $TESTS_DIR/aarbology.test*.subject.xml`; do PATTERN_FILE=${SUBJECT_FILE%.subject.xml}.subtree.xml - if [ -f ]; then - Occs=`./aarbology2 -a exactSubtreeMatch -s "$SUBJECT_FILE" -p "$PATTERN_FILE" | ./astat2 -p size --set` + if [ -f $PATTERN_FILE ]; then + SUBJECT_FILE_COPY=$(mktemp) + PATTERN_FILE_COPY=$(mktemp) + + cat $SUBJECT_FILE > $SUBJECT_FILE_COPY + cat $PATTERN_FILE > $PATTERN_FILE_COPY + + Occs=`./aarbology2 -a exactSubtreeMatch -s "$SUBJECT_FILE_COPY" -p "$PATTERN_FILE_COPY" | ./astat2 -p size --set` - runTest2 "$Occs" "$2" "$SUBJECT_FILE" "$PATTERN_FILE" - registerResult $? + runTest2 "$Occs" "$2" "$SUBJECT_FILE_COPY" "$PATTERN_FILE_COPY" fi done echo -n " | " # random tests - SUBJECT_FILE=s.xml - PATTERN_FILE=p.xml for i in $(seq 1 $TESTCASE_ITERATIONS ); do + SUBJECT_FILE=$(mktemp) + PATTERN_FILE=$(mktemp) + cat <(generateSubject) > $SUBJECT_FILE cat <(generateSubtree) > $PATTERN_FILE Occs=`./aarbology2 -a exactSubtreeMatch -s "$SUBJECT_FILE" -p "$PATTERN_FILE" | ./astat2 -p size --set` - runTest2 "$Occs" "$2" "$SUBJECT_FILE" "$PATTERN_FILE" - registerResult $? + runTest2 "$Occs" "$2" "$SUBJECT_FILE" "$PATTERN_FILE" & (( i%JOBS==0 )) && wait done - rm $SUBJECT_FILE - rm $PATTERN_FILE + wait outputResults } @@ -187,32 +198,36 @@ function runTestPattern { # predefined tests first for SUBJECT_FILE in `ls $TESTS_DIR/aarbology.test*.subject.xml`; do PATTERN_FILE=${SUBJECT_FILE%.subject.xml}.pattern.xml - if [ -f ]; then - Occs=`./aarbology2 -a exactPatternMatch -s "$SUBJECT_FILE" -p "$PATTERN_FILE" | ./astat2 -p size --set` + if [ -f $PATTERN_FILE ]; then + SUBJECT_FILE_COPY=$(mktemp) + PATTERN_FILE_COPY=$(mktemp) + + cat $SUBJECT_FILE > $SUBJECT_FILE_COPY + cat $PATTERN_FILE > $PATTERN_FILE_COPY - runTest2 "$Occs" "$2" "$SUBJECT_FILE" "$PATTERN_FILE" - registerResult $? + Occs=`./aarbology2 -a exactPatternMatch -s "$SUBJECT_FILE_COPY" -p "$PATTERN_FILE_COPY" | ./astat2 -p size --set` + + runTest2 "$Occs" "$2" "$SUBJECT_FILE_COPY" "$PATTERN_FILE_COPY" fi done echo -n " | " # random tests - SUBJECT_FILE=s.xml - PATTERN_FILE=p.xml for i in $(seq 1 $TESTCASE_ITERATIONS ); do + SUBJECT_FILE=$(mktemp) + PATTERN_FILE=$(mktemp) + cat <(generateSubject) > $SUBJECT_FILE cat <(generatePattern) > $PATTERN_FILE Occs=`./aarbology2 -a exactPatternMatch -s "$SUBJECT_FILE" -p "$PATTERN_FILE" | ./astat2 -p size --set` - runTest2 "$Occs" "$2" "$SUBJECT_FILE" "$PATTERN_FILE" - registerResult $? + runTest2 "$Occs" "$2" "$SUBJECT_FILE" "$PATTERN_FILE" & (( i%JOBS==0 )) && wait done - rm $SUBJECT_FILE - rm $PATTERN_FILE + wait outputResults } @@ -227,32 +242,36 @@ function runTestPatternEnds { # predefined tests first for SUBJECT_FILE in `ls $TESTS_DIR/aarbology.test*.subject.xml`; do PATTERN_FILE=${SUBJECT_FILE%.subject.xml}.pattern.xml - if [ -f ]; then - Occs=`./aarbology2 -e -a exactPatternMatch -s <(./acast2 -t PrefixRankedTree -i "$SUBJECT_FILE" ) -p <(./acast2 -t PrefixRankedPattern -i "$PATTERN_FILE" ) | ./astat2 -p size --set` + if [ -f $PATTERN_FILE ]; then + SUBJECT_FILE_COPY=$(mktemp) + PATTERN_FILE_COPY=$(mktemp) - runTest2 "$Occs" "$2" "$SUBJECT_FILE" "$PATTERN_FILE" - registerResult $? + cat $SUBJECT_FILE > $SUBJECT_FILE_COPY + cat $PATTERN_FILE > $PATTERN_FILE_COPY + + Occs=`./aarbology2 -e -a exactPatternMatch -s <(./acast2 -t PrefixRankedTree -i "$SUBJECT_FILE_COPY" ) -p <(./acast2 -t PrefixRankedPattern -i "$PATTERN_FILE_COPY" ) | ./astat2 -p size --set` + + runTest2 "$Occs" "$2" "$SUBJECT_FILE_COPY" "$PATTERN_FILE_COPY" fi done echo -n " | " # random tests - SUBJECT_FILE=s.xml - PATTERN_FILE=p.xml for i in $(seq 1 $TESTCASE_ITERATIONS ); do + SUBJECT_FILE=$(mktemp) + PATTERN_FILE=$(mktemp) + cat <(generateSubject) > $SUBJECT_FILE cat <(generatePattern) > $PATTERN_FILE Occs=`./aarbology2 -e -a exactPatternMatch -s <(./acast2 -t PrefixRankedTree -i "$SUBJECT_FILE" ) -p <(./acast2 -t PrefixRankedPattern -i "$PATTERN_FILE" ) | ./astat2 -p size --set` - runTest2 "$Occs" "$2" "$SUBJECT_FILE" "$PATTERN_FILE" - registerResult $? + runTest2 "$Occs" "$2" "$SUBJECT_FILE" "$PATTERN_FILE" & (( i%JOBS==0 )) && wait done - rm $SUBJECT_FILE - rm $PATTERN_FILE + wait outputResults } diff --git a/tests.aconversion.sh b/tests.aconversion.sh index 2558e1214d609a184b1e60cc962efbf239289e3a..49409017fd2dc08b90f73a103cedad7b7fc6a6ad 100755 --- a/tests.aconversion.sh +++ b/tests.aconversion.sh @@ -33,6 +33,8 @@ done cd bin-$1/ rm -f $LOGFILE +JOBS=$2 + # ---------------------------- # $1 = conv command @@ -61,18 +63,24 @@ function runTest2 { OUT=`timeout $TESTCASE_TIMEOUT bash -c "./acompare2 <(cat $2 | $1 | $MDFA ) <(cat $2 | $MDFA)"` RET=$? - if [ $RET == 0 ]; then # ok - return 0 + if [ $RET != 0 ]; then # fail + log "$1" $RET "$2" "$OUT" fi - log "$1" $RET "$2" "$OUT" + rm $2 if [ $RET == 124 ]; then # timeout + registerResult 2 return 2 elif [ $RET -ge 124 ]; then #segv + registerResult 3 return 3 - else + elif [ $RET != 0 ]; then # fail + registerResult 1 return 1 + else + registerResult 0 + return 0 fi } @@ -125,23 +133,26 @@ function runTest { # predefined tests first for FILE in `ls $TESTS_DIR/aconversion.test*`; do - runTest2 "$1" "$FILE" - registerResult $? + FILE_COPY=$(mktemp) + + cat $FILE > $FILE_COPY + + runTest2 "$1" "$FILE_COPY" done echo -n " | " # random tests - NFA_FILE=nfa.xml for i in $(seq 1 $TESTCASE_ITERATIONS ); do + NFA_FILE=$(mktemp) + cat <(generateNFA) > $NFA_FILE - runTest2 "$1" "$NFA_FILE" - registerResult $? + runTest2 "$1" "$NFA_FILE" & (( i%JOBS==0 )) && wait done - rm $NFA_FILE + wait outputResults } diff --git a/tests.anormalize.sh b/tests.anormalize.sh index 4a8617fafa0ee2e85a924a2928f8dcc8db52ac52..d4b50a17785dc16075cf1f01e0a76b20eb433653 100755 --- a/tests.anormalize.sh +++ b/tests.anormalize.sh @@ -34,6 +34,8 @@ done cd bin-$1/ rm -f $LOGFILE +JOBS=$2 + # ---------------------------- # $1 = conv command @@ -62,18 +64,24 @@ function runTest2 { OUT=`timeout $TESTCASE_TIMEOUT bash -c "diff <(cat $2 | $1 | $GENERATED_STRINGS ) <(cat $2 | $GENERATED_STRINGS)"` RET=$? - if [ $RET == 0 ]; then # ok - return 0 + if [ $RET != 0 ]; then # fail + log "$1" $RET "$2" "$OUT" fi - log "$1" $RET "$2" "$OUT" + rm $2 if [ $RET == 124 ]; then # timeout + registerResult 2 return 2 elif [ $RET -ge 124 ]; then #segv + registerResult 3 return 3 - else + elif [ $RET != 0 ]; then # fail + registerResult 1 return 1 + else + registerResult 0 + return 0 fi } @@ -126,23 +134,26 @@ function runTest { # predefined tests first for FILE in `ls $TESTS_DIR/anormalization.test*`; do - runTest2 "$1" "$FILE" - registerResult $? + FILE_COPY=$(mktemp) + + cat $FILE > $FILE_COPY + + runTest2 "$1" "$FILE_COPY" done echo -n " | " # random tests - CFG_FILE=cfg.xml for i in $(seq 1 $TESTCASE_ITERATIONS ); do + CFG_FILE=$(mktemp) + cat <(generateCFG) > $CFG_FILE - runTest2 "$1" "$CFG_FILE" - registerResult $? + runTest2 "$1" "$CFG_FILE" & (( i%JOBS==0 )) && wait done - rm $CFG_FILE + wait outputResults } diff --git a/tests.astringology.sh b/tests.astringology.sh index e7c81eb24659ea155f8818645241d2715ae4a517..4b9749bfce2b914ae4e6e26f14d8032dd9fa7392 100755 --- a/tests.astringology.sh +++ b/tests.astringology.sh @@ -34,6 +34,8 @@ done cd bin-$1/ rm -f $LOGFILE +JOBS=$2 + # ---------------------------- # $1 = conv command @@ -76,16 +78,21 @@ function runTest2 { log "$2" $RET "$3" "$4" "$OUT" fi + rm $3 + rm $4 + if [ $RET == 124 ]; then # timeout + registerResult 2 return 2 elif [ $RET -ge 124 ]; then #segv + registerResult 3 return 3 - fi - - if [ $RET != 0 ] || [ $RET2 != 0 ]; then # fail + elif [ $RET != 0 ] || [ $RET2 != 0 ]; then # fail + registerResult 1 return 1 else MATCHES=$(($MATCHES + $OUT2)) + registerResult 0 return 0 fi } @@ -141,32 +148,36 @@ function runTest { # predefined tests first for SUBJECT_FILE in `ls $TESTS_DIR/astringology.test*.subject.xml`; do PATTERN_FILE=${SUBJECT_FILE%.subject.xml}.pattern.xml - if [ -f ]; then - Occs=`./astringology2 -a exactFactorMatch -s "$SUBJECT_FILE" -p "$PATTERN_FILE" | ./astat2 -p size --set` + if [ -f $PATTERN_FILE ]; then + SUBJECT_FILE_COPY=$(mktemp) + PATTERN_FILE_COPY=$(mktemp) + + cat $SUBJECT_FILE > $SUBJECT_FILE_COPY + cat $PATTERN_FILE > $PATTERN_FILE_COPY - runTest2 "$Occs" "$2" "$SUBJECT_FILE" "$PATTERN_FILE" - registerResult $? + Occs=`./astringology2 -a exactFactorMatch -s "$SUBJECT_FILE_COPY" -p "$PATTERN_FILE_COPY" | ./astat2 -p size --set` + + runTest2 "$Occs" "$2" "$SUBJECT_FILE_COPY" "$PATTERN_FILE_COPY" fi done echo -n " | " # random tests - SUBJECT_FILE=s.xml - PATTERN_FILE=p.xml for i in $(seq 1 $TESTCASE_ITERATIONS ); do + SUBJECT_FILE=$(mktemp) + PATTERN_FILE=$(mktemp) + cat <(generateSubject) > $SUBJECT_FILE cat <(generatePattern) > $PATTERN_FILE Occs=`./astringology2 -a exactFactorMatch -s "$SUBJECT_FILE" -p "$PATTERN_FILE" | ./astat2 -p size --set` - runTest2 "$Occs" "$2" "$SUBJECT_FILE" "$PATTERN_FILE" - registerResult $? + runTest2 "$Occs" "$2" "$SUBJECT_FILE" "$PATTERN_FILE" & (( i%JOBS==0 )) && wait done - rm $SUBJECT_FILE - rm $PATTERN_FILE + wait outputResults }