| 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..20\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::InetBase qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | ipv6_ntoa | ||||||||||||||||||||||||||||
| 14 | inet_pton | ||||||||||||||||||||||||||||
| 15 | AF_INET6 | ||||||||||||||||||||||||||||
| 16 | 1 | ); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | $loaded = 1; | |||||||||||||||||||||||||||
| 19 | 1 | print "ok 1\n"; | |||||||||||||||||||||||||||
| 20 | ######################### End of black magic. | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # Insert your test code below (better if it prints "ok 13" | ||||||||||||||||||||||||||||
| 23 | # (correspondingly "not ok 13") depending on the success of chunk 13 | ||||||||||||||||||||||||||||
| 24 | # of the test code): | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | $test = 2; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 19 | ▶ | sub ok { | ||||||||||||||||||||||||||
|
Subroutine
ok: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 19 | print "ok $test\n"; | |||||||||||||||||||||||||||
| 30 | 19 | ++$test; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | ## test 2 - 19 add stuff to buffer | ||||||||||||||||||||||||||||
| 34 | 1 | my @num = # in exphex | |||||||||||||||||||||||||||
| 35 | qw( | ||||||||||||||||||||||||||||
| 36 | :: :: | ||||||||||||||||||||||||||||
| 37 | 43:: 43:: | ||||||||||||||||||||||||||||
| 38 | ::21 ::21 | ||||||||||||||||||||||||||||
| 39 | ::1:2:3:4:5:6:7 0:1:2:3:4:5:6:7 | ||||||||||||||||||||||||||||
| 40 | 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:0 | ||||||||||||||||||||||||||||
| 41 | 1::8 1::8 | ||||||||||||||||||||||||||||
| 42 | FF00::FFFF ff00::ffff | ||||||||||||||||||||||||||||
| 43 | FFFF::FFFF:FFFF ffff::ffff:ffff | ||||||||||||||||||||||||||||
| 44 | A1B2:C3D4:E5D6:F7E8:08F9:190A:1.2.3.4 a1b2:c3d4:e5d6:f7e8:8f9:190a:102:304 | ||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 1 | ▶ | for (my $i=0;$i<@num;$i+=2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 9 | my $bits = inet_pton(AF_INET6(),$num[$i]); | |||||||||||||||||||||||||||
| 49 | 9 | my $len = length($bits); | |||||||||||||||||||||||||||
| 50 | 9 | ▶ | print "bad len = $len, exp: 16\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | unless $len == 16; # 16 bytes x 8 bits | ||||||||||||||||||||||||||||
| 52 | 9 | &ok; | |||||||||||||||||||||||||||
| 53 | 9 | my $ipv6x = ipv6_ntoa($bits); | |||||||||||||||||||||||||||
| 54 | 9 | ▶ | print "got: $ipv6x\nexp: $num[$i +1]\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | unless $ipv6x eq $num[$i +1]; | ||||||||||||||||||||||||||||
| 56 | 9 | &ok; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | ## test 32 check bad length ntop | ||||||||||||||||||||||||||||
| 60 | 1 | my $try = '1234'; | |||||||||||||||||||||||||||
| 61 | 1 | my $notempty = eval { | |||||||||||||||||||||||||||
| 62 | 1 | ipv6_ntoa($try); | |||||||||||||||||||||||||||
| 63 | }; | ||||||||||||||||||||||||||||
| 64 | 1 | ▶ | print "failed bad argument length test for ipv6_ntoa\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ and $@ =~ /Bad arg/
MC/DC0%0/2
$@ and $@ =~ /Bad arg/
$@
$@ =~ /Bad arg/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad arg/
| |||||||||||||||||||||||||||||
| 65 | unless $@ && $@ =~ /Bad arg/; | ||||||||||||||||||||||||||||
| 66 | 1 | &ok; | |||||||||||||||||||||||||||