#!/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 $prev = 0; $total_missing = 0; $repeats = 0; open TRACEFILE, $ARGV[0] or die "Couldn't open trace file $ARGV[0]"; while () { 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"; }