chiark / gitweb /
* adt-testreport-onepackage: limit log to 64K (32K head, 32K tail)
authorIan Jackson <ian@davenant.greenend.org.uk>
Mon, 1 Oct 2007 16:28:47 +0000 (17:28 +0100)
committerIan Jackson <ian@davenant.greenend.org.uk>
Mon, 1 Oct 2007 16:28:47 +0000 (17:28 +0100)
  to avoid humungous bug reports which LP silently discards.

debian/changelog
runner/adt-testreport-onepackage

index f240b545c7f23361ad0c4ac726228e1b33ba89a0..73f9641f871e3a33cfa4e5a66276f1cdeac41d76 100644 (file)
@@ -13,8 +13,10 @@ autopkgtest (1.0.9) unstable; urgency=low
   * adt-testreport-onepackage: skip emails if _source_ is suppresed.
   * adt-testreport-onepackage etc.: new blacklist feature, and initially
     blacklist ltsp-client{,-core}.
+  * adt-testreport-onepackage: limit log to 64K (32K head, 32K tail)
+    to avoid humungous bug reports which LP silently discards.
 
 --
+ --
 
 autopkgtest (1.0.8) gutsy; urgency=low
 
index 87d33a7b935f5bc9e55598a4c48730354ec62f86..b0f138bd05289160939c7878f384f4df4eb78b7c 100755 (executable)
@@ -11,6 +11,8 @@ interactive=true
 target=source
 suppressrepeatedemails=false
 arch=`dpkg --print-architecture`
+logheadmaxbytes=32768
+logtailmaxbytes=32768
 
 for config in "$@"; do
        case "$config" in
@@ -428,10 +430,10 @@ END
        esac
        cat >>"$tmp/_email" <<END
 
-The test log, which is intended to be sufficient to diagnose most
-failures, can be found below.  However, in case this is not
-sufficient, another copy can be found along with output files, saved
-temporary files, and so on, at:
+The top and tail of the test log, which is intended to be sufficient
+to diagnose most failures, can be found below.  However, in case this
+is not sufficient, a complete log can be found along with output
+files, saved temporary files, and so on, at:
  $desthttphead/$destdirfin/
 $email_extra_info
 If you have any questions about this service please contact me at:
@@ -457,14 +459,34 @@ else
        progress "fault ($ourx)."
 fi
 
-perl <"$tmp"/_log_raw >"$tmp"/_log -pe '
+perl <"$tmp"/_log_raw >"$tmp"/_log -ne '
        s/[^\012\040-\133\135-\176]/
                $& eq "\t" ? "\\t" :
                $& eq "\r" ? "\\r" :
                $& eq "\b" ? "\\b" :
                $& eq "\\" ? "\\\\" :
                sprintf "\\x%02x", ord $&
-       /ge'
+       /ge;
+
+       if (!$middle) {
+               $headlen += length;
+               $middle=1 if $headlen > '"$logheadmaxbytes"';
+       }
+       if (!$middle) {
+               print or die $!;
+       } else {
+               $taillen += length;
+               push @tail, $_;
+               while ($taillen > '"$logtailmaxbytes"') {
+                       $taillen -= length shift @tail;
+                       $some_dropped= 1;
+               }
+       }
+       END {
+               print "...\n" or die $! if $some_dropped;
+               print @tail or die $!;
+       }
+'
 
 if [ "x$email" = x ]; then
        if $interactive; then