Debian lenny version packages
[pkg-perl] / deb-src / libnet-ssleay-perl / libnet-ssleay-perl-1.35 / t / local / 00_ptr_cast.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use File::Spec;
6 use Test::More tests => 5;
7 use Symbol qw(gensym);
8 use IPC::Open3;
9 use Config;
10
11 my $input  = File::Spec->catfile(qw( t local ptr_cast_test.c ));
12 my $output = File::Spec->catfile(qw( t local ptr_cast_test   ));
13
14 unlink $output;
15
16 my $out = gensym();
17 my $err = gensym();
18
19 my @extraargs;
20 push(@extraargs, '/nologo') if $^O eq 'MSWin32' && $Config{cc} eq 'cl';
21 my $cmd = "$Config{cc} -o $output $input " . join(' ', @extraargs);
22 diag( "compiling test program with: $cmd" );
23 my $pid = open3(undef, $out, $err, $cmd);
24 waitpid $pid, 0;
25
26 is( $?, 0, 'compiling ptr_cast_test.c' );
27
28 is( do { local $/ = undef; <$err>}, '', 'STDERR empty after compiling' );
29
30 $pid = open3(undef, $out, $err, "./$output");
31 waitpid $pid, 0;
32
33 is( $?, 0, './ptr_cast_test exited with 0' );
34
35 like( do { local $/ = undef; <$out> }, qr/ptr_cast_test:\s+ok\s+/, 'casting pointer integer and back worked' );
36 ok( !do { local $/ = undef; <$err> }, 'STDERR empty after running' );