Rename for the new liburcu API namespace
[ust.git] / tests / trace_matches
... / ...
CommitLineData
1#!/bin/bash
2
3if [ -z "$RUNLTTV" ]; then
4 RUNLTTV=~/devel/lttv/runlttv
5fi
6
7function error() {
8 echo "$0: $@" >/dev/stderr
9}
10
11function usage() {
12 echo "Usage: $0 [ -N pattern_name ] [ -n pattern_count ] PATTERN TRACE_PARENT_DIR"
13}
14
15if [ ! -x "$RUNLTTV" ]; then
16 echo "$0: $RUNLTTV not executable. Edit \$RUNLTTV to point to your lttv source directory." >/dev/stderr
17 exit 1;
18fi
19
20while getopts ":n:N:" options; do
21 case "$options" in
22 n) expected_count=$OPTARG;;
23 N) name=$OPTARG;;
24 h) usage;
25 exit 0;;
26 \?) usage
27 exit 1;;
28 *) usage
29 exit 1;;
30 esac
31done
32shift $(($OPTIND - 1))
33
34pattern=$1
35if [ -z "$pattern" ]; then
36 error "no pattern specified"
37 usage
38 exit 1
39fi
40
41if [ -z "$2" ]; then
42 error "no trace directory specified"
43 usage
44 exit 1
45fi
46traces=$(find "$2" -mindepth 1 -maxdepth 1 -type d)
47
48echo -n "Analyzing trace ($name): "
49
50cnt=$($RUNLTTV -m text "$traces" | grep "$pattern" | wc -l)
51if [ -z "$expected_count" ]; then
52 if [ "$cnt" -eq "0" ]; then
53 echo "ERROR"
54 echo "Did not find at least one instance of this event ($cnt)"
55 exit 1
56 else
57 echo "Success"
58 exit 0
59 fi
60else
61 if [ "$cnt" -ne "$expected_count" ]; then
62 echo "ERROR"
63 echo "Expected: $expected_count"
64 echo "In trace: $cnt"
65 exit 1
66 else
67 echo "Success"
68 exit 0
69 fi
70fi
This page took 0.021913 seconds and 4 git commands to generate.