ovs-ofctl: Fix del-flows command parsing bugs.
[sliver-openvswitch.git] / tests / lcov-wrapper.in
1 #! /bin/sh
2
3 abs_top_builddir='@abs_top_builddir@'
4 wrap_program=`basename '@wrap_program@'`
5
6 # Strip the first directory from $PATH that contains $wrap_program,
7 # so that below we run the real $wrap_program, not ourselves.
8 not_found=true
9 new_path=
10 first=true
11 save_IFS=$IFS
12 IFS=:
13 for dir in $PATH; do
14     IFS=$save_IFS
15     if $not_found && test -x "$dir/$wrap_program"; then
16         not_found=false
17     else
18         if $first; then
19             first=false
20             new_path=$dir
21         else
22             new_path=$new_path:$dir
23         fi
24     fi
25 done
26 IFS=$save_IFS
27 if $not_found; then
28     echo "$0: error: cannot find $wrap_program in \$PATH" >&2
29     exit 1
30 fi
31 PATH=$new_path
32 export PATH
33
34 if test "$DISABLE_LCOV" = true; then
35     exec $wrap_program "$@"
36     exit 1
37 fi
38
39 # XXX Probably want some kind of synchronization here to deal with
40 # programs running in parallel.
41 LCOV="lcov -b $abs_top_builddir -d $abs_top_builddir -q"
42 $LCOV -z
43
44 # Run the subprocess and propagate signals to it.
45 for signal in 1 2 3 5 15; do
46     trap "kill -$signal \$!     # Propagate signal
47           trap - $signal        # Reset signal to default
48           wait                  # Wait for child to die
49           kill -$signal $$      # Kill ourselves with same signal
50           exit 1                # Exit in case 'kill' failed" $signal
51 done
52 $wrap_program 0<&0 "$@" &       # 0<&0 prevents shell from closing stdin
53 exec 0</dev/null                # Don't hold stdin open unnecessarily
54 wait $!; rc=$?
55
56 # Run lcov, but only if some .gcda files were produced, since lcov
57 # complains otherwise.
58 for file in `find "$abs_top_builddir" -name '*.gcda'`; do
59     $LCOV -c -o - >> "$abs_top_builddir/tests/coverage.info"
60     break
61 done
62
63 exit $rc