runtests run the real test-libmallocwrap/.libs/prog
[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)"
53 else
54 echo "Success"
55 exit 0
56 fi
57else
58 if [ "$cnt" -ne "$expected_count" ]; then
59 echo "ERROR"
60 echo "Expected: $expected_count"
61 echo "In trace: $cnt"
62 exit 1
63 else
64 echo "Success"
65 exit 0
66 fi
67fi
This page took 0.023478 seconds and 4 git commands to generate.