Start generating json archive files for nightly tests.

This turns on the option for the nightly tests to generate json
files, which get stored in a pending archives directory and can
later be picked up, converted to ColumnIO and stored on a colossus
server.

It also fixes a bug where the nightly test was looking for a .boto
file in /home/mobiletc-prebuild instead of
/usr/local/google/home/mobiletc-prebuild.

BUG=None
TEST=None

Change-Id: Id413097686d8e72499d141ca7b8d2e131a993cb9
Reviewed-on: https://chrome-internal-review.googlesource.com/228860
Commit-Ready: Caroline Tice <cmtice@google.com>
Tested-by: Caroline Tice <cmtice@google.com>
Reviewed-by: Luis Lozano <llozano@chromium.org>
diff --git a/test_toolchains.py b/test_toolchains.py
index 033f3ec..01606a2 100755
--- a/test_toolchains.py
+++ b/test_toolchains.py
@@ -13,9 +13,12 @@
 from utils import logger
 
 
-WEEKLY_REPORTS_ROOT="/usr/local/google/crostc/weekly_test_data"
+CROSTC_ROOT = "/usr/local/google/crostc"
 AFDO_BOARDS = ["butterfly", "lumpy", "stumpy", "stout", "parrot", "parrot_ivb"]
 MAIL_PROGRAM = "~/var/bin/mail-sheriff"
+WEEKLY_REPORTS_ROOT = os.path.join(CROSTC_ROOT, "weekly_test_data")
+PENDING_ARCHIVES_DIR = os.path.join(CROSTC_ROOT, "pending_archives")
+NIGHTLY_TESTS_DIR = os.path.join(CROSTC_ROOT, "nightly_test_reports")
 
 class GCCConfig(object):
   def __init__(self, githash):
@@ -159,8 +162,7 @@
     self._l = logger.GetLogger()
     timestamp = datetime.datetime.strftime(datetime.datetime.now(),
                                            "%Y-%m-%d_%H:%M:%S")
-    self._reports_dir = os.path.join(
-        os.path.expanduser("~/nightly_test_reports"),
+    self._reports_dir = os.path.join(NIGHTLY_TESTS_DIR,
         "%s.%s" % (timestamp, board),
         )
     self._schedv2 = schedv2
@@ -170,7 +172,7 @@
   def _FinishSetup(self):
     # Get correct .boto file
     current_dir = os.getcwd()
-    src = "/home/mobiletc-prebuild/.boto"
+    src = "/usr/local/google/home/mobiletc-prebuild/.boto"
     dest = os.path.join(current_dir, self._chromeos_root,
                         "src/private-overlays/chromeos-overlay/"
                         "googlestorage_account.boto")
@@ -245,7 +247,7 @@
                             "crosperf")
     schedv2_opts = '--schedv2 --logging_level=verbose' if self._schedv2 else ''
     command = ("{crosperf} --no_email=True --results_dir={r_dir} "
-               "{schedv2_opts} {exp_file}").format(
+               "--json_report=True {schedv2_opts} {exp_file}").format(
                 crosperf=crosperf,
                 r_dir=self._reports_dir,
                 schedv2_opts=schedv2_opts,
@@ -254,6 +256,10 @@
     ret = self._ce.RunCommand(command)
     if ret != 0:
       raise RuntimeError("Couldn't run crosperf!")
+    else:
+      # Copy json report to pending archives directory.
+      command = "cp %s/*.json %s/." % (self._reports_dir, PENDING_ARCHIVES_DIR)
+      ret = self._ce.RunCommand(command)
     return