summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Bug_2777_Regression/run_test.pl
blob: 60fbbfbcf2183912c33a245618a30564236687fe (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
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
     & eval 'exec perl -S $0 $argv:q'
     if 0;

# $Id$
# -*- perl -*-

use lib "$ENV{ACE_ROOT}/bin";
use PerlACE::TestTarget;

$status = 0;
$debug_level = '0';

foreach $i (@ARGV) {
    if ($i eq '-debug') {
        $debug_level = '10';
    }
}

my $exec_extn = "";
if ($^O eq "MSWin32") {
    $exec_extn = ".exe";
}

my @nslist_paths = (["../../../../bin", ""],
                    ["../../../bin", ""],
                    ["../../../../TAO/utils/nslist", ""]);
if (grep(($_ eq 'ARCH'), @PerlACE::ConfigList::Configs)) {
    push @nslist_paths, ["../../../../bin/" . $PerlACE::Process::ExeSubDir,
                         "../../../../bin"];
}

my $nslist_path = "";
for my $p (@nslist_paths) {
  my $use_path = ($p->[1] eq "") ? $p->[0] : $p->[1];
  if (-e $p->[0] . '/tao_nslist') {
    $nslist_path = $use_path . '/tao_nslist';
    last;
  }
  if ($exec_extn ne "" && -e $p->[0] . '/tao_nslist' . $exec_extn) {
    $nslist_path = $use_path . '/tao_nslist';
    last;
  }
}

if ($nslist_path eq "") {
    print STDERR "ERROR: tao_nslist utility not found.\n";
    exit 1;
}

## The two test targets will communicate over shared memory (SHMIOP) so they
## can't be 32-bit and 64-bit executables on the same host.
my $target_ns_list = 2;
if (exists $ENV{'DOC_TEST_2_EXE_SUBDIR'} && $ENV{'DOC_TEST_2_OS'} eq 'local' &&
    $ENV{'DOC_TEST_2_EXE_SUBDIR'} ne $PerlACE::Process::ExeSubDir) {
  $target_ns_list = 1;
}

my $ns_service = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
my $ns_list = PerlACE::TestTarget::create_target ($target_ns_list) || die "Create target $target_ns_list failed\n";

my $iorbase = "ns.ior";
my $ns_service_iorfile = $ns_service->LocalFile ($iorbase);
my $ns_list_iorfile = $ns_list->LocalFile ($iorbase);
$ns_service->DeleteFile($iorbase);
$ns_list->DeleteFile($iorbase);

$NS = $ns_service->CreateProcess ("../../../../TAO/orbsvcs/Naming_Service/tao_cosnaming",
                                  "-ORBdebuglevel $debug_level -o $ns_service_iorfile ".
                                  "-ORBObjRefStyle URL -ORBEndpoint shmiop:// -ORBSvcConfDirective ".
                                  "\"dynamic SHMIOP_Factory Service_Object ".
                                  "*TAO_Strategies:_make_TAO_SHMIOP_Protocol_Factory () ''\"");

$NSL = $ns_list->CreateProcess ($nslist_path, "-ORBSvcConfDirective \"dynamic SHMIOP_Factory Service_Object ".
                                              "*TAO_Strategies:_make_TAO_SHMIOP_Protocol_Factory () ''\" ".
                                              "-ORBInitRef NameService=file://$ns_list_iorfile --ior --ctxior ".
                                              "--node \"\" --tree \"\"");

$process_status = $NS->Spawn ();

if ($process_status != 0) {
    print STDERR "ERROR: naming service returned $process_status\n";
    exit 1;
}

if ($ns_service->WaitForFileTimed ($iorbase,
                                   $ns_service->ProcessStartWaitInterval()) == -1) {
    print STDERR "ERROR: cannot find file <$ns_service_iorfile>\n";
    $NS->Kill (); $NS->TimedWait (1);
    exit 1;
}

if ($ns_service->GetFile ($iorbase) == -1) {
    print STDERR "ERROR: cannot retrieve file <$ns_service_iorfile>\n";
    $NS->Kill (); $NS->TimedWait (1);
    exit 1;
}

if ($ns_list->PutFile ($iorbase) == -1) {
    print STDERR "ERROR: cannot set file <$ns_list_iorfile>\n";
    $NS->Kill (); $NS->TimedWait (1);
    exit 1;
}

$process_status = $NSL->SpawnWaitKill ($ns_list->ProcessStartWaitInterval() + 285);

if ($process_status != 0) {
    print STDERR "ERROR: Regression - tao_nslist returned $process_status\n";
    $status = 1;
}

$process_status = $NS->TerminateWaitKill ($ns_service->ProcessStopWaitInterval());

if ($process_status != 0) {
    print STDERR "ERROR: naming service TerminateWaitKill returned $process_status\n";
    $status = 1;
}

$ns_service->DeleteFile($iorbase);
$ns_list->DeleteFile($iorbase);

if ($status == 0) {
    print "Test passed !!\n";
}

exit $status;