| 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..4\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_ntoa | ||||||||||||||||||||||||||||
| 13 | inet_any2n | ||||||||||||||||||||||||||||
| 14 | ipv6_n2d | ||||||||||||||||||||||||||||
| 15 | ipv6to4 | ||||||||||||||||||||||||||||
| 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 | 3 | ▶ | sub ok { | ||||||||||||||||||||||||||
|
Subroutine
ok: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 3 | print "ok $test\n"; | |||||||||||||||||||||||||||
| 30 | 3 | ++$test; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | my $nip = inet_any2n('1.2.3.4'); | |||||||||||||||||||||||||||
| 34 | 1 | my $exp = '0:0:0:0:0:0:1.2.3.4'; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | ## test 2 check that we have an ipv6 netaddr | ||||||||||||||||||||||||||||
| 37 | 1 | my $ipv6 = ipv6_n2d($nip); | |||||||||||||||||||||||||||
| 38 | 1 | ▶ | print "got: $ipv6\nexp: $exp\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | unless $ipv6 eq $exp; | ||||||||||||||||||||||||||||
| 40 | 1 | &ok; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | ## test 3 check conversion back to ipv4 | ||||||||||||||||||||||||||||
| 43 | 1 | $exp = '1.2.3.4'; | |||||||||||||||||||||||||||
| 44 | 1 | ▶ | print "got: $_, exp: $exp\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | unless inet_ntoa(ipv6to4($nip)) eq $exp; | ||||||||||||||||||||||||||||
| 46 | 1 | &ok; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | ## test 4 check bad length | ||||||||||||||||||||||||||||
| 49 | 1 | $nip = pack("H9",0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09); | |||||||||||||||||||||||||||
| 50 | 1 | eval { | |||||||||||||||||||||||||||
| 51 | 1 | ipv6to4($nip); | |||||||||||||||||||||||||||
| 52 | }; | ||||||||||||||||||||||||||||
| 53 | 1 | ▶ | print "ipv6to4 accepted bad argument length\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ and $@ =~ /Bad arg.+ipv6to4/
MC/DC0%0/2
$@ and $@ =~ /Bad arg.+ipv6to4/
$@
$@ =~ /Bad arg.+ipv6to4/
Truth table33%1/3
A and B
A= $@B= $@ =~ /Bad arg.+ipv6to4/
| |||||||||||||||||||||||||||||
| 54 | unless $@ && $@ =~ /Bad arg.+ipv6to4/; | ||||||||||||||||||||||||||||
| 55 | 1 | &ok; | |||||||||||||||||||||||||||