#!/usr/bin/perl
#
# Use this script with -DVERIFY_TRANSFER.  record framework will print out
# src-dest.send and src-dest.recv files.  This lists all of these files, 
# makes sure that there are even numbers and matching sends and recvs, and
# makes sure that the rsd queues in each match.
#
# If this prints output besides stating it is diffing something, there are 
# differences that need to be fixed.
#
# Added by Todd Gamblin 10/4/2007.
#

my @rfiles = split(/\n/, `ls *.recv | sort`);
my @sfiles = split(/\n/, `ls *.send | sort`);

while (my $send = pop(@sfiles)) {
    unless (@rfiles) {
	print "More sends than recvs!\n";
	exit(1);
    }

    my $recv = pop(@rfiles);

    $send =~ s/\.send$//;
    $recv =~ s/\.recv$//;

    if ($send ne $recv) {
	print "Error: no matching recv for ".$send.".send\n";
	exit(1);
    }

    print "diffing $send.send $recv.recv\n";
    system("diff $send.send $recv.recv");
}

if (@rfiles) {
    print "more recvs than sends!\n";
    exit(1);
}
