Check/Test/host_syntax.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 66 CC 6 SCAR 29.1
CC
6
Cov
0%
test
30.0
new
6.0
BEGIN
2.0
CRAP 18.4
1 package Net::DNS::Check::Test::host_syntax;
2  
3 use strict;
4 use vars qw(@ISA $VERSION);
5  
6 @ISA = qw(Net::DNS::Check::Test);
7  
8  
9 sub new {
10 my ($class) = shift;
11  
12 my ($self) = bless {}, $class;
13  
14 if ( @_ ) {
15 $self->_process_args(@_);
16 }
17  
18 $self->test();
19  
20 return $self;
21 }
22  
23  
24  
25 sub test() {
26 my ($self) = shift;
27  
28 my $test_status = 1;
29 my @host_array;
30 my $test_detail = {};
31  
32
33
34 foreach my $nsquery ( @{$self->{nsquery}} ) {
35 push (@host_array, $nsquery->hostslist()->get_list());
36 }
37  
38 push (@host_array, $self->{hostslist}->get_list());
39  
40 foreach my $hostname ( @host_array ) {
41  
42 next if ( exists $test_detail->{$hostname} );
43  
44 my $status = 1;
45 if (length($hostname) > 255 ) {
46 $status = 0;
47 }
48  
49 my @labels = split('\.', $hostname);
50 my $tld = pop @labels;
51  
52 unless ( $tld =~ /^[a-z]+$/ ) {
53 $status = 0;
54 }
55  
56 foreach my $label ( @labels ) {
57 if ( length($label) > 63 || $label !~ /^([0-9a-z]+(-+[0-9a-z]+)*|[a-z0-9]+)$/ ) {
58 $status = 0;
59 }
60 }
61 $test_detail->{$hostname}->{status} = $status;
62 $test_detail->{$hostname}->{desc} = '';
63 $test_status &&= $status;
64 }
65  
66 $self->{test_status} = $test_status;
67 $self->{test_detail} = $test_detail;
68  
69 return $test_status;
70 }
71  
72 1;
73  
74 __END__