3 # Copyright 2010 Ericsson AB
5 # This file is part of LTTng-UST.
7 # LTTng-UST is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # LTTng-UST is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with LTTng-UST. If not, see <http://www.gnu.org/licenses/>.
20 function starttest
() {
22 echo "------------------------------------"
23 echo "Starting test: $1"
24 echo "------------------------------------"
27 function check_trace_logs
() {
30 for f
in $
(ls $1/*.log
); do
31 NLINES
=$
(egrep "Warning|Error" $f |
wc -l)
32 if [ "$NLINES" -ne "0" ]; then
33 fail
"Errors/warnings found in $f"
37 pass
"$f was consistent"
42 function trace_matches
() {
45 #Get a textdump command
46 # if RUNLTTV is defined try to use it
47 # if LTTV variable is defined try to use it
48 # try to find lttv in the path
49 # try to find runlttv in std paths (devel/lttv/runlttv and ust/../lttv/runlttv
51 if [ ! -d "$RUNLTTV" -a -x "$RUNLTTV" ]; then
52 LTTV_TEXTDUMP_CMD
="$RUNLTTV -m text "
55 elif [ -d "$RUNLTTV" -a -x "$RUNLTTV/runlttv" ]; then
56 LTTV_TEXTDUMP_CMD
="$RUNLTTV/runlttv -m text "
59 elif [ ! -d "$LTTV" -a -x "$LTTV" ]; then
60 LTTV_TEXTDUMP_CMD
="$LTTV -m textDump "
61 LTTV_TRACE_PREFIX
="-t"
63 elif [ -d "$LTTV" -a -x "$LTTV/lttv" ]; then
64 LTTV_TEXTDUMP_CMD
="$LTTV/lttv -m textDump "
65 LTTV_TRACE_PREFIX
="-t"
67 elif [ -x "$(which lttv.real)" ]; then
68 LTTV_TEXTDUMP_CMD
="$(which lttv.real) -m textDump ";
69 LTTV_TRACE_PREFIX
="-t"
71 elif [ -x "~/devel/lttv/runlttv" ]; then
72 LTTV_TEXTDUMP_CMD
="~/devel/lttv/runlttv -m text ";
75 elif [ -x "$(dirname `readlink -f $0`)/../../lttv/runlttv" ]; then
76 LTTV_TEXTDUMP_CMD
="$(dirname `readlink -f $0`)/../../lttv/runlttv -m text "
80 echo "$0: No lttv found. Edit \$RUNLTTV to point to your lttv source directory or \$LTTV to you lttv executable." 1>&2
85 while getopts ":n:N:" options
; do
87 n
) expected_count
=$OPTARG;;
89 *) echo "Invalid option to trace_matches"
93 shift $
(($OPTIND - 1))
96 if [ -z "$pattern" ]; then
97 error
"no pattern specified"
103 error
"no trace directory specified"
106 traces
=$
(find "$2" -mindepth 1 -maxdepth 1 -type d
)
107 lttv_trace_cmd
=$LTTV_TEXTDUMP_CMD
108 for trace
in $traces; do
109 lttv_trace_cmd
="$lttv_trace_cmd $LTTV_TRACE_PREFIX $trace"
111 cnt
=$
($lttv_trace_cmd |
grep "$pattern" |
wc -l)
112 if [ -z "$expected_count" ]; then
113 if [ "$cnt" -eq "0" ]; then
114 fail
"Did not find at least one instance of $name in trace"
117 pass
"Found at least one instance of $name in trace."
121 if [ "$cnt" -ne "$expected_count" ]; then
122 fail
"Found $cnt instances of $name in trace, expected $expected_count"
125 pass
"Found $cnt instances of $name in trace."
This page took 0.033482 seconds and 4 git commands to generate.