#!/usr/bin/perl -wT # $Id: 80-File.t,v 1.10 2003/06/06 19:52:05 unimlo Exp $ use strict; use Test::More tests => 171; eval <{$type}->{$name}; ok(defined $list1,"Got something for $type $name"); next unless defined $list1; ok($list1->isa('Net::ACL::File'),"Load $type $name"); ok($list1->name eq $name,"Name $type $name"); ok($list1->type eq $type,"Type $type $name"); my $list2 = renew Net::ACL( Name => $name, Type => $type ); ok($list2->isa('Net::ACL'),"Renew $type $name"); my $conf = $list2->asconfig; #print "---CUT---\n${conf}---CUT---\n"; #use Data::Dumper; warn Dumper($list2) unless $conf ne ''; $list2->name(undef); ok(! defined $list2->name,"Name removed for $type $name"); foreach my $line (split(/\n/,$conf)) { next if $line =~ /^!/; ok(defined $myconf{$line},'Got correct configline: ' . $line); if (defined $myconf{$line}) { $myconf{$line} -= 1; delete $myconf{$line} if $myconf{$line} == 0; }; }; my $newhash = load Net::ACL::File($conf); my $newlist = $newhash->{$type}->{$name}; ok(defined $newlist,"Got something back for $type $name"); next unless defined $newlist; ok($newlist->asconfig eq $conf,"Load(asconfig) $type $name"); $newhash = undef; $newlist = undef; ok($list2->name($name) eq $name,"Changed name back $type $name"); my $i = 0; foreach my $test (@tests) { my ($rc,$input,$output) = @{$test}; $i+=1; ok($list2->match(@{$input}) == $rc,"Match test $i for $type $name"); next unless defined $output; my ($rc2,@res) = $list2->query(@{$input}); ok($rc2 == $rc,"Query test result code $i for $type $name"); ok(&mycompare($output,\@res),"Query test output $i for $type $name"); }; }; SKIP: { skip('No recent Net::BGP::NLRI',39) unless $hasbgp; } # Got it all? my $noleft = scalar (keys %myconf); ok($noleft == 0,"All config lines regenerated ($noleft left)"); diag(map { "Missing: $_\n" } sort keys %myconf) if $noleft; # Check operation of other lists.... sub mycompare { fail('Compare not implemented!!!'); } __END__