File indexing completed on 2024-03-24 15:26:17
0001 #!/usr/bin/perl 0002 0003 if ( @ARGV != 1 ) { 0004 print STDERR "Missing arg: filename\n"; 0005 system "touch FAILED"; 0006 exit 1; 0007 } 0008 0009 $file = $ARGV[0]; 0010 0011 if ( !open( IN, "$file" ) ) { 0012 print STDERR "Unable to open '$file'\n"; 0013 system "touch FAILED"; 0014 exit 1; 0015 } 0016 0017 while( <IN> ) { 0018 if (/^VERSION:(.*)$/ ) { 0019 $version = $1; 0020 if ( $version eq "2.1" ) { $options = "--vcard21"; } 0021 } 0022 } 0023 0024 close IN; 0025 0026 $ref = "$file.ref"; 0027 0028 if ( !open( REF, "$ref" ) ) { 0029 print STDERR "Unable to open $ref\n"; 0030 system "touch FAILED"; 0031 exit 1; 0032 } 0033 0034 while( <REF> ) { 0035 push @ref, $_; 0036 } 0037 0038 close REF; 0039 0040 if ( !open( READ, "./testread $file $options 2> /dev/null |" ) ) { 0041 print STDERR "Unable to open testread\n"; 0042 system "touch FAILED"; 0043 exit 1; 0044 } 0045 0046 print "Checking '$file':\n"; 0047 0048 $gotsomething = 0; 0049 $error = 0; 0050 $i = 0; 0051 while( <READ> ) { 0052 $gotsomething = 1; 0053 $out = $_; 0054 $ref = @ref[$i++]; 0055 0056 if ( $out ne $ref ) { 0057 if ( $ref =~ /^UID/ && $out =~ /^UID/ ) { next; } 0058 $error++; 0059 print " Expected : $ref"; 0060 print " Parser output : $out"; 0061 } 0062 } 0063 0064 close READ; 0065 0066 if ( $gotsomething == 0 ) { 0067 print "\n FAILED: testread didn't output anything\n"; 0068 system "touch FAILED"; 0069 exit 1; 0070 } 0071 if ( $error > 0 ) { 0072 print "\n FAILED: $error errors found.\n"; 0073 system "touch FAILED"; 0074 exit 1; 0075 } else { 0076 print " OK\n"; 0077 } 0078 0079 exit 0;