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