changeset 234:ed0cb66b23d4

better detection of dsn delivery reports
author Carl Byington <carl@five-ten-sg.com>
date Fri, 11 Sep 2009 12:46:36 -0700
parents 1d50ff3c5091
children 9d6bb722d0fe
files regression/regression-tests.bash src/readpst.c
diffstat 2 files changed, 60 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/regression/regression-tests.bash	Thu Sep 10 22:49:24 2009 -0700
+++ b/regression/regression-tests.bash	Fri Sep 11 12:46:36 2009 -0700
@@ -21,10 +21,10 @@
     n="$1"
     fn="$2"
     echo $fn
+    ba=$(basename "$fn" .pst)
     rm -rf output$n
     mkdir output$n
-    $val ../src/pst2dii -f /usr/share/fonts/bitstream-vera/VeraMono.ttf -B "bates-" -o output$n -O mydii$n -d $fn.log $fn >$fn.dii.err 2>&1
-    rm -f dumper
+    $val ../src/pst2dii -f /usr/share/fonts/bitstream-vera/VeraMono.ttf -B "bates-" -o output$n -O $ba.mydii -d $fn.log $fn >$fn.dii.err 2>&1
 }
 
 
@@ -37,7 +37,6 @@
     rm -rf output$n
     mkdir output$n
     $val ../src/pst2ldif -d $ba.ldif.log -b 'o=ams-cc.com, c=US' -c 'inetOrgPerson' $fn >$ba.ldif.err 2>&1
-    rm -f dumper
 }
 
 
@@ -47,20 +46,23 @@
     fn="$2"
     echo $fn
     ba=$(basename "$fn" .pst)
-    jobs="-j 0"
-    [ -n "$val" ] && jobs="-j 0"
+    jobs=""
+    [ -n "$val" ]              && jobs="-j 0"
+    [ "$regression" == "yes" ] && jobs="-j 0"
     rm -rf output$n
     mkdir output$n
-    #val ../src/readpst $jobs -r -D -cv -o output$n            $fn
-    #$val ../src/readpst $jobs -r -D -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
-    $val ../src/readpst $jobs -r -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
-    #../src/getidblock -p $fn 0 >$ba.fulldump
+    if [ "$regression" == "yes" ]; then
+        $val ../src/readpst $jobs -te -r -D -cv -o output$n $fn >$ba.err 2>&1
+    else
+        #val ../src/readpst $jobs -r -D -cv -o output$n            $fn
+        $val ../src/readpst $jobs -r -D -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
+        #$val ../src/readpst $jobs -r -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
+        #../src/getidblock -p $fn 0 >$ba.fulldump
+    fi
 }
 
 
 
-val="valgrind --leak-check=full"
-val=''
 
 pushd ..
 make || exit
@@ -68,63 +70,49 @@
 
 rm -rf output* *.err *.log
 
-if [ "$1" == "test" ]; then
-    dopst  19 harris.pst
+func="dopst"
+[ "$1" == "pst"  ] && func="dopst"
+[ "$1" == "ldif" ] && func="doldif"
+[ "$1" == "dii"  ] && func="dodii"
 
-elif [ "$1" == "dii" ]; then
-    dodii 1 ams.pst
-    dodii 2 sample_64.pst
-    dodii 3 test.pst
-    dodii 4 big_mail.pst
+val="valgrind --leak-check=full"
+val=""
+
+regression=""
+[ "$2" == "reg" ] && regression="yes"
+[ "$regression" == "yes" ] && val=""
 
