5 # convert dump from one CPE to test files
9 use File::Path qw/mkpath/;
10 use Data::Dump qw/dump/;
16 my $path = shift @ARGV || die "usage: $0 dump/client_ip/\n";
23 my $path = $File::Find::name;
25 return unless -l $path;
27 if ( $path =~ m!\d+-(.+)!) {
29 $requests->{$name} = $path;
31 warn "can't find request name in $path\n";
37 warn "## requests = ",dump( $requests );
39 my $test_path = 't/dump/';
44 return CWMP::Request->parse( $xml );
47 if ( my $i = $requests->{Inform} ) {
49 my $xml = read_file($i);
51 # warn "## xml: $xml\n";
53 my $state = xml2state( $xml );
55 # warn "## state = ",dump( $state );
58 $state->{Parameter}->{'InternetGatewayDevice.DeviceInfo.HardwareVersion'}
60 $state->{Parameter}->{'InternetGatewayDevice.DeviceInfo.SoftwareVersion'}
64 die "need Inform found ", dump( $requests );
67 mkpath $test_path unless -e $test_path;
69 warn "dumping new tests into $test_path\n";
71 foreach my $name ( keys %$requests ) {
72 my $from = $requests->{$name};
73 my $to = "$test_path/$name";
78 warn "## $from -> $to\n";
79 my $xml = read_file( $from );
80 write_file( $to, $xml );
81 DumpFile( "$to.yml", xml2state( $xml ) );