summaryrefslogtreecommitdiff
path: root/TAO/tests/RTCORBA/MT_Client_Protocol_Priority/process-output.pl
blob: 6d9b05d6b396b91e80bdbd47a9594aade68bb59d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# $Id$
# -*- perl -*-
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if 0;

# Usage:
# process-output.pl output-filename number-of-iterations priority1 priority2

# This is a Perl script that processes the output of the
# MT_Client_Protocol_Priority test run.

# The following checks are performed:
# 1) There are no errors or excpetion messages.
# 2) Both server and client termination messages are present, i.e.,
#    "Client thrreads finished" and "Server ORB event loop finished".
# 3) Number of times servant is invoked equals 2 * number of
#    iterations (for two threads).
# 4) Number of requests using iiop is equal to the number of requests using
#    shmiop, which is equal to the specified number of iterations.
# 5) Number of requests at priority1 is equal to the number of
#    requests at priority2, which is equal to the specified number of
#    iterations.

# Command-line args.
$input_file = $ARGV[0];
$iterations = $ARGV[1];
$priority1 = $ARGV[2];
$priority2 = $ARGV[3];

$errors = 0;

# Open the output file.
if ($input_file and $ARGV[1])
{
    open (DATA, $input_file);
}
else
{
    die "Usage: process-output.pl output-file-name "
        ."number-of-iterations priority1 priority2\n";
}

$thread_priority_pattern =
    "original thread priority = requested priority =";

$iiop_requests = 0;
$shmiop_requests = 0;
$priority1_requests = 0;
$priority2_requests = 0;
$threads_finished = 0;
$server_shutdown = 0;
$test_method = 0;

# Process the output.
while ($line = <DATA>)
{
    # Process the line.
    chomp $line;
    @words = split (/ /, $line);

    if ($line eq "test_method invoked")
    {
        ++$test_method;
    }

    if ($words[3] eq "SHMIOP_Server_Connection_Handler::handle_input"
        and $threads_finished == 0)
    {
        ++$shmiop_requests;
    }

    if ($words[3] eq "IIOP_Server_Connection_Handler::handle_input"
        and $threads_finished == 0)
    {
        ++$iiop_requests;
    }

    if ($line eq "Client threads finished")
    {
        $threads_finished = 1;
    }

    if ($line eq "Server ORB event loop finished")
    {
        $server_shutdown = 1;
    }

    if ($line =~ /$thread_priority_pattern/
        and $threads_finished == 0)
    {
        if ($words[10] == $priority1)
        {
            ++$priority1_requests;
        }
        elsif ($words[10] == $priority2)
        {
            ++$priority2_requests;
        }
    }

    # Make sure there are no errors or exceptions.
    if ($line =~ /error/i
        or $line =~ /exception/i)
    {
        close (DATA);
        die "Error is detected in the output file <$input_file> \n";
    }
}
close (DATA);

# Go through processing results.
if ($server_shutdown == 0
    or $threads_finished == 0)
{
    print "ERROR: Missing test over message\n";
    ++$errors;
}
elsif ($iiop_requests != $shmiop_requests
       or $iiop_requests != $iterations)
{
    print "ERROR: Number of iiop requests differs from shmiop differs from "
        ."number of iterations\n";
    ++$errors;
}
elsif (($priority1 != $priority2 
        and ($priority1_requests != $priority2_requests
             or $priority1_requests != $iterations))
       or ($priority1 == $priority2 
           and ($priority2_requests != 0 
                or $priority1_requests != 2*$iterations)))
{
    print "ERROR: Nonmatching number of requests of each priority\n";
    ++$errors;
}
elsif ($test_method != 2*$iterations)
{
    print "ERROR: Incorrect number servant invocations\n";
    ++$errors;
}
else
{
    print "Test output is ok \n";
}

exit $errors;