xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/t/run/switchd.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl -w
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateBEGIN {
4*0Sstevel@tonic-gate    chdir 't' if -d 't';
5*0Sstevel@tonic-gate    @INC = qw(../lib lib);
6*0Sstevel@tonic-gate}
7*0Sstevel@tonic-gate
8*0Sstevel@tonic-gaterequire "./test.pl";
9*0Sstevel@tonic-gate
10*0Sstevel@tonic-gateplan(tests => 1);
11*0Sstevel@tonic-gate
12*0Sstevel@tonic-gatemy $r;
13*0Sstevel@tonic-gatemy @tmpfiles = ();
14*0Sstevel@tonic-gateEND { unlink @tmpfiles }
15*0Sstevel@tonic-gate
16*0Sstevel@tonic-gatemy $filename = 'swdtest.tmp';
17*0Sstevel@tonic-gateSKIP: {
18*0Sstevel@tonic-gate	open my $f, ">$filename"
19*0Sstevel@tonic-gate	    or skip( "Can't write temp file $filename: $!" );
20*0Sstevel@tonic-gate	print $f <<'__SWDTEST__';
21*0Sstevel@tonic-gatepackage Bar;
22*0Sstevel@tonic-gatesub bar { $_[0] * $_[0] }
23*0Sstevel@tonic-gatepackage Foo;
24*0Sstevel@tonic-gatesub foo {
25*0Sstevel@tonic-gate  my $s;
26*0Sstevel@tonic-gate  $s += Bar::bar($_) for 1..$_[0];
27*0Sstevel@tonic-gate}
28*0Sstevel@tonic-gatepackage main;
29*0Sstevel@tonic-gateFoo::foo(3);
30*0Sstevel@tonic-gate__SWDTEST__
31*0Sstevel@tonic-gate    close $f;
32*0Sstevel@tonic-gate    push @tmpfiles, $filename;
33*0Sstevel@tonic-gate    $| = 1; # Unbufferize.
34*0Sstevel@tonic-gate    $r = runperl(
35*0Sstevel@tonic-gate		 switches => [ '-Ilib', '-d:switchd' ],
36*0Sstevel@tonic-gate		 progfile => $filename,
37*0Sstevel@tonic-gate		);
38*0Sstevel@tonic-gate    like($r, qr/^main,swdtest.tmp,9;Foo,swdtest.tmp,5;Foo,swdtest.tmp,6;Foo,swdtest.tmp,6;Bar,swdtest.tmp,2;Bar,swdtest.tmp,2;Bar,swdtest.tmp,2;$/i);
39*0Sstevel@tonic-gate}
40*0Sstevel@tonic-gate
41