-elif [ "$1" == "ldif" ]; then
-    doldif   1 ams.pst
-    doldif   2 sample_64.pst
-    doldif   3 test.pst
-    doldif   4 big_mail.pst
-    doldif   5 mbmg.archive.pst
-    doldif   6 Single2003-read.pst
-    doldif   7 Single2003-unread.pst
-    doldif   8 ol2k3high.pst
-    doldif   9 ol97high.pst
-    doldif  10 returned_message.pst
-    doldif  11 flow.pst
-    doldif  12 test-html.pst
-    doldif  13 test-text.pst
-    doldif  14 joe.romanowski.pst
-    doldif  15 hourig1.pst
-    doldif  16 hourig2.pst
-    doldif  17 hourig3.pst
-    doldif  18 test-mac.pst
-    doldif  19 harris.pst
-    doldif  20 spam.pst
-    doldif  21 rendgen.pst
-else
-    dopst   1 ams.pst
-    dopst   2 sample_64.pst
-    dopst   3 test.pst
-    dopst   4 big_mail.pst
-    dopst   5 mbmg.archive.pst
-    dopst   6 Single2003-read.pst
-    dopst   7 Single2003-unread.pst
-    dopst   8 ol2k3high.pst
-    dopst   9 ol97high.pst
-    dopst  10 returned_message.pst
-    dopst  11 flow.pst
-    dopst  12 test-html.pst
-    dopst  13 test-text.pst
-    dopst  14 joe.romanowski.pst
-    dopst  15 hourig1.pst
-    #dopst  16 hourig2.pst
-    #dopst  17 hourig3.pst
-    dopst  18 test-mac.pst
-    dopst  19 harris.pst
-    dopst  20 spam.pst
-    dopst  21 rendgen.pst       # single email appointment
-    dopst  22 rendgen2.pst      # email appointment with no termination date
-    dopst  23 rendgen3.pst      # mime signed email
-    dopst  24 rendgen4.pst      # appointment test cases
-    dopst  25 rendgen5.pst      # appointment test cases
+$func   1 ams.pst
+$func   2 sample_64.pst
+$func   3 test.pst
+$func   4 big_mail.pst
+$func   5 mbmg.archive.pst
+$func   6 Single2003-read.pst
+$func   7 Single2003-unread.pst
+$func   8 ol2k3high.pst
+$func   9 ol97high.pst
+$func  10 returned_message.pst
+$func  11 flow.pst
+$func  12 test-html.pst
+$func  13 test-text.pst
+$func  14 joe.romanowski.pst
+$func  15 hourig1.pst
+$func  16 test-mac.pst
+$func  17 harris.pst
+$func  18 spam.pst
+$func  19 rendgen.pst       # single email appointment
+$func  20 rendgen2.pst      # email appointment with no termination date
+$func  21 rendgen3.pst      # mime signed email
+$func  22 rendgen4.pst      # appointment test cases
+$func  23 rendgen5.pst      # appointment test cases
+
+[ -n "$val" ] && grep 'lost:' *err | grep -v 'lost: 0 '
+
+if [ "$regression" == "yes" ]; then
+    (
+        (for i in output*; do find $i -type f; done) | while read a; do
+            grep -v iamunique "$a"
+            rm -f "$a"
+        done
+    ) >regression.txt
 fi
-
-grep 'lost:' *err | grep -v 'lost: 0 '
--- a/src/readpst.c	Thu Sep 10 22:49:24 2009 -0700
+++ b/src/readpst.c	Fri Sep 11 12:46:36 2009 -0700
@@ -1320,10 +1320,8 @@
     // setup default body character set and report type
     strncpy(body_charset, pst_default_charset(item, sizeof(buffer_charset), buffer_charset), sizeof(body_charset));
     body_charset[sizeof(body_charset)-1] = '\0';
-    body_report[0] = '\0';
-    if (item->email->report_text.str && !item->body.str) {
-        strncpy(body_report, "delivery-status", sizeof(body_report));
-    }
+    strncpy(body_report, "delivery-status", sizeof(body_report));
+    body_report[sizeof(body_report)-1] = '\0';
 
     // setup default sender
     pst_convert_utf8(item, &item->email->sender_address);
@@ -1487,7 +1485,7 @@
 
     // add our own mime headers
     fprintf(f_output, "MIME-Version: 1.0\n");
-    if (body_report[0] != '\0') {
+    if (item->type == PST_TYPE_REPORT) {
         // multipart/report for DSN/MDN reports
         fprintf(f_output, "Content-Type: multipart/report; report-type=%s;\n\tboundary=\"%s\"\n", body_report, boundary);
     }
@@ -1497,7 +1495,7 @@
     fprintf(f_output, "\n");    // end of headers, start of body
 
     // now dump the body parts
-    if ((item->email->report_text.str) && (body_report[0] != '\0')) {
+    if ((item->type == PST_TYPE_REPORT) && (item->email->report_text.str)) {
         write_body_part(f_output, &item->email->report_text, "text/plain", body_charset, boundary, pst);
         fprintf(f_output, "\n");
     }