4 |
|
|
5 |
my $debug = shift @ARGV; |
my $debug = shift @ARGV; |
6 |
|
|
7 |
use Test::More tests => 53; |
use Test::More tests => 73; |
8 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
9 |
use Cwd qw/abs_path/; |
use Cwd qw/abs_path/; |
10 |
use File::Slurp; |
use File::Slurp; |
21 |
ok(my $abs_path = abs_path($0), "abs_path"); |
ok(my $abs_path = abs_path($0), "abs_path"); |
22 |
$abs_path =~ s!/[^/]*$!/!; #!fix-vim |
$abs_path =~ s!/[^/]*$!/!; #!fix-vim |
23 |
|
|
24 |
|
my $path2method; |
25 |
|
my $triggers_count; |
26 |
|
|
27 |
sub file_is_deeply { |
sub file_is_deeply { |
28 |
my ( $path ) = @_; |
my ( $path ) = @_; |
29 |
|
|
31 |
|
|
32 |
diag $xml if $debug; |
diag $xml if $debug; |
33 |
|
|
34 |
|
ok( my $trigger = $path2method->{$path}, "path2method($path)" ); |
35 |
|
|
36 |
|
CWMP::Request->add_trigger( name => $trigger, callback => sub { |
37 |
|
my ( $self, $state ) = @_; |
38 |
|
$triggers_count->{$trigger}++; |
39 |
|
ok( $state, "called trigger $trigger" ); |
40 |
|
}); |
41 |
|
|
42 |
ok( my $state = CWMP::Request->parse( $xml ), 'parse' ); |
ok( my $state = CWMP::Request->parse( $xml ), 'parse' ); |
43 |
|
|
44 |
my $dump_path = $path; |
my $dump_path = $path; |
58 |
|
|
59 |
my $dir = "$abs_path/$model/"; |
my $dir = "$abs_path/$model/"; |
60 |
opendir(DIR, $dir) || die "can't opendir $dir: $!"; |
opendir(DIR, $dir) || die "can't opendir $dir: $!"; |
61 |
my @xmls = map { "$dir/$_" } grep { /\.xml$/ && -f "$dir/$_" } readdir(DIR); |
my @xmls = map { |
62 |
|
my $path = "$dir/$_"; |
63 |
|
my $method = $_; |
64 |
|
$method =~ s/\.xml$//; |
65 |
|
$path2method->{$path} = $method; |
66 |
|
$path; |
67 |
|
} grep { /\.xml$/ && -f "$dir/$_" } readdir(DIR); |
68 |
closedir DIR; |
closedir DIR; |
69 |
|
|
70 |
diag "$model has ", $#xmls + 1, " xml tests"; |
diag "$model has ", $#xmls + 1, " xml tests"; |
77 |
} |
} |
78 |
} |
} |
79 |
|
|
80 |
|
diag "triggers_count = ",dump( $triggers_count ) if $debug; |
81 |
|
|