[autotest] Include crash information in the status log.

This will include a line in the status log for each crash dmp file found.
Points to note:
    - INFO lines are only dumped into the status.log of the main server job
      not each status log of different jobs it might kick off.
    - We emit these dmp line whether or not we successfully symbolicate.

Also includes a link to the appropriate status.log in the bugs description.

TEST=Filed bugs, generated dmps.
eg status log: http://172.22.73.115/results/340470-beeps/172.22.75.218/status.log
eg bug filed:
https://code.google.com/p/autotest-bug-filing-test/issues/detail?id=1858#c2
BUG=chromium:319634

Change-Id: Ic0579163b954c3342b03edaf0c4fadd5b0fc634f
Reviewed-on: https://chromium-review.googlesource.com/176895
Reviewed-by: Prashanth B <beeps@chromium.org>
Tested-by: Prashanth B <beeps@chromium.org>
Commit-Queue: Prashanth B <beeps@chromium.org>
diff --git a/server/cros/dynamic_suite/reporting.py b/server/cros/dynamic_suite/reporting.py
index e3ab2f3..e2892d2 100644
--- a/server/cros/dynamic_suite/reporting.py
+++ b/server/cros/dynamic_suite/reporting.py
@@ -173,6 +173,7 @@
                    'Build: %(build)s.\n\nReason:\n%(reason)s.\n'
                    'build artifacts: %(build_artifacts)s.\n'
                    'results log: %(results_log)s.\n'
+                   'status log: %(status_log)s.\n'
                    'buildbot stages: %(buildbot_stages)s.\n'
                    'job link: %(job)s.\n')
 
@@ -184,6 +185,7 @@
             'reason': self.reason,
             'build_artifacts': links.artifacts,
             'results_log': links.results,
+            'status_log': links.status_log,
             'buildbot_stages': links.buildbot,
             'job': links.job,
         }
@@ -203,19 +205,6 @@
                 self._chromeos_image_archive + self.build)
 
 
-    def _link_result_logs(self):
-        """Returns an url to test logs on google storage."""
-        if self.job_id and self.result_owner and self.hostname:
-            path_to_object = '%s-%s/%s/%s' % (self.job_id, self.result_owner,
-                                              self.hostname, self._debug_dir)
-            return (self._retrieve_logs_cgi + self._generic_results_bin +
-                    path_to_object)
-
-        return ('Could not generate results log: the job with id %s, '
-                'scheduled by: %s on host: %s did not run' %
-                (self.job_id, self.result_owner, self.hostname))
-
-
     def _link_job(self):
         """Returns an url to the job on cautotest."""
         if not self.job_id:
@@ -223,6 +212,33 @@
         return '%s=%s' % (self._cautotest_job_view, self.job_id)
 
 
+    def _base_results_log(self):
+        """Returns the base url of the job's results."""
+        if self.job_id and self.result_owner and self.hostname:
+            path_to_object = '%s-%s/%s' % (self.job_id, self.result_owner,
+                                           self.hostname)
+            return (self._retrieve_logs_cgi + self._generic_results_bin +
+                    path_to_object)
+
+
+    def _link_result_logs(self):
+        """Returns an url to test logs on google storage."""
+        base_results = self._base_results_log()
+        if base_results:
+            return '%s/%s' % (base_results, self._debug_dir)
+        return ('Could not generate results log: the job with id %s, '
+                'scheduled by: %s on host: %s did not run' %
+                (self.job_id, self.result_owner, self.hostname))
+
+
+    def _link_status_log(self):
+        """Returns an url to status log of the job."""
+        base_results = self._base_results_log()
+        if base_results:
+            return '%s/%s' % (base_results, 'status.log')
+        return 'NA'
+
+
     def _get_metadata_dict(self):
         """
         Get a dictionary of metadata related to this failure.
@@ -272,10 +288,12 @@
     def _get_links_for_failure(self):
         """Returns a named tuple of links related to this failure."""
         links = collections.namedtuple('links', ('results,'
+                                                 'status_log,'
                                                  'artifacts,'
                                                  'buildbot,'
                                                  'job'))
         return links(self._link_result_logs(),
+                     self._link_status_log(),
                      self._link_build_artifacts(),
                      self._link_buildbot_stages(),
                      self._link_job())
diff --git a/server/site_crashcollect.py b/server/site_crashcollect.py
index a3b1126..6cf5187 100644
--- a/server/site_crashcollect.py
+++ b/server/site_crashcollect.py
@@ -63,6 +63,8 @@
     identified as files with .dmp extension.  The stack trace filename is
     composed by appending the .txt extension to the minidump filename.
 
+    @param host_resultdir: Directory to walk looking for dmp files.
+
     @returns The list of generated minidumps.
     """
     minidumps = []
@@ -132,6 +134,20 @@
         logging.warning('Collection of orphaned crash dumps failed %s', e)
 
     minidumps = find_and_generate_minidump_stacktraces(host_resultdir)
+
+    # Record all crashdumps in status.log of the job:
+    # - If one server job runs several client jobs we will only record
+    # crashdumps in the status.log of the high level server job.
+    # - We will record these crashdumps whether or not we successfully
+    # symbolicate them.
+    if host.job and minidumps or orphans:
+        host.job.record('INFO', None, None, 'Start crashcollection record')
+        for minidump in minidumps:
+            host.job.record('INFO', None, 'New Crash Dump', minidump)
+        for orphan in orphans:
+            host.job.record('INFO', None, 'Orphaned Crash Dump', orphan)
+        host.job.record('INFO', None, None, 'End crashcollection record')
+
     orphans.extend(minidumps)
 
     for minidump in orphans: