X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=tests%2Ftrace_matches;fp=tests%2Ftrace_matches;h=c2135c1801a5886bdc34308b0a6a456972f5a36b;hb=1518fa0fad67101416c2def6b1c88ec767e8b5eb;hp=0000000000000000000000000000000000000000;hpb=25ea915c3c33bf3aafa4436b66a6699f0292bb4b;p=ust.git diff --git a/tests/trace_matches b/tests/trace_matches new file mode 100755 index 0000000..c2135c1 --- /dev/null +++ b/tests/trace_matches @@ -0,0 +1,67 @@ +#!/bin/bash + +RUNLTTV=~/devel/lttv/runlttv + +function error() { + echo "$0: $@" >/dev/stderr +} + +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 + exit 1; +fi + +while getopts ":n:N:" options; do + case "$options" in + n) expected_count=$OPTARG;; + N) name=$OPTARG;; + h) usage; + exit 0;; + \?) usage + exit 1;; + *) usage + exit 1;; + esac +done +shift $(($OPTIND - 1)) + +pattern=$1 +if [ -z "$pattern" ]; then + error "no pattern specified" + usage + exit 1 +fi + +if [ -z "$2" ]; then + error "no trace directory specified" + usage + exit 1 +fi +traces=$(find "$2" -mindepth 1 -maxdepth 1 -type d) + +echo -n "Analyzing trace ($name): " + +cnt=$($RUNLTTV -m text "$traces" | grep "$pattern" | wc -l) +if [ -z "$expected_count" ]; then + if [ "$cnt" -eq "0" ]; then + echo "ERROR" + echo "Did not find at least one instance of this event ($cnt)" + else + echo "Success" + exit 0 + fi +else + if [ "$cnt" -ne "$expected_count" ]; then + echo "ERROR" + echo "Expected: $expected_count" + echo "In trace: $cnt" + exit 1 + else + echo "Success" + exit 0 + fi +fi