| 1 | # Before `make install' is performed this script should be runnable with | ||||||||||||||||||||
| 2 | # `make test'. After `make install' it should work as `perl test.pl' | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | ######################### We start with some black magic to print on failure. | ||||||||||||||||||||
| 5 | # Change 1..1 below to 1..last_test_to_print . | ||||||||||||||||||||
| 6 | # (It may become useful if the test is moved to ./t subdirectory.) | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 1 | ▶ | BEGIN { $| = 1; print "1..3\n"; } | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 1 | ▶ | END {print "not ok 1\n" unless $loaded;} | ||||||||||||||||||
|
Subroutine
END: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | #use diagnostics; | ||||||||||||||||||||
| 12 | 1 | ▶ | use NetAddr::IP::Util qw( | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | naip_gethostbyname | ||||||||||||||||||||
| 14 | havegethostbyname2 | ||||||||||||||||||||
| 15 | ipv6_n2x | ||||||||||||||||||||
| 16 | inet_aton | ||||||||||||||||||||
| 17 | 1 | ); | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 1 | $loaded = 1; | |||||||||||||||||||
| 20 | 1 | print "ok 1\n"; | |||||||||||||||||||
| 21 | ######################### End of black magic. | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | # Insert your test code below (better if it prints "ok 13" | ||||||||||||||||||||
| 24 | # (correspondingly "not ok 13") depending on the success of chunk 13 | ||||||||||||||||||||
| 25 | # of the test code): | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 1 | $test = 2; | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 2 | ▶ | sub ok { | ||||||||||||||||||
|
Subroutine
ok: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 30 | 2 | print "ok $test\n"; | |||||||||||||||||||
| 31 | 2 | ++$test; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 1 | my $exp = '0:0:0:0:0:FFFF:7F00:1'; | |||||||||||||||||||
| 35 | 1 | my $host = '127.1'; | |||||||||||||||||||
| 36 | 1 | my $got = ipv6_n2x( scalar naip_gethostbyname($host)); | |||||||||||||||||||
| 37 | 1 | ▶ | print "got: $got\nexp: $exp\nnot " | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 38 | unless $got eq $exp; | ||||||||||||||||||||
| 39 | 1 | &ok; | |||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 1 | $exp = '0:0:0:0:0:0:0:1'; | |||||||||||||||||||
| 42 | 1 | $host = $exp; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 1 | ▶ | if (havegethostbyname2()) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 45 | 0 | $got = ipv6_n2x(scalar naip_gethostbyname($host)); | |||||||||||||||||||
| 46 | 0 | ▶ | print "got: $got\nexp: $exp\nnot " | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | unless $got eq $exp; | ||||||||||||||||||||
| 48 | } else { | ||||||||||||||||||||
| 49 | print STDERR "\n\tgethostbyname2 missing from Socket6\n" | ||||||||||||||||||||
| 50 | 1 | ▶ | if eval{ require Socket6 }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | 1 | $got = scalar naip_gethostbyname($host); | |||||||||||||||||||
| 52 | 1 | ▶ | if ($got) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | 0 | $got = eval{ inet_ntoa($got) } || | |||||||||||||||||||
| 54 | 0 | ▶ | eval{ ipv6_n2x($got) }; | ||||||||||||||||||
|
Condition0%0/3
eval {
do {
inet_ntoa($got)
}
} || eval {
do {
ipv6_n2x($got)
}
}
MC/DC0%0/2
eval {
do {
inet_ntoa($got)
}
} || eval {
do {
ipv6_n2x($got)
}
}
eval {
do {
inet_ntoa($got)
}
}
eval {
do {
ipv6_n2x($got)
}
}
Truth table0%0/3
A || B
A= eval {
do {
inet_ntoa($got)
}
}B= eval {
do {
ipv6_n2x($got)
}
}
| |||||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | 1 | ▶ | print "unexpected return value got: $got\nnot " | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | if $got; | ||||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | 1 | &ok; | |||||||||||||||||||