X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=tests%2Ftrace_matches;h=da3d95455058b7b489d45382bf07b181b0f9ce94;hb=a5723f5808f5c93ef4ae20ed11523c97db0e6269;hp=ae838fba66adf7fc8d124d9a87b65f79ceea1a0a;hpb=1ee0e522631bccee196eb95eca198a3252fe234f;p=ust.git diff --git a/tests/trace_matches b/tests/trace_matches index ae838fb..da3d954 100755 --- a/tests/trace_matches +++ b/tests/trace_matches @@ -1,20 +1,51 @@ #!/bin/bash -if [ -z "$RUNLTTV" ]; then - RUNLTTV=~/devel/lttv/runlttv -fi - function error() { - echo "$0: $@" >/dev/stderr + echo "$0: $@" 1>&2 } 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." 1>&2 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"