My/CanTrace.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 13 | 14 | 92.8 |
branch | 1 | 2 | 50.0 |
condition | 2 | 6 | 33.3 |
subroutine | 3 | 3 | 100.0 |
pod | n/a | ||
total | 19 | 25 | 76.0 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package My::CanTrace; | ||||||
2 | 2 | 2 | 9034 | use Test::More; | |||
2 | 4 | ||||||
2 | 14 | ||||||
3 | 2 | 2 | 1318 | use POSIX (); | |||
2 | 6578 | ||||||
2 | 231 | ||||||
4 | |||||||
5 | sub import { | ||||||
6 | 2 | 2 | 17 | my $class = shift; | |||
7 | |||||||
8 | 2 | 3 | my $ok = 0; | ||||
9 | 2 | 5 | for(qw(strace ktrace truss)) { | ||||
10 | 6 | 33716 | system "$_ 2>/dev/null"; | ||||
11 | 6 | 33 | 941 | $ok ||= POSIX::WIFEXITED($?) && POSIX::WEXITSTATUS($?) == 1; | |||
33 | |||||||
12 | } | ||||||
13 | |||||||
14 | 2 | 50 | 203 | if($ok) { | |||
15 | 0 | 0 | plan @_; | ||||
16 | } else { | ||||||
17 | 2 | 53 | plan skip_all => "No tracing programs available"; | ||||
18 | } | ||||||
19 | } | ||||||
20 | |||||||
21 | 1; |