Try harder to find a usable lttv in the tests scripts v2
authorYannick Brosseau <yannick.brosseau@gmail.com>
Fri, 18 Feb 2011 21:55:25 +0000 (16:55 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Fri, 18 Feb 2011 21:55:25 +0000 (16:55 -0500)
Add many more attempts to auto-detect the path to the lttv executable or
the runlttv script in trace comparison tests.
Also support setting the LTTV env variable to directly set a path the
the lttv executable in addition to the RUNLTTV variable

Changelog:
   Correctly manage multiple traces

[ Edit: fix merge conflict ]

Signed-off-by: Yannick Brosseau <yannick.brosseau@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/test_functions.sh
tests/trace_matches

index 4f789ab1c4327a00d37685b9bda2cfc84d2e79e0..79ade73d6ad1bb840ec6b8f1f9f6fd99e18de053 100644 (file)
@@ -42,9 +42,44 @@ function check_trace_logs() {
 function trace_matches() {
     local OPTIND=
 
-    if [ ! -x "$RUNLTTV" ]; then
-       echo "$0: $RUNLTTV not executable. Edit \$RUNLTTV to point to your lttv source directory." >/dev/stderr
+    #Get a textdump command
+    # if RUNLTTV is defined try to use it
+    # if LTTV variable is defined try to use it
+    # try to find lttv in the path
+    # try to find runlttv in std paths (devel/lttv/runlttv and ust/../lttv/runlttv
+
+    if [ ! -d "$RUNLTTV" -a -x "$RUNLTTV" ]; then
+       LTTV_TEXTDUMP_CMD="$RUNLTTV -m text "
+       LTTV_TRACE_PREFIX=""
+       
+    elif [ -d "$RUNLTTV" -a -x "$RUNLTTV/runlttv" ]; then 
+       LTTV_TEXTDUMP_CMD="$RUNLTTV/runlttv -m text "
+       LTTV_TRACE_PREFIX=""
+
+    elif [ ! -d "$LTTV" -a -x "$LTTV" ]; then
+       LTTV_TEXTDUMP_CMD="$LTTV -m textDump "
+       LTTV_TRACE_PREFIX="-t"
+
+    elif [ -d "$LTTV" -a -x "$LTTV/lttv" ]; then
+       LTTV_TEXTDUMP_CMD="$LTTV/lttv -m textDump "
+       LTTV_TRACE_PREFIX="-t"
+       
+    elif [ -x "$(which lttv.real)" ]; then
+       LTTV_TEXTDUMP_CMD="$(which lttv.real) -m textDump ";
+       LTTV_TRACE_PREFIX="-t"
+       
+    elif [ -x "~/devel/lttv/runlttv" ]; then
+       LTTV_TEXTDUMP_CMD="~/devel/lttv/runlttv -m text ";
+       LTTV_TRACE_PREFIX=""
+
+    elif [ -x "$(dirname `readlink -f $0`)/../../lttv/runlttv" ]; then
+       LTTV_TEXTDUMP_CMD="$(dirname `readlink -f $0`)/../../lttv/runlttv -m text "
+       LTTV_TRACE_PREFIX=""
+
+    else
+       echo "$0: No lttv found. Edit \$RUNLTTV to point to your lttv source directory or \$LTTV to you lttv executable." >/dev/stderr
        exit 1;
+
     fi
 
     while getopts ":n:N:" options; do
@@ -69,8 +104,11 @@ function trace_matches() {
        return 1
     fi
     traces=$(find "$2" -mindepth 1 -maxdepth 1 -type d)
-
-    cnt=$($RUNLTTV -m text "$traces" | grep "$pattern" | wc -l)
+    lttv_trace_cmd=$LTTV_TEXTDUMP_CMD
+    for trace in $traces; do
+       lttv_trace_cmd="$lttv_trace_cmd $LTTV_TRACE_PREFIX $trace"
+    done
+    cnt=$($lttv_trace_cmd | grep "$pattern" | wc -l)
     if [ -z "$expected_count" ]; then
        if [ "$cnt" -eq "0" ]; then
            fail "Did not find at least one instance of $name in trace"
index ae838fba66adf7fc8d124d9a87b65f79ceea1a0a..17a65f8ccf1008a5003483f7af592bced56f122c 100755 (executable)
@@ -1,9 +1,5 @@
 #!/bin/bash
 
-if [ -z "$RUNLTTV" ]; then
-       RUNLTTV=~/devel/lttv/runlttv
-fi
-
 function error() {
        echo "$0: $@" >/dev/stderr
 }
@@ -12,9 +8,44 @@ function usage() {
        echo "Usage: $0 [ -N pattern_name ] [ -n pattern_count ] PATTERN TRACE_PARENT_DIR"
 }
 
-if [ ! -x "$RUNLTTV" ]; then
-       echo "$0: $RUNLTTV not executable. Edit \$RUNLTTV to point to your lttv source directory." >/dev/stderr
+#Get a textdump command
+# if RUNLTTV is defined try to use it
+# if LTTV variable is defined try to use it
+# try to find lttv in the path
+# try to find runlttv in std paths (devel/lttv/runlttv and ust/../lttv/runlttv
+
+if [ ! -d "$RUNLTTV" -a -x "$RUNLTTV" ]; then
+       LTTV_TEXTDUMP_CMD="$RUNLTTV -m text "
+       LTTV_TRACE_PREFIX=""
+
+elif [ -d "$RUNLTTV" -a -x "$RUNLTTV/runlttv" ]; then 
+       LTTV_TEXTDUMP_CMD="$RUNLTTV/runlttv -m text "
+       LTTV_TRACE_PREFIX=""
+
+elif [ ! -d "$LTTV" -a -x "$LTTV" ]; then
+       LTTV_TEXTDUMP_CMD="$LTTV -m textDump "
+       LTTV_TRACE_PREFIX="-t"
+               
+elif [ -d "$LTTV" -a -x "$LTTV/lttv" ]; then
+       LTTV_TEXTDUMP_CMD="$LTTV/lttv -m textDump "
+       LTTV_TRACE_PREFIX="-t"
+
+elif [ -x "$(which lttv.real)" ]; then
+       LTTV_TEXTDUMP_CMD="$(which lttv.real) -m textDump ";
+       LTTV_TRACE_PREFIX="-t"
+
+elif [ -x "~/devel/lttv/runlttv" ]; then
+       LTTV_TEXTDUMP_CMD="~/devel/lttv/runlttv -m text ";
+       LTTV_TRACE_PREFIX=""
+
+elif [ -x "$(dirname `readlink -f $0`)/../../lttv/runlttv" ]; then
+       LTTV_TEXTDUMP_CMD="$(dirname `readlink -f $0`)/../../lttv/runlttv -m text "
+       LTTV_TRACE_PREFIX=""
+
+else
+       echo "$0: No lttv found. Edit \$RUNLTTV to point to your lttv source directory or \$LTTV to you lttv executable." >/dev/stderr
        exit 1;
+
 fi
 
 while getopts ":n:N:" options; do
@@ -44,10 +75,13 @@ if [ -z "$2" ]; then
        exit 1
 fi
 traces=$(find "$2" -mindepth 1 -maxdepth 1 -type d)
-
+lttv_trace_cmd=$LTTV_TEXTDUMP_CMD
+for trace in $traces; do
+       lttv_trace_cmd="$lttv_trace_cmd $LTTV_TRACE_PREFIX $trace"
+done
 echo -n "Analyzing trace ($name): "
 
-cnt=$($RUNLTTV -m text "$traces" | grep "$pattern" | wc -l)
+cnt=$($lttv_trace_cmd | grep "$pattern" | wc -l)
 if [ -z "$expected_count" ]; then
        if [ "$cnt" -eq "0" ]; then
                echo "ERROR"
This page took 0.027694 seconds and 4 git commands to generate.