Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / IDL_Test / run_test.pl
blob4555a81197c488c1c26c6ca3b2b49e7e582901a6
1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
3 if 0;
5 # -*- perl -*-
7 use lib "$ENV{ACE_ROOT}/bin";
8 use PerlACE::TestTarget;
9 use File::Spec;
11 my $status =0;
12 my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
13 $SV = $server->CreateProcess ("main");
14 $test = $SV->SpawnWaitKill ($server->ProcessStartWaitInterval());
15 if ($test != 0) {
16 print STDERR "ERROR: test returned $test\n";
17 $status= 1;
20 #Redirect the screen output to the null device.
21 open (OLDOUT, ">&STDOUT");
22 open (STDOUT, ">" . File::Spec->devnull());
23 open (OLDERR, ">&STDERR");
24 open (STDERR, ">&STDOUT");
26 my $tao_idl = "$ENV{ACE_ROOT}/bin/tao_idl";
27 if (exists $ENV{HOST_ROOT}) {
28 $tao_idl = "$ENV{HOST_ROOT}/bin/tao_idl";
31 my $server2 = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
32 my $input_file2 = $server2->LocalFile ("invalid_scoping1.idl");
34 # Compile the IDL
35 $SV = $server2->CreateProcess ("$tao_idl", "$input_file2");
36 $test2 = $SV->SpawnWaitKill ($server2->ProcessStartWaitInterval());
38 my $server3 = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
39 my $input_file3 = $server3->LocalFile ("invalid_scoping2.idl");
41 # Compile the IDL
42 $SV = $server3->CreateProcess ("$tao_idl", "$input_file3");
43 $test3 = $SV->SpawnWaitKill ($server3->ProcessStartWaitInterval());
45 my $server4 = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
46 my $input_file4 = $server4->LocalFile ("keyword_case_diff.idl");
48 # Compile the IDL
49 $SV = $server4->CreateProcess ("$tao_idl", "$input_file4");
50 $test4 = $SV->SpawnWaitKill ($server4->ProcessStartWaitInterval());
52 my $server5 = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n";
53 my $input_file5 = $server5->LocalFile ("keyword_case_diff.idl");
54 my $result_filename5 = "keyword_case_diff.log";
55 my $result_file5 = $server5->LocalFile ($result_filename5);
57 open (STDERR, ">$result_file5") or die "can't redirect stderr: $!";
59 # Compile the IDL
60 $SV = $server5->CreateProcess ("$tao_idl", " -Cw $input_file5");
61 $test5 = $SV->SpawnWaitKill ($server5->ProcessStartWaitInterval());
63 open (STDERR, ">&STDOUT");
65 my $server6 = PerlACE::TestTarget::create_target (6) || die "Create target 6 failed\n";
66 my $input_file6 = $server6->LocalFile ("exception_misuse1.idl");
68 # Compile the IDL
69 $SV = $server6->CreateProcess ("$tao_idl", "$input_file6");
70 $test6 = $SV->SpawnWaitKill ($server6->ProcessStartWaitInterval());
72 my $server7 = PerlACE::TestTarget::create_target (7) || die "Create target 7 failed\n";
73 my $input_file7 = $server7->LocalFile ("exception_misuse2.idl");
75 # Compile the IDL
76 $SV = $server7->CreateProcess ("$tao_idl", "$input_file7");
77 $test7 = $SV->SpawnWaitKill ($server7->ProcessStartWaitInterval());
79 sub analyze_results {
80 my $result_file = $_[0];
82 if (! -r $result_file) {
83 print STDERR "ERROR: cannot find $result_file\n";
84 return 1;
87 my $match = 0;
88 open (FILE, $result_file) or return -1;
89 while (<FILE>) {
90 $match = /Warning - spelling differs from IDL keyword only in case:/;
91 last if $match;
93 close FILE;
95 return $match ? 0 : -1;
98 $match5 = analyze_results($result_file5);
99 $server5->DeleteFile($result_filename5);
101 #Redirect the null device output back to the screen
102 open (STDOUT, ">&OLDOUT");
103 open (STDERR, ">&OLDERR");
104 if ($test2== 0) {
105 print STDERR "ERROR: tao_idl returned $test2 for $input_file2, should have failed!\n";
106 $status = 1;
108 if ($test3== 0) {
109 print STDERR "ERROR: tao_idl returned $test3 for $input_file3, should have failed!\n";
110 $status = 1;
112 if ($test4== 0) {
113 print STDERR "ERROR: tao_idl returned $test4 for $input_file4, should have failed!\n";
114 $status = 1;
116 if ($test5!= 0) {
117 print STDERR "ERROR: tao_idl -Cw returned $test5 for $input_file5, should have succeeded!\n";
118 $status = 1;
120 if ($match5!= 0) {
121 print STDERR "ERROR: tao_idl -Cw should have printed warning for $input_file5\n";
122 $status = 1;
124 if ($test6 == 0) {
125 print STDERR "ERROR: tao_idl returned $test6 for $input_file6, should have failed!\n";
126 $status = 1;
128 if ($test7 == 0) {
129 print STDERR "ERROR: tao_idl returned $test7 for $input_file7, should have failed!\n";
130 $status = 1;
133 exit $status;