Rework the testing script.
authorKim Nguyễn <kn@lri.fr>
Thu, 14 Mar 2013 07:20:05 +0000 (08:20 +0100)
committerKim Nguyễn <kn@lri.fr>
Thu, 14 Mar 2013 07:20:05 +0000 (08:20 +0100)
Rename the main program.

main.itarget
src/main.ml [deleted file]
src/tatoo.ml [new file with mode: 0644]
tools/do_jaxp.sh [new file with mode: 0755]
tools/do_tatoo.sh [new file with mode: 0755]
tools/do_test.sh [deleted file]
tools/gen_test.sh [deleted file]
tools/gen_test_results.sh [new file with mode: 0755]

index d11e542..6c7372b 100644 (file)
@@ -1,4 +1,4 @@
-src/main.native
+src/tatoo.native
 tools/xml_diff.native
 tools/XPathEval.class
 
diff --git a/src/main.ml b/src/main.ml
deleted file mode 100644 (file)
index d6a1986..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-(***********************************************************************)
-(*                                                                     *)
-(*                               TAToo                                 *)
-(*                                                                     *)
-(*                     Kim Nguyen, LRI UMR8623                         *)
-(*                   Université Paris-Sud & CNRS                       *)
-(*                                                                     *)
-(*  Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
-(*  Recherche Scientifique. All rights reserved.  This file is         *)
-(*  distributed under the terms of the GNU Lesser General Public       *)
-(*  License, with the special exception on linking described in file   *)
-(*  ../LICENSE.                                                        *)
-(*                                                                     *)
-(***********************************************************************)
-
-(*
-  Time-stamp: <Last modified on 2013-03-13 21:29:17 CET by Kim Nguyen>
-*)
-
-let doc =
-  let fd = open_in Sys.argv.(1) in
-  let d = Tree.Naive.load_xml_file fd in
-  close_in fd; d
-
-
-let query =
-  let arg2 = Sys.argv.(2) in
-  Xpath.Parser.parse (Ulexing.from_latin1_string arg2)
-
-let auto =
-  Xpath.Compile.path query
-
-open Format
-
-let () =
-  fprintf err_formatter "Query: %a\n%!" Xpath.Ast.print_path query;
-  fprintf err_formatter "Automata: %a\n%!" Auto.Ata.print auto;
-  fprintf err_formatter "Evaluating automaton:\n%!";
-  let module Naive = Auto.Eval.Make(Tree.Naive) in
-  let t1 = Unix.gettimeofday() in
-  let results = Naive.eval auto doc (Tree.Naive.root doc) in
-  let teval = (Unix.gettimeofday () -. t1) *. 1000. in
-  let t1 = Unix.gettimeofday () in
-  output_string stdout "<xml_result>\n";
-  List.iter (fun n ->
-    Tree.Naive.print_xml stdout doc n;
-    output_char stdout '\n'
-  ) results;
-  output_string stdout "</xml_result>\n";
-  let tprint = (Unix.gettimeofday () -. t1) *. 1000. in
-  flush stdout;
-  fprintf err_formatter "evaluation time: %fms\nserialization time: %fms\n%!" teval tprint
diff --git a/src/tatoo.ml b/src/tatoo.ml
new file mode 100644 (file)
index 0000000..d6a1986
--- /dev/null
@@ -0,0 +1,52 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                               TAToo                                 *)
+(*                                                                     *)
+(*                     Kim Nguyen, LRI UMR8623                         *)
+(*                   Université Paris-Sud & CNRS                       *)
+(*                                                                     *)
+(*  Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
+(*  Recherche Scientifique. All rights reserved.  This file is         *)
+(*  distributed under the terms of the GNU Lesser General Public       *)
+(*  License, with the special exception on linking described in file   *)
+(*  ../LICENSE.                                                        *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+  Time-stamp: <Last modified on 2013-03-13 21:29:17 CET by Kim Nguyen>
+*)
+
+let doc =
+  let fd = open_in Sys.argv.(1) in
+  let d = Tree.Naive.load_xml_file fd in
+  close_in fd; d
+
+
+let query =
+  let arg2 = Sys.argv.(2) in
+  Xpath.Parser.parse (Ulexing.from_latin1_string arg2)
+
+let auto =
+  Xpath.Compile.path query
+
+open Format
+
+let () =
+  fprintf err_formatter "Query: %a\n%!" Xpath.Ast.print_path query;
+  fprintf err_formatter "Automata: %a\n%!" Auto.Ata.print auto;
+  fprintf err_formatter "Evaluating automaton:\n%!";
+  let module Naive = Auto.Eval.Make(Tree.Naive) in
+  let t1 = Unix.gettimeofday() in
+  let results = Naive.eval auto doc (Tree.Naive.root doc) in
+  let teval = (Unix.gettimeofday () -. t1) *. 1000. in
+  let t1 = Unix.gettimeofday () in
+  output_string stdout "<xml_result>\n";
+  List.iter (fun n ->
+    Tree.Naive.print_xml stdout doc n;
+    output_char stdout '\n'
+  ) results;
+  output_string stdout "</xml_result>\n";
+  let tprint = (Unix.gettimeofday () -. t1) *. 1000. in
+  flush stdout;
+  fprintf err_formatter "evaluation time: %fms\nserialization time: %fms\n%!" teval tprint
diff --git a/tools/do_jaxp.sh b/tools/do_jaxp.sh
new file mode 100755 (executable)
index 0000000..7208ae1
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+usage() {
+    echo "error: missing input, query file"
+    echo "usage: $0 file.xml"
+}
+
+FILE="$1"
+RESULTS="$FILE".results
+QUERIES="$FILE".queries
+
+if test ! -f "$FILE" -o ! -f "$QUERIES"
+then
+   usage;
+   exit 1
+fi
+
+
+mkdir -p "$RESULTS"
+
+cat "$QUERIES" | grep -v '^#' | while read qname q
+do
+    echo "Computing $q"
+    java -cp _build/tools XPathEval "$FILE" "$q" > "$RESULTS"/"$qname"_jaxp.xml 2> "$RESULTS"/"$qname"_jaxp.log
+done
diff --git a/tools/do_tatoo.sh b/tools/do_tatoo.sh
new file mode 100755 (executable)
index 0000000..d1eea03
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+TESTPROG="./tatoo.native"
+VERSION="$(git log -1 --oneline | cut -f1 -d ' ' 2>/dev/null)"
+if [ -z "$VERSION" ]
+then
+    SUFFIX=tatoo
+else
+    SUFFIX=tatoo_"$VERSION"
+fi
+
+usage() {
+    echo "error: missing input, query file, xml_diff or $TESTPROG"
+    echo "usage: $0 file.xml"
+}
+
+FILE="$1"
+RESULTS="$FILE".results
+QUERIES="$FILE".queries
+
+if test ! -f "$FILE" -o ! -f "$QUERIES" -o ! -f "$TESTPROG"
+then
+   usage;
+   exit 1
+fi
+
+
+mkdir -p "$RESULTS"
+
+cat "$QUERIES" | grep -v '^#' | while read qname q
+do
+    echo -n "Testing $qname: $q ... "
+    "$TESTPROG" "$FILE" "$q" > "$RESULTS"/"$qname"_"$SUFFIX".xml  2> "$RESULTS"/"$qname"_"$SUFFIX".log
+    echo "ok"
+done
diff --git a/tools/do_test.sh b/tools/do_test.sh
deleted file mode 100755 (executable)
index 64748f4..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/sh
-
-TESTPROG="./main.native"
-
-usage() {
-    echo "error: missing input, query file, xml_diff or $TESTPROG"
-    echo "usage: $0 file.xml"
-}
-
-FILE="$1"
-RESULTS="$FILE".results
-QUERIES="$FILE".queries
-
-if test ! -f "$FILE" -o ! -f "$QUERIES" -o ! -f "$TESTPROG" -o ! -f xml_diff.native
-then
-   usage;
-   exit 1
-fi
-
-
-mkdir -p "$RESULTS"
-
-cat "$QUERIES" | grep -v '^#' | ( TOTAL=0; TESTS=0;
-while read qname q
-do
-    TOTAL=$(($TOTAL + 1))
-    echo -n "Testing $qname: $q ... "
-    "$TESTPROG" "$FILE" "$q" > "$RESULTS"/"$qname"_test.xml  2> "$RESULTS"/"$qname"_test.log
-    ./xml_diff.native "$RESULTS"/"$qname"_test.xml "$RESULTS"/"$qname".xml 2>> "$RESULTS"/"$qname"_test.log
-    case "$?" in
-        0)
-            TESTS=$(($TESTS + 1))
-            echo ok
-            ;;
-        *)
-            echo failed
-            # echo ------- output -----------
-            # cat "$RESULTS"/"$qname".xml
-            # echo ==========================
-            # cat "$RESULTS"/"$qname"_test.xml
-            # echo --------------------------
-            ;;
-    esac
-done;
-echo "Summary: $TESTS/$TOTAL tests successfull"
-)
diff --git a/tools/gen_test.sh b/tools/gen_test.sh
deleted file mode 100755 (executable)
index 1c9ce12..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-
-usage() {
-    echo "error: missing input, query file"
-    echo "usage: $0 file.xml"
-}
-
-FILE="$1"
-RESULTS="$FILE".results
-QUERIES="$FILE".queries
-
-if test ! -f "$FILE" -o ! -f "$QUERIES"
-then
-   usage;
-   exit 1
-fi
-
-
-mkdir -p "$RESULTS"
-
-cat "$QUERIES" | grep -v '^#' | while read qname q
-do
-    echo "Computing $q"
-    java -cp _build/tools XPathEval "$FILE" "$q" > "$RESULTS"/"$qname".xml 2> "$RESULTS"/"$qname".log
-done
diff --git a/tools/gen_test_results.sh b/tools/gen_test_results.sh
new file mode 100755 (executable)
index 0000000..925c1ce
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+PROGS="$@"
+for doc in tests/*.xml
+do
+    if [ -f "$doc".queries ]
+    then
+        cat "$doc".queries | grep -v '^#' | while read qname q
+        do
+            D=""
+            N=""
+            echo "$qname" "$q"
+            for p in $PROGS
+            do
+                echo "$p":
+                cat "$doc".results/"$qname"_"$p".log | grep --color=never time
+                N="$N_$p"
+                D="$D $doc".results/"$qname"_"$p".xml
+            done
+            echo -n "Diff ... "
+            ./xml_diff.native $D > "$doc".results/"$qname""$N".diff 2>&1
+            case "$?" in
+                "0")
+                    echo "ok"
+                    ;;
+                *)
+                    echo "failed"
+                    ;;
+            esac
+            echo "-------------------------------------------"
+        done
+    fi
+
+
+done