From: yannick.brosseau@gmail.com (Yannick Brosseau)
Subject: [ltt-dev] [UST PATCH 1/3] Try harder to find a usable lttv in the tests scripts v2
Date: Fri, 18 Feb 2011 12:59:38 -0500 [thread overview]
Message-ID: <1298051980-20312-1-git-send-email-yannick.brosseau@gmail.com> (raw)
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
Signed-off-by: Yannick Brosseau <yannick.brosseau at gmail.com>
---
tests/test_functions.sh | 46 ++++++++++++++++++++++++++++++++++++++----
tests/trace_matches | 50 +++++++++++++++++++++++++++++++++++++++-------
2 files changed, 83 insertions(+), 13 deletions(-)
diff --git a/tests/test_functions.sh b/tests/test_functions.sh
index 40d4d89..79ade73 100644
--- a/tests/test_functions.sh
+++ b/tests/test_functions.sh
@@ -42,11 +42,44 @@ function check_trace_logs() {
function trace_matches() {
local OPTIND=
- RUNLTTV=~/devel/lttv/runlttv
+ #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 [ ! -x "$RUNLTTV" ]; then
- echo "$0: $RUNLTTV not executable. Edit \$RUNLTTV to point to your lttv source directory." >/dev/stderr
+ 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
@@ -71,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"
diff --git a/tests/trace_matches b/tests/trace_matches
index ae838fb..17a65f8 100755
--- a/tests/trace_matches
+++ b/tests/trace_matches
@@ -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"
--
1.7.2.3
next reply other threads:[~2011-02-18 17:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-18 17:59 Yannick Brosseau [this message]
2011-02-18 17:59 ` [ltt-dev] [UST PATCH 2/3] Use usttrace and libraries from the build directory in the test scripts Yannick Brosseau
2011-02-18 20:33 ` Mathieu Desnoyers
2011-02-18 17:59 ` [ltt-dev] [UST PATCH 3/3] Test for the presence of valgrind in the valgrind test Yannick Brosseau
2011-02-18 20:34 ` Mathieu Desnoyers
2011-02-18 20:32 ` [ltt-dev] [UST PATCH 1/3] Try harder to find a usable lttv in the tests scripts v2 Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1298051980-20312-1-git-send-email-yannick.brosseau@gmail.com \
--to=yannick.brosseau@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox