diff options
Diffstat (limited to 'testsuite/systemtap.samples/transport-counts')
-rwxr-xr-x | testsuite/systemtap.samples/transport-counts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/testsuite/systemtap.samples/transport-counts b/testsuite/systemtap.samples/transport-counts new file mode 100755 index 00000000..87335cb9 --- /dev/null +++ b/testsuite/systemtap.samples/transport-counts @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +# tracks gaps (missing records) and repeats in the transport-testing +# output. If there aren't any missing records or repeats, it prints +# "test passed", otherwise "test failed" +# +# Usage: transport-counts <output file> + +$prev = 0; +$total_missing = 0; +$repeats = 0; + +open TRACEFILE, $ARGV[0] + or die "Couldn't open trace file $ARGV[0]"; + +while (<TRACEFILE>) { + chomp; + if (/\[(\d*)/) { + if ($prev + 1 != $1) { + $start_missing = $prev + 1; + $end_missing = $1 - 1; + if ($start_missing > $end_missing) { + $repeats++; + } else { + $total_missing += $end_missing - $start_missing; + } + } + $prev = $1; + } +} +print "total missing: $total_missing\n"; +print "repeats: $repeats\n"; +print "last event logged: $prev\n"; +if ($total_missing == 0 && $repeats == 0) { + print "test passed\n"; +} else { + print "test failed\n"; +} |