| 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..7\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 | 1 | ▶ | use NetAddr::IP::Util qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | inet_aton | ||||||||||||||||||||||||||||
| 13 | ipv6_n2d | ||||||||||||||||||||||||||||
| 14 | ipv6_aton | ||||||||||||||||||||||||||||
| 15 | ipanyto6 | ||||||||||||||||||||||||||||
| 16 | maskanyto6 | ||||||||||||||||||||||||||||
| 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 | 6 | ▶ | sub ok { | ||||||||||||||||||||||||||
|
Subroutine
ok: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 6 | print "ok $test\n"; | |||||||||||||||||||||||||||
| 31 | 6 | ++$test; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 1 | my $nip = inet_aton('1.2.3.4'); | |||||||||||||||||||||||||||
| 35 | 1 | my $exp = '0:0:0:0:0:0:1.2.3.4'; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | ## test 2 check 4->6 conversion | ||||||||||||||||||||||||||||
| 38 | 1 | my $nipv6 = ipanyto6($nip); | |||||||||||||||||||||||||||
| 39 | 1 | my $ipv6 = ipv6_n2d($nipv6); | |||||||||||||||||||||||||||
| 40 | 1 | ▶ | print "got: $ipv6\nexp: $exp\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | unless $ipv6 eq $exp; | ||||||||||||||||||||||||||||
| 42 | 1 | &ok; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | ## test 3 check mask4->6 extension | ||||||||||||||||||||||||||||
| 46 | 1 | $exp = 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:1.2.3.4'; | |||||||||||||||||||||||||||
| 47 | 1 | $nipv6 = maskanyto6($nip); | |||||||||||||||||||||||||||
| 48 | 1 | $ipv6 = ipv6_n2d($nipv6); | |||||||||||||||||||||||||||
| 49 | 1 | ▶ | print "got: $ipv6\nexp: $exp\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ipv6 eq $exp and &ok
MC/DC0%0/2
$ipv6 eq $exp and &ok
$ipv6 eq $exp
&ok
Truth table33%1/3
A and B
A= $ipv6 eq $expB= &ok
| |||||||||||||||||||||||||||||
| 50 | unless $ipv6 eq $exp && | ||||||||||||||||||||||||||||
| 51 | &ok; | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | ## test 4 check bad length | ||||||||||||||||||||||||||||
| 54 | 1 | $nip = pack("H9",0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09); | |||||||||||||||||||||||||||
| 55 | 1 | eval { | |||||||||||||||||||||||||||
| 56 | 1 | ipanyto6($nip); | |||||||||||||||||||||||||||
| 57 | }; | ||||||||||||||||||||||||||||
| 58 | 1 | ▶ | print "ipanyto6 accepted bad argument length\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ and $@ =~ /Bad arg.+ipanyto6/
MC/DC0%0/2
$@ and $@ =~ /Bad arg.+ipanyto6/
$@
$@ =~ /Bad arg.+ipanyto6/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad arg.+ipanyto6/
| |||||||||||||||||||||||||||||
| 59 | unless $@ && $@ =~ /Bad arg.+ipanyto6/; | ||||||||||||||||||||||||||||
| 60 | 1 | &ok; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | ## test 5 check bad length | ||||||||||||||||||||||||||||
| 63 | 1 | eval { | |||||||||||||||||||||||||||
| 64 | 1 | maskanyto6($nip); | |||||||||||||||||||||||||||
| 65 | }; | ||||||||||||||||||||||||||||
| 66 | 1 | ▶ | print "maskanyto6 accepted bad argument length\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ and $@ =~ /Bad arg.+maskanyto6/
MC/DC0%0/2
$@ and $@ =~ /Bad arg.+maskanyto6/
$@
$@ =~ /Bad arg.+maskanyto6/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad arg.+maskanyto6/
| |||||||||||||||||||||||||||||
| 67 | unless $@ && $@ =~ /Bad arg.+maskanyto6/; | ||||||||||||||||||||||||||||
| 68 | 1 | &ok; | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | ## test 6 check pass of ipv6 addrs | ||||||||||||||||||||||||||||
| 71 | 1 | $nip = ipv6_aton('::1:2.3.4.5'); | |||||||||||||||||||||||||||
| 72 | 1 | $exp = '0:0:0:0:0:1:2.3.4.5'; | |||||||||||||||||||||||||||
| 73 | 1 | $nipv6 = ipanyto6($nip); | |||||||||||||||||||||||||||
| 74 | 1 | $ipv6 = ipv6_n2d($nipv6); | |||||||||||||||||||||||||||
| 75 | 1 | ▶ | print "got: $ipv6\nexp: $exp\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | unless $ipv6 eq $exp; | ||||||||||||||||||||||||||||
| 77 | 1 | &ok; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | ## test 7 check pass of ipv6 addrs | ||||||||||||||||||||||||||||
| 80 | 1 | $nip = ipv6_aton('FFF::1:2.3.4.5'); | |||||||||||||||||||||||||||
| 81 | 1 | $exp = 'FFF:0:0:0:0:1:2.3.4.5'; | |||||||||||||||||||||||||||
| 82 | 1 | $nipv6 = maskanyto6($nip); | |||||||||||||||||||||||||||
| 83 | 1 | $ipv6 = ipv6_n2d($nipv6); | |||||||||||||||||||||||||||
| 84 | 1 | ▶ | print "got: $ipv6\nexp: $exp\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | unless $ipv6 eq $exp; | ||||||||||||||||||||||||||||
| 86 | 1 | &ok; | |||||||||||||||||||||||||||