File: 00_ptr_cast.t

package info (click to toggle)
libnet-ssleay-perl 1.36-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 940 kB
  • ctags: 798
  • sloc: perl: 3,668; ansic: 2,711; makefile: 7
file content (43 lines) | stat: -rw-r--r-- 1,154 bytes parent folder | download
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
#!/usr/bin/perl

use strict;
use warnings;
use File::Spec;
use Test::More tests => 5;
use Symbol qw(gensym);
use IPC::Open3;
use Config;

my $input  = File::Spec->catfile(qw( t local ptr_cast_test.c ));
my $output = File::Spec->catfile(qw( t local ptr_cast_test   ));

unlink $output;

my $out = gensym();
my $err = gensym();

my @extraargs;
my $cmd;
if($^O eq 'MSWin32' && $Config{cc} eq 'cl') {
  push(@extraargs, '/nologo ' . $Config{libs});
  $cmd = "$Config{cc} /Fe$output $input " . join(' ', @extraargs);
}
else {
    push(@extraargs, '-Zexe') if $^O eq 'os2';
    $cmd = "$Config{cc} -o $output $input " . join(' ', @extraargs)
}
diag( "compiling test program with: $cmd" );
my $pid = open3(undef, $out, $err, $cmd);
waitpid $pid, 0;

is( $?, 0, 'compiling ptr_cast_test.c' );

is( do { local $/ = undef; <$err>}, '', 'STDERR empty after compiling' );

$pid = open3(undef, $out, $err, "./$output");
waitpid $pid, 0;

is( $?, 0, './ptr_cast_test exited with 0' );

like( do { local $/ = undef; <$out> }, qr/ptr_cast_test:\s+ok\s+/, 'casting pointer integer and back worked' );
ok( !do { local $/ = undef; <$err> }, 'STDERR empty after running' );