Rework test scripts
authorKim Nguyễn <kn@lri.fr>
Tue, 29 May 2012 05:58:54 +0000 (07:58 +0200)
committerKim Nguyễn <kn@lri.fr>
Tue, 29 May 2012 05:58:54 +0000 (07:58 +0200)
tests/non_regression_tests/Treebank.srx [new symlink]
tests/non_regression_tests/Treebank.xml.queries [new file with mode: 0644]
tests/non_regression_tests/monet.sh
tests/non_regression_tests/qizx.sh
tests/non_regression_tests/sxsi.sh
tests/non_regression_tests/test.sh
tests/non_regression_tests/test_cache.sh [new file with mode: 0755]
tests/non_regression_tests/utils.sh [new file with mode: 0644]
tests/non_regression_tests/xmark_01.04.xml.queries [new symlink]
tests/non_regression_tests/xmark_all.xml.queries

diff --git a/tests/non_regression_tests/Treebank.srx b/tests/non_regression_tests/Treebank.srx
new file mode 120000 (symlink)
index 0000000..a9bc709
--- /dev/null
@@ -0,0 +1 @@
+../docs/Treebank.srx
\ No newline at end of file
diff --git a/tests/non_regression_tests/Treebank.xml.queries b/tests/non_regression_tests/Treebank.xml.queries
new file mode 100644 (file)
index 0000000..be0e21e
--- /dev/null
@@ -0,0 +1,9 @@
+T01%/descendant::NP
+#%/descendant::*/child::NP
+#T03%/descendant::NP/descendant::VBZ
+T02%/descendant::S[descendant::VP and descendant::NP]/child::VP/child::PP[child::IN]/child::NP/child::VBN
+T03%/descendant::NP[descendant::JJ or descendant::CC]
+T04%/descendant::CC[ not(descendant::JJ) ]
+#%/descendant::S/child::VP/child::PP[child::NP/child::VBN]/child::IN
+T05%/descendant::NN[descendant::VBZ or descendant::IN]/child::*[descendant::NN or descendant::_QUOTE_]
+#T06%/descendant::EMPTY[descendant::VP and descendant::S]/descendant::PP[descendant::S and descendant::VGN]
\ No newline at end of file
index db76444..d1e2c35 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-
+source utils.sh
 #Mserver and killall must be in /etc/sudoers
 function kmonet() {
     sudo killall -TERM Mserver
@@ -11,7 +11,7 @@ trap kmonet INT TERM
 function do_monet(){
     while pidof Mserver >/dev/null
     do
-       
+
        sudo killall -TERM Mserver
        sleep 3
     done
@@ -44,8 +44,8 @@ function do_monet(){
     } < <(echo "fn:count(fn:doc(\"$doc\")$query)
 " | mclient -t --interactive 2>&1 | grep -o '[0-9.]*' )
 
-    TIME_COUNT="$tquery
-$TIME_COUNT"
+    TIME_COUNT="$TIME_COUNT
+$tquery"
 
     NUM_RESULTS="$num"
     done
@@ -62,24 +62,24 @@ $TIME_COUNT"
 fn:doc(\"$doc\")$query
 " | mclient -t --interactive 2>&1 | grep -o '[0-9.]*' )
 
-    TIME_MAT="$tquery
-$TIME_MAT"
+    TIME_MAT="$TIME_MAT
+$tquery"
 
-    TIME_PRINT="$tprint
-$TIME_PRINT"
+    TIME_PRINT="$TIME_PRINT
+$tprint"
 
     done
 
     while pidof Mserver >/dev/null
     do
-       
+
        sudo killall -TERM Mserver
        sleep 3
     done
 
-    echo "$TIME_COUNT" | sort -g | head -2 | tail -1
-    echo "$TIME_MAT" | sort -g | head -2 | tail -1
-    echo "$TIME_PRINT" | sort -g | head -2 | tail -1
+    echo "$TIME_COUNT" | tail -n +2 | average
+    echo "$TIME_MAT" | tail -n +2   | average
+    echo "$TIME_PRINT" | tail -n +2   | average
     echo $NUM_RESULTS
 }
 
index d9f56dd..2226239 100755 (executable)
 #!/bin/bash
-QIZX="/usr/local/bin/alarm 600 22000000 /raid0/kn/qizx/qizx-fe-4.1p1/bin/qizx"
+QIZX="/raid0/kn/qizx/qizx-fe-4.1p1/bin/qizx.alarm"
+
+source utils.sh
+
+function stop_qizx() {
+    sleep 2
+    rm -rf mat.xq count.xq
+    QIZXPIDS=`ps xwww --format "%p,%a" | grep java | grep qizx | cut -f 1 -d ' '`
+    for i in $QIZXPIDS
+    do
+       kill -TERM "$i"
+       sleep 2
+       KILLED=`ps aux | grep '^'$i`
+       if [ "$KILLED" ]
+       then
+           kill -9 "$i"
+       fi
+       sleep 3
+       rm -f /raid0/kn/qizxlib/*/lock
+       while true
+       do
+           o=/raid0/kn/qizx/qizx-fe-4.1p1/bin/qizx -g /raid0/kn/qizxlib/ -l xmark -check /tmp/log >/dev/null 2>&1
+           sleep 2
+           if [ -z "$o" ]
+           then
+               break
+           fi
+       done
+    done
+
+}
+
+trap stop_qizx INT TERM
 
 function do_qizx() {
-    
+
+    stop_qizx
+
     query="$1"
-    doc=`basename "$2" .xml`
+    doc=`basename "$2"`
+    repeat="$3"
     echo 'let $doc := collection("'"$doc"'") return count($doc'"$query"')' > count.xq
     echo 'let $doc := collection("'"$doc"'") return $doc'"$query" > mat.xq
-    {
-       read count;
-    } < <($QIZX -g /raid0/kn/qizxlib/ -l xmark count.xq 2>&1 )
-    {
-       read time_count;
-    } < <($QIZX -g /raid0/kn/qizxlib/ -l xmark -mr 4 count.xq 2>&1 | grep evaluation | cut -f2 -d ',' | grep -o '[0-9.]*' | head -1 )    
-
-    {
-       read time_mat;
-    } <  <($QIZX -g /raid0/kn/qizxlib/ -l xmark -mr 2 mat.xq 2>&1 | grep evaluation | cut -f2 -d ',' | grep -o '[0-9.]*' | sort -g | head -1 )    
-    
+
+    IT=0
+    while true
+    do
+       OUTPUT=`$QIZX -g /raid0/kn/qizxlib/ -l xmark count.xq 2>&1`
+       if  echo "$OUTPUT" | grep -q 'java' >/dev/null 2>&1
+       then
+           if [ "$IT" = 5 ]
+           then
+               break
+           fi
+           IT=$(($IT + 1))
+           continue
+       fi
+
+       {
+           read count;
+       } < <(echo "$OUTPUT")
+
+       stop_qizx
+       sleep 3
+       tmp=`echo "$count" | grep -o '[0-9.]\+'`
+       if [ "$tmp" = "$count" ]
+       then
+           break
+       fi
+    done
+
+    IT=0
+    while true
+    do
+
+       OUTPUT=`$QIZX -g /raid0/kn/qizxlib/ -l xmark -r "$repeat" count.xq 2>&1`
+       if  echo "$OUTPUT" | grep -q 'java' >/dev/null 2>&1
+       then
+           if [ "$IT" = 5 ]
+           then
+               break
+           fi
+           IT=$(($IT + 1))
+           continue
+       fi
+
+       {
+           read time_count;
+       } < <(echo "$OUTPUT" | grep 'display time' | cut -f 3 -d : | grep -o '[0-9]\+'| tail -n +1 | average )
+
+
+       stop_qizx
+       sleep 3
+       if [ -z "$time_count" ]
+       then
+           break
+       fi
+       tmp=`echo "$time_count" | grep -o '[0-9.]\+'`
+       if [ "$tmp" = "$time_count" ]
+       then
+           break
+       fi
+    done
+
+    IT=0
+    while true
+    do
+       OUTPUT=`$QIZX -g /raid0/kn/qizxlib/ -l xmark -r "$repeat" mat.xq -out /dev/null 2>&1`
+       if  echo "$OUTPUT" | grep -q 'java' >/dev/null 2>&1
+       then
+           if [ "$IT" = 5 ]
+           then
+               break
+           fi
+           IT=$(($IT + 1))
+           continue
+       fi
+
+       {
+           read time_mat;
+       } <  <(echo "$OUTPUT" 2>&1 | grep 'display time' | cut -f 3 -d : | grep -o '[0-9]\+'| tail -n +1 | average)
+
+       stop_qizx
+       sleep 3
+       if [ -z "$time_mat" ]
+       then
+           break
+       fi
+
+
+       tmp=`echo "$time_mat" | grep -o '[0-9.]\+'`
+       if [ "$tmp" = "$time_mat" ]
+       then
+           break
+       fi
+    done
+
     echo $time_count
     echo 0
-    echo $time_mat 
+    echo $time_mat
     echo $count
 
 }
index f1948ea..0ef26c4 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+source utils.sh
+
 function do_sxsi() {
     query="$1"
     doc=`basename "$2" .xml`.srx
@@ -8,20 +10,20 @@ function do_sxsi() {
     TIME_COUNT=""
     TIME_PRINT=""
     NUM_RESULTS=""
-    output=`./main.native -v -c -b "$doc" "$query" 2>&1`
+    output=`./main.native -r "$3" -c -b "$doc" "$query" 2>&1`
     echo "$output" >> sxsi_debug.log
-    NUM_RESULT=`echo "$output" | grep "Number of nodes " | grep -o '[0-9]*'`
-    time=`echo "$output" | grep "Execution time" | cut -f 2 -d',' | grep -o '[0-9.]*'`
-    TIME_COUNT=`echo "$time" | sort -g | head -1`
+    NUM_RESULT=`echo "$output" | grep "Number of results" | grep -o '[0-9]*'`
+    time=`echo "$output" | grep "Execution time" | cut -f 2 -d',' | cut -f1 -d ':' | grep -o '[0-9.]*'`
+    TIME_COUNT=`echo "$time" | tail -n +2 | average`
 
-    output=`./main.native -b "$doc" "$query" /dev/null 2>&1`
-    mtime=`echo "$output" | grep "Execution time" | cut -f 2 -d',' | grep -o '[0-9.]*'`
-    ptime=`echo "$output" | grep "Serializing" | grep -o '[0-9.]*'`
-    TIME_MAT=`echo "$mtime" | sort -g | head -1`
+    output=`./main.native -b -r "$3" "$doc" "$query" /dev/null 2>&1`
+    mtime=`echo "$output" | grep "Execution time" | cut -f 2 -d',' | cut -f1 -d ':'| grep -o '[0-9.]*'`
+    ptime=`echo "$output" | grep 'Serialization time' | cut -f 3 -d ' ' | grep -o '[0-9.]*'`
+    TIME_MAT=`echo "$mtime" | tail -n +2 | average`
     TIME_PRINT="$ptime"
 
-    echo "$TIME_COUNT" 
-    echo "$TIME_MAT" 
+    echo "$TIME_COUNT"
+    echo "$TIME_MAT"
     echo "$TIME_PRINT"
     echo $NUM_RESULT
 }
index dc75a4e..c02a2be 100755 (executable)
@@ -32,9 +32,11 @@ if [ "$1" = "fast" ]
 then
     repeat_monet=1
     repeat_sxsi=1
+    repeat_qizx=2
 else
-    repeat_monet=5
-    repeat_sxsi=3
+    repeat_monet=10
+    repeat_sxsi=10
+    repeat_qizx=4
 fi
 
 
@@ -50,8 +52,14 @@ QLOG="$TESTDOC"_qizx.log
 rm -f "$MLOG" "$SLOG" "$QLOG"
 cat "$TESTDOC".queries | grep -v '^#' | while read line
 do
-    query=`echo "$line" | cut -f 1 -d "%"`
-    query_qizx=`echo "$line" | cut -f 2 -d "%"`
+
+    qname=`echo "$line" | cut -f 1 -d "%"`
+    query=`echo "$line" | cut -f 2 -d "%"`
+    query_qizx=`echo "$line" | cut -f 3 -d "%"`
+    if [ -z "$query_qizx" ]
+    then
+       query_qizx="$query"
+    fi
     echo Test $I "... "
     echo "$query" | sed -e 's|/descendant::|//|g' | sed -e 's|child::||g'
     echo -n Running SXSI
@@ -83,15 +91,15 @@ do
     fi
     echo " ok"
 
-# echo -n Running Qizx/XQuery
-# {
-#      read qizx_count_time
-#      read qizx_mat_time
-#      read qizx_print_time
-#      read qizx_count
-#   } < <(`pwd`/qizx.sh "$query_qizx" "$TESTDOC")
-#
-#   echo " ok"
+    echo -n Running Qizx/XQuery
+    {
+       read qizx_count_time
+       read qizx_mat_time
+       read qizx_print_time
+       read qizx_count
+    } < <(`pwd`/qizx.sh "$query_qizx" "$TESTDOC" "$repeat_qizx")
+
+    echo " ok"
 
     if [ "$monet_count" = "" ]
     then
diff --git a/tests/non_regression_tests/test_cache.sh b/tests/non_regression_tests/test_cache.sh
new file mode 100755 (executable)
index 0000000..de275a7
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+source utils.sh
+DOC="$2"
+cat "$1" | grep -v '^#' | while read line 
+do
+    QNAME=`echo "$line" | cut -f 1 -d '%'`
+    QUERY=`echo "$line" | cut -f 2 -d '%'`
+    echo -n "$QNAME",
+    for mode in "-nc -nj" "-nc" "-nj" ""
+    do
+       output=`../../main.native -r "4" $mode -c "$DOC" "$QUERY" 2>&1`
+       #echo "$output"
+       time=`echo "$output" | grep "Execution time" | cut -f 2 -d',' | cut -f1 -d ':' | grep -o '[0-9.]*'`
+       TIME_COUNT=`echo "$time" | tail -n +2 | average`
+       echo -n "$TIME_COUNT"
+       if [ -z "$mode" ]
+       then
+           echo
+       else
+           echo -n ","
+       fi
+    done
+done
diff --git a/tests/non_regression_tests/utils.sh b/tests/non_regression_tests/utils.sh
new file mode 100644 (file)
index 0000000..db48227
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+function average() {
+    N="0"
+    I=0
+    while read x
+    do
+       if [ -z "$x" ]
+       then
+           I=0
+           break
+       fi
+       N="$N + $x"
+       I=$(($I+1))
+    done
+    if [ "$I" = "0" ]
+    then
+       echo
+    else
+       echo "scale=3; 1+(( $N ) / $I)" | bc -q
+    fi
+}
diff --git a/tests/non_regression_tests/xmark_01.04.xml.queries b/tests/non_regression_tests/xmark_01.04.xml.queries
new file mode 120000 (symlink)
index 0000000..7c96d58
--- /dev/null
@@ -0,0 +1 @@
+xmark_all.xml.queries
\ No newline at end of file
index 6d70d8f..831e116 100644 (file)
@@ -1,29 +1,29 @@
-/child::site/child::regions
-/child::site/child::closed_auctions
-/child::site/child::regions/child::*/child::item
-/child::site/child::closed_auctions/child::closed_auction/child::annotation/child::description/child::text/child::keyword
-/descendant::listitem/descendant::keyword
-/descendant::closed_auction/descendant::keyword
-/site/closed_auctions/closed_auction/descendant::keyword
-/child::site/child::closed_auctions/child::closed_auction[child::annotation/child::description/child::text/child::keyword]/child::date
-/child::site/child::closed_auctions/child::closed_auction[descendant::keyword]/child::date
-/child::site/child::people/child::person[child::profile/child::gender and child::profile/child::age]/child::name
-/child::site/child::people/child::person[child::phone or child::homepage]/child::name
-/child::site/child::people/child::person[child::address and (child::phone or child::homepage) and (child::creditcard or child::profile)]/child::name
-/descendant::listitem[not(descendant::keyword/child::emph)]/descendant::parlist
-/descendant::listitem[ (descendant::keyword or descendant::emph) and (descendant::emph or descendant::bold)]/child::parlist
-/descendant::people[ descendant::person[not(child::address)] and descendant::person[not(child::watches)]]/child::person[child::watches]
-/site/regions/europe/item/mailbox/mail/text/keyword
-/site/closed_auctions/closed_auction/annotation/description/parlist/listitem
-/site/closed_auctions/closed_auction/annotation/description/parlist/listitem/parlist/listitem/*/descendant::keyword
-/site/regions/*/item/descendant::keyword
-/site/regions/*/person[ address and (phone or homepage) ]
-/descendant::listitem[ descendant::keyword and descendant::emph]/descendant::parlist
-/site/regions/*/item[ mailbox/mail/date ]/mailbox/mail
-/child::*[ descendant::* ]
-/descendant::*
-/descendant::*/descendant::*
-/descendant::*/descendant::*/descendant::*
-/descendant::*/descendant::*/descendant::*/descendant::*
-/descendant::*/descendant::*/descendant::*/descendant::*/descendant::*/descendant::*
-#/descendant::*/descendant::*
+X01%/child::site/child::regions
+#%/child::site/child::closed_auctions
+X02%/child::site/child::regions/child::*/child::item
+X03%/child::site/child::closed_auctions/child::closed_auction/child::annotation/child::description/child::text/child::keyword
+X04%/descendant::listitem/descendant::keyword
+#%/descendant::closed_auction/descendant::keyword
+#%/site/closed_auctions/closed_auction/descendant::keyword
+X05%/child::site/child::closed_auctions/child::closed_auction[child::annotation/child::description/child::text/child::keyword]/child::date
+X06%/child::site/child::closed_auctions/child::closed_auction[descendant::keyword]/child::date
+X07%/child::site/child::people/child::person[child::profile/child::gender and child::profile/child::age]/child::name
+X08%/child::site/child::people/child::person[child::phone or child::homepage]/child::name
+X09%/child::site/child::people/child::person[child::address and (child::phone or child::homepage) and (child::creditcard or child::profile)]/child::name
+X10%/descendant::listitem[not(descendant::keyword/child::emph)]/descendant::parlist
+X11%/descendant::listitem[ (descendant::keyword or descendant::emph) and (descendant::emph or descendant::bold)]/child::parlist
+X12%/descendant::people[ descendant::person[not(child::address)] and descendant::person[not(child::watches)]]/child::person[child::watches]
+#%/site/regions/europe/item/mailbox/mail/text/keyword
+#%/site/closed_auctions/closed_auction/annotation/description/parlist/listitem
+#%/site/closed_auctions/closed_auction/annotation/description/parlist/listitem/parlist/listitem/*/descendant::keyword
+#%/site/regions/*/item/descendant::keyword
+#%/site/regions/*/person[ address and (phone or homepage) ]
+#%/descendant::listitem[ descendant::keyword and descendant::emph]/descendant::parlist
+#%/site/regions/*/item[ mailbox/mail/date ]/mailbox/mail
+X13%/child::*[ descendant::* ]
+X14%/descendant::*
+X15%/descendant::*/descendant::*
+X16%/descendant::*/descendant::*/descendant::*
+X17%/descendant::*/descendant::*/descendant::*/descendant::*
+#%/descendant::*/descendant::*/descendant::*/descendant::*/descendant::*/descendant::*
+#%/descendant::*/descendant::*