5 # convert dump from one CPE to test files
9 use File::Path qw/mkpath/;
10 use Data::Dump qw/dump/;
15 my $path = shift @ARGV || die "usage: $0 dump/client_ip/\n";
22 my $path = $File::Find::name;
24 return unless -l $path;
26 if ( $path =~ m!\d+-(.+)!) {
28 $requests->{$name} = $path;
30 warn "can't find request name in $path\n";
36 warn "## requests = ",dump( $requests );
38 my $test_path = 't/dump/';
40 if ( my $i = $requests->{Inform} ) {
42 my $xml = read_file($i);
45 # warn "## xml: $xml\n";
47 my $state = CWMP::Request->parse( $xml );
49 # warn "## state = ",dump( $state );
52 $state->{Parameter}->{'InternetGatewayDevice.DeviceInfo.HardwareVersion'}
54 $state->{Parameter}->{'InternetGatewayDevice.DeviceInfo.SoftwareVersion'}
58 die "need Inform found ", dump( $requests );
61 mkpath $test_path unless -e $test_path;
63 warn "dumping new tests into $test_path\n";
65 foreach my $name ( keys %$requests ) {
66 my $from = $requests->{$name};
67 my $to = "$test_path/$name";
68 warn "## $from -> $to\n";
70 write_file( $to, read_file( $from ) );