tests: adjust file part behavior in test verify section.

When a <file> part is now specified with no contents at all, this
will actually verify that the specified file has no contents at all.
Previously file contents would be ignored.
This commit is contained in:
Yang Tse 2012-06-05 20:01:23 +02:00
Родитель 89b5680d81
Коммит 62f374b19e
2 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -124,6 +124,25 @@ sub getpart {
return @this; #empty! return @this; #empty!
} }
sub partexists {
my ($section, $part)=@_;
my $inside = 0;
for(@xml) {
if(!$inside && ($_ =~ /^ *\<$section/)) {
$inside++;
}
elsif((1 == $inside) && ($_ =~ /^ *\<$part[ \>]/)) {
return 1; # exists
}
elsif((1 == $inside) && ($_ =~ /^ *\<\/$section/)) {
return 0; # does not exist
}
}
return 0; # does not exist
}
# Return entire document as list of lines # Return entire document as list of lines
sub getall { sub getall {
return @xml; return @xml;

Просмотреть файл

@ -3499,7 +3499,7 @@ sub singletest {
my $outputok; my $outputok;
for my $partsuffix (('', '1', '2', '3', '4')) { for my $partsuffix (('', '1', '2', '3', '4')) {
my @outfile=getpart("verify", "file".$partsuffix); my @outfile=getpart("verify", "file".$partsuffix);
if(@outfile) { if(@outfile || partexists("verify", "file".$partsuffix) ) {
# we're supposed to verify a dynamically generated file! # we're supposed to verify a dynamically generated file!
my %hash = getpartattr("verify", "file".$partsuffix); my %hash = getpartattr("verify", "file".$partsuffix);