2 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
3 & eval 'exec perl -S $0 $argv:q'
6 # This is a Perl script that processes the output of the multithreaded
7 # client test. Usage: process-m-output.pl output-file-name number-of-threads
9 # The following checks are performed:
10 # 1) Number of sucessful binds equals to the number of sucessful
12 # 2) Each thread id has 1 output line for each of the following: bind,
14 # 3) There are no unexpected output lines (e.g., more lines than
15 # expected or with unexpected content like Exceptions, seg faults).
17 # Open the output file.
18 $input_file = $ARGV[0];
19 if ($input_file and $ARGV[1])
21 open (DATA
, $input_file);
25 die "Usage: process-m-output.pl output-file-name number-of-threads \n";
33 while ($line = <DATA
>)
37 @words = split (/ /, $line);
39 # Ignore the empty line, the "CommandLine:" line and the "WARNING:" line
40 # from the orbsvcs/orbsvcs/Shutdown_Utilities.cpp.
42 $words[0] eq "CommandLine:" or
43 $line =~ /WARNING: /) {
47 # Make sure the line contains expected output.
48 if (not ($words[0] eq "Unbound" or
49 $words[0] eq "Bound" or
50 $words[0] eq "Resolved" or
51 $words[0] eq "Unable"))
54 die "Error is detected in the output file <$input_file> \n";
57 # Keep track of sucessful binds/unbinds.
58 if ($words[0] eq "Bound")
62 if ($words[0] eq "Unbound")
67 # Keep track of output lines for each thread.
68 $count = $threads{$words[5]};
71 ($words[0] eq "Bound" or $words[2] eq "bind"))
73 ++$threads{$words[5]};
75 elsif ($count eq 1 and
76 ($words[0] eq "Resolved" or $words[2] eq "resolve"))
78 ++$threads{$words[5]};
80 elsif ($count eq 2 and
81 ($words[0] eq "Unbound" or $words[2] eq "unbind"))
83 ++$threads{$words[5]};
88 die "Wrong output for thread $word[5]\n";
92 # Check that each thread performed 3 operations.
93 if (grep {not $_ eq 3} values %threads)
95 die "Some thread has performed a wrong number of operations\n";
97 $number = values %threads;
98 if ($number ne $ARGV[1])
100 die "Not all threads performed operations\n";
103 # Check that number of binds equals to those of unbinds.
104 if ($binds == $unbinds)
106 print "Multithreaded output is ok \n";
110 print "Number of sucessfule binds is different from number of
111 sucessful unbinds\n";