5 my $debug = shift @ARGV;
7 use Test::More tests => 53;
8 use Data::Dump qw/dump/;
14 use_ok('CWMP::Request');
17 my @models = ( qw/SpeedTouch-706 SpeedTouch-780/ );
19 ok( $#models + 1, 'got models' );
21 ok(my $abs_path = abs_path($0), "abs_path");
22 $abs_path =~ s!/[^/]*$!/!; #!fix-vim
27 ok( my $xml = read_file( $path ), "read_file( $path )" );
31 ok( my $state = CWMP::Request->parse( $xml ), 'parse' );
33 my $dump_path = $path;
34 $dump_path =~ s/\.xml/\.pl/;
36 write_file( $dump_path, dump( $state ) ) unless ( -e $dump_path );
38 diag "$path ? $dump_path" if $debug;
40 ok( my $hash = read_file( $dump_path ), "read_file( $dump_path )" );
41 ok ( $hash = eval "$hash", 'eval' );
43 is_deeply( $state, $hash, 'same' );
46 foreach my $model ( @models ) {
48 my $dir = "$abs_path/$model/";
49 opendir(DIR, $dir) || die "can't opendir $dir: $!";
50 my @xmls = map { "$dir/$_" } grep { /\.xml$/ && -f "$dir/$_" } readdir(DIR);
53 diag "$model has ", $#xmls + 1, " xml tests";
57 foreach my $xml_path ( @xmls ) {
58 ok ( $xml_path, 'xml path' );
59 file_is_deeply( $xml_path );