| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::CChecker; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
31706
|
use strict; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
89
|
|
|
4
|
3
|
|
|
3
|
|
11
|
use warnings; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
91
|
|
|
5
|
3
|
|
|
3
|
|
14
|
use base qw( Test::Builder::Module ); |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
331
|
|
|
6
|
3
|
|
|
3
|
|
1601
|
use ExtUtils::CChecker; |
|
|
3
|
|
|
|
|
211010
|
|
|
|
3
|
|
|
|
|
117
|
|
|
7
|
3
|
|
|
3
|
|
1910
|
use Capture::Tiny qw( capture_merged ); |
|
|
3
|
|
|
|
|
10426
|
|
|
|
3
|
|
|
|
|
205
|
|
|
8
|
3
|
|
|
3
|
|
19
|
use Text::ParseWords qw( shellwords ); |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
127
|
|
|
9
|
3
|
|
|
3
|
|
3005
|
use Env qw( @LD_LIBRARY_PATH ); |
|
|
3
|
|
|
|
|
6441
|
|
|
|
3
|
|
|
|
|
16
|
|
|
10
|
3
|
|
|
3
|
|
448
|
use File::Spec; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
61
|
|
|
11
|
3
|
|
|
3
|
|
1334
|
use FindBin (); |
|
|
3
|
|
|
|
|
2156
|
|
|
|
3
|
|
|
|
|
51
|
|
|
12
|
3
|
|
|
3
|
|
28
|
use File::Temp (); |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
43
|
|
|
13
|
3
|
|
|
3
|
|
8
|
use Scalar::Util qw( blessed ); |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
2170
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
16
|
|
|
|
|
|
|
cc |
|
17
|
|
|
|
|
|
|
compile_ok |
|
18
|
|
|
|
|
|
|
compile_run_ok |
|
19
|
|
|
|
|
|
|
compile_with_alien |
|
20
|
|
|
|
|
|
|
compile_output_to_nowhere |
|
21
|
|
|
|
|
|
|
compile_output_to_diag |
|
22
|
|
|
|
|
|
|
compile_output_to_note |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# ABSTRACT: Test-time utilities for checking C headers, libraries, or OS features (DEPRECATED) |
|
26
|
|
|
|
|
|
|
our $VERSION = '0.08'; # VERSION |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
do { |
|
30
|
|
|
|
|
|
|
my $cc; |
|
31
|
|
|
|
|
|
|
sub cc () |
|
32
|
|
|
|
|
|
|
{ |
|
33
|
4
|
|
66
|
4
|
1
|
38
|
$cc ||= ExtUtils::CChecker->new( quiet => 0 ); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
}; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $output = ''; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub compile_run_ok ($;$) |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
2
|
|
|
2
|
1
|
361
|
my($args, $message) = @_; |
|
43
|
2
|
|
50
|
|
|
7
|
$message ||= "compile ok"; |
|
44
|
2
|
|
|
|
|
7
|
my $cc = cc(); |
|
45
|
2
|
|
|
|
|
38211
|
my $tb = __PACKAGE__->builder; |
|
46
|
|
|
|
|
|
|
|
|
47
|
2
|
|
|
|
|
21
|
my $ok; |
|
48
|
2
|
100
|
|
2
|
|
85
|
my $out = capture_merged { $ok = $cc->try_compile_run(ref($args) eq 'HASH' ? %$args : $args) }; |
|
|
2
|
|
|
|
|
2195
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
2
|
|
|
|
|
106792
|
$tb->ok($ok, $message); |
|
51
|
2
|
50
|
33
|
|
|
1521
|
if(!$ok || $output eq 'diag') |
|
|
|
50
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
{ |
|
53
|
0
|
|
|
|
|
0
|
$tb->diag($out); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
elsif($output eq 'note') |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
0
|
|
|
|
|
0
|
$tb->note($out); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
15
|
$ok; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub compile_ok ($;$) |
|
65
|
|
|
|
|
|
|
{ |
|
66
|
2
|
|
|
2
|
1
|
393
|
my($args, $message) = @_; |
|
67
|
2
|
|
50
|
|
|
7
|
$message ||= "compile ok"; |
|
68
|
2
|
100
|
|
|
|
9
|
$args = ref $args ? $args : { source => $args }; |
|
69
|
2
|
|
|
|
|
7
|
my $cc = cc(); |
|
70
|
2
|
|
|
|
|
35705
|
my $tb = __PACKAGE__->builder; |
|
71
|
|
|
|
|
|
|
|
|
72
|
2
|
|
|
|
|
43
|
my($fh, $filename) = File::Temp::tempfile("ccheckerXXXXX", SUFFIX => '.c'); |
|
73
|
2
|
|
|
|
|
1116
|
print $fh $args->{source}; |
|
74
|
2
|
|
|
|
|
157
|
close $fh; |
|
75
|
2
|
|
|
|
|
3
|
my $obj; |
|
76
|
2
|
|
|
|
|
8
|
my %compile = ( source => $filename ); |
|
77
|
2
|
100
|
|
|
|
18
|
$compile{extra_compiler_flags} = $args->{extra_compiler_flags} if defined $args->{extra_compiler_flags}; |
|
78
|
2
|
|
|
|
|
2
|
my $err; |
|
79
|
2
|
|
|
2
|
|
203
|
my $out = capture_merged { $obj = eval { $cc->compile(%compile) }; $err = $@ }; |
|
|
2
|
|
|
|
|
2407
|
|
|
|
2
|
|
|
|
|
15
|
|
|
|
2
|
|
|
|
|
68720
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
2
|
|
|
|
|
2287
|
my $ok = !!$obj; |
|
82
|
2
|
50
|
|
|
|
151
|
unlink $filename if $ok; |
|
83
|
2
|
50
|
33
|
|
|
194
|
unlink $obj if defined $obj && -f $obj; |
|
84
|
2
|
|
|
|
|
30
|
$tb->ok($ok, $message); |
|
85
|
2
|
50
|
33
|
|
|
1516
|
if(!$ok || $output eq 'diag') |
|
|
|
50
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
{ |
|
87
|
0
|
|
|
|
|
0
|
$tb->diag($out); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
elsif($output eq 'note') |
|
90
|
|
|
|
|
|
|
{ |
|
91
|
0
|
|
|
|
|
0
|
$tb->note($out); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
2
|
50
|
|
|
|
8
|
$tb->diag($err) if $err; |
|
95
|
|
|
|
|
|
|
|
|
96
|
2
|
|
|
|
|
32
|
$ok; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub compile_with_alien ($) |
|
101
|
|
|
|
|
|
|
{ |
|
102
|
0
|
|
|
0
|
1
|
|
my $alien = shift; |
|
103
|
0
|
0
|
|
|
|
|
$alien = $alien->new unless ref $alien; |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
0
|
|
|
|
|
if($alien->can('dist_dir')) |
|
106
|
|
|
|
|
|
|
{ |
|
107
|
0
|
|
|
|
|
|
my $dir = eval { File::Spec->catdir($alien->dist_dir, 'lib') }; |
|
|
0
|
|
|
|
|
|
|
|
108
|
0
|
0
|
0
|
|
|
|
unshift @LD_LIBRARY_PATH, $dir if defined $dir && -d $dir; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $tdir = File::Spec->catdir($FindBin::Bin, File::Spec->updir, '_test'); |
|
112
|
0
|
0
|
|
|
|
|
if(-d $tdir) |
|
113
|
|
|
|
|
|
|
{ |
|
114
|
|
|
|
|
|
|
cc->push_extra_compiler_flags(map { |
|
115
|
0
|
0
|
|
|
|
|
/^-I(.*)$/ ? ("-I".File::Spec->catdir($tdir, $1), $_) : ($_) |
|
|
0
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
} shellwords $alien->cflags); |
|
117
|
|
|
|
|
|
|
cc->push_extra_linker_flags(map { |
|
118
|
0
|
0
|
|
|
|
|
/^-L(.*)$/ ? ( map { push @LD_LIBRARY_PATH, $_; "-L$_" } File::Spec->catdir($tdir, $1), $_) : ($_) |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
} shellwords $alien->libs); |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
else |
|
122
|
|
|
|
|
|
|
{ |
|
123
|
0
|
|
|
|
|
|
cc->push_extra_compiler_flags(shellwords $alien->cflags); |
|
124
|
0
|
|
|
|
|
|
cc->push_extra_linker_flags(shellwords $alien->libs); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
return; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub compile_output_to_nowhere () |
|
132
|
|
|
|
|
|
|
{ |
|
133
|
0
|
|
|
0
|
1
|
|
$output = ''; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub compile_output_to_diag () |
|
138
|
|
|
|
|
|
|
{ |
|
139
|
0
|
|
|
0
|
1
|
|
$output = 'diag'; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub compile_output_to_note () |
|
144
|
|
|
|
|
|
|
{ |
|
145
|
0
|
|
|
0
|
1
|
|
$output = 'note'; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
__END__ |