]> granicus.if.org Git - curl/commitdiff
tests: adjust file part behavior in test verify section.
authorYang Tse <yangsita@gmail.com>
Tue, 5 Jun 2012 18:01:23 +0000 (20:01 +0200)
committerYang Tse <yangsita@gmail.com>
Tue, 5 Jun 2012 18:20:39 +0000 (20:20 +0200)
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.

tests/getpart.pm
tests/runtests.pl

index 1aeedd6dd464235077469269504bbf5552a75877..d9510dd208b1bea6f9687747df83b366e350597b 100644 (file)
@@ -124,6 +124,25 @@ sub getpart {
     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
 sub getall {
     return @xml;
index 65dd9610ba6f3aed1b12075097bc9596ce38cc52..ed234be234a7f55ae02b02a82e79176134e0fe07 100755 (executable)
@@ -3499,7 +3499,7 @@ sub singletest {
     my $outputok;
     for my $partsuffix (('', '1', '2', '3', '4')) {
         my @outfile=getpart("verify", "file".$partsuffix);
-        if(@outfile) {
+        if(@outfile || partexists("verify", "file".$partsuffix) ) {
             # we're supposed to verify a dynamically generated file!
             my %hash = getpartattr("verify", "file".$partsuffix);