| 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 | 1 | $| = 1; | |||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | END {print "1..1\nnot ok 1\n" unless $test;} | ||||||||||||||||||||||||||||||
|
Subroutine
END: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | #use diagnostics; | ||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use NetAddr::IP::Util qw( | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | ipv6_n2d | ||||||||||||||||||||||||||||||||
| 13 | inet_aton | ||||||||||||||||||||||||||||||||
| 14 | ipv6_aton | ||||||||||||||||||||||||||||||||
| 15 | inet_4map6 | ||||||||||||||||||||||||||||||||
| 16 | 1 | ); | |||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 1 | $test = 1; | |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 6 | ▶ | sub ok { | ||||||||||||||||||||||||||||||
|
Subroutine
ok: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 21 | 6 | print "ok $test\n"; | |||||||||||||||||||||||||||||||
| 22 | 6 | ++$test; | |||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | # Insert your test code below (better if it prints "ok 13" | ||||||||||||||||||||||||||||||||
| 26 | # (correspondingly "not ok 13") depending on the success of chunk 13 | ||||||||||||||||||||||||||||||||
| 27 | # of the test code): | ||||||||||||||||||||||||||||||||
| 28 | 1 | print "1..6\n"; | |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 1 | my @stuff = qw( | |||||||||||||||||||||||||||||||
| 31 | 192.168.1.1 | ||||||||||||||||||||||||||||||||
| 32 | 1.2.3.4 | ||||||||||||||||||||||||||||||||
| 33 | ::3.4.5.6 | ||||||||||||||||||||||||||||||||
| 34 | ::FFFF:4.5.6.7 | ||||||||||||||||||||||||||||||||
| 35 | ::1:5.4.3.2 | ||||||||||||||||||||||||||||||||
| 36 | ::FEFF:4.3.2.1 | ||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 1 | my $p4 = '0:0:0:0:0:FFFF:'; | |||||||||||||||||||||||||||||||
| 40 | 1 | my $p6 = '0:0:0:0:0:'; | |||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | 1 | foreach(0..$#stuff) { | |||||||||||||||||||||||||||||||
| 43 | 6 | my $pass = 1; | |||||||||||||||||||||||||||||||
| 44 | 6 | my $result; | |||||||||||||||||||||||||||||||
| 45 | my $bstr; | ||||||||||||||||||||||||||||||||
| 46 | 6 | ▶ | $pass = 0 if $_ > 3; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 47 | 6 | ▶ | if ($stuff[$_] =~ /\:/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 48 | 4 | $bstr = ipv6_aton($stuff[$_]); | |||||||||||||||||||||||||||||||
| 49 | 4 | ▶ | my $prefix = ($stuff[$_] =~ /^\:\:F/) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 50 | ? $p6 : $p4; | ||||||||||||||||||||||||||||||||
| 51 | 4 | ($result = $stuff[$_]) =~ s/\:\:/$prefix/; | |||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||
| 53 | else { | ||||||||||||||||||||||||||||||||
| 54 | 2 | $bstr = inet_aton($stuff[$_]); | |||||||||||||||||||||||||||||||
| 55 | 2 | $result = $p4 . $stuff[$_]; | |||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | 6 | my $rv = inet_4map6($bstr); | |||||||||||||||||||||||||||||||
| 58 | 6 | ▶ | if ($pass && ! $rv) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$pass and not $rv
MC/DC0%0/2
$pass and not $rv
$pass
not $rv
Truth table66%2/3
A and not(B)
A= $passB= not $rv
| |||||||||||||||||||||||||||||||||
| 59 | 0 | print "failed to return valid address\nnot "; | |||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||
| 61 | elsif ($pass) { | ||||||||||||||||||||||||||||||||
| 62 | 4 | $rv = ipv6_n2d($rv); | |||||||||||||||||||||||||||||||
| 63 | 4 | ▶ | print "got: $rv, exp: $result\nnot " unless $rv eq $result; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||
| 65 | else { | ||||||||||||||||||||||||||||||||
| 66 | 2 | ▶ | print 'unknown return ', ipv6_n2d($rv), "\nnot " if $rv; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | 6 | &ok; | |||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||