Add job keyval support to Test Suites for job tracking.

Update dynamic_suite to accept a results_dir variable, when
present write out job keyvals to the results dir that the job is running in.

These keyvals appear during the final parse of the job and are not available
anytime sooner.

These results can be read from TKO via get_detailed_test_views.

TEST=Unitests and end to end tests on the devserver
BUG=chromium-os:26857

Change-Id: I638ad27d0c38594e0c2d75f9b7236a72fa808ffb
Reviewed-on: https://gerrit.chromium.org/gerrit/16986
Commit-Ready: Scott Zawalski <scottz@chromium.org>
Reviewed-by: Scott Zawalski <scottz@chromium.org>
Tested-by: Scott Zawalski <scottz@chromium.org>
diff --git a/server/cros/dynamic_suite_unittest.py b/server/cros/dynamic_suite_unittest.py
index 04ca80a..fa3d348 100755
--- a/server/cros/dynamic_suite_unittest.py
+++ b/server/cros/dynamic_suite_unittest.py
@@ -373,6 +373,21 @@
         suite.schedule()
 
 
+    def testScheduleTestsAndRecord(self):
+        """Should schedule stable and experimental tests with the AFE."""
+        self.mock_control_file_parsing()
+        self.mox.ReplayAll()
+        suite = dynamic_suite.Suite.create_from_name(self._TAG, self._BUILD,
+                                                     afe=self.afe, tko=self.tko,
+                                                     results_dir=self.tmpdir)
+        self.mox.ResetAll()
+        self.expect_job_scheduling(add_experimental=True)
+        self.mox.StubOutWithMock(suite, '_record_scheduled_jobs')
+        suite._record_scheduled_jobs()
+        self.mox.ReplayAll()
+        suite.schedule()
+
+
     def testScheduleStableTests(self):
         """Should schedule only stable tests with the AFE."""
         self.mock_control_file_parsing()
@@ -400,7 +415,7 @@
         """
         self.expect_control_file_parsing()
         self.mox.ReplayAll()
-        suite = dynamic_suite.Suite.create_from_name(self._TAG, self.tmpdir,
+        suite = dynamic_suite.Suite.create_from_name(self._TAG, self._BUILD,
                                                      self.getter, self.afe,
                                                      self.tko)
         self.mox.ResetAll()