Report failure for most of the graphics_test

Use chrome perf dashboard for regression alerts for graphics tests
1) Add several tests to report failures
   graphics_GLBench/
   graphics_GpuReset/
   graphics_KernelMemory/
   graphics_PerfControl/
   graphics_VTSwitch/
   graphics_WebGLClear/ (no control file associated)

BUG=chromium:717664

TEST=[1] test_that dut graphics_GLBench
/tmp/test_that_results_ucjKLm/results-1-graphics_GLBench   [  PASSED  ]
-----------------------------------------------------------------------
Total PASS: 2/2 (100%)

TEST=[2] test_that dut graphics_GpuReset
/tmp/test_that_results_jRFyhv/results-1-graphics_GpuReset  [  PASSED  ]
-----------------------------------------------------------------------
Total PASS: 2/2 (100%)

TEST=[3] test_that dut graphics_KernelMemory
/tmp/test_that_results_XwyCEE/results-1-graphics_Kern...   [  PASSED  ]
-----------------------------------------------------------------------
Total PASS: 2/2 (100%)

TEST=[4] test_that dut graphics_PerfControl
/tmp/test_that_results_liG7CL/results-1-graphics_Perf...   [  PASSED  ]
-----------------------------------------------------------------------
Total PASS: 2/2 (100%)

TEST=[5] test_that dut graphics_VTSwitch
/tmp/test_that_results_61NrD4/results-1-graphics_VTS...    [  PASSED  ]
-----------------------------------------------------------------------
Total PASS: 2/2 (100%)

Change-Id: Ifd7c08cc88825556fe3919dc3b2d4f694aac574d
Reviewed-on: https://chromium-review.googlesource.com/529769
Commit-Ready: Ilja H. Friedel <ihf@chromium.org>
Tested-by: Ilja H. Friedel <ihf@chromium.org>
Reviewed-by: Ilja H. Friedel <ihf@chromium.org>
diff --git a/client/site_tests/graphics_GLBench/graphics_GLBench.py b/client/site_tests/graphics_GLBench/graphics_GLBench.py
index c71f0a1..33c7be6 100644
--- a/client/site_tests/graphics_GLBench/graphics_GLBench.py
+++ b/client/site_tests/graphics_GLBench/graphics_GLBench.py
@@ -12,7 +12,7 @@
 from autotest_lib.client.cros.graphics import graphics_utils
 
 
-class graphics_GLBench(test.test):
+class graphics_GLBench(graphics_utils.GraphicsTest):
   """Run glbench, a benchmark that times graphics intensive activities."""
   version = 1
   preserve_srcdir = True
@@ -49,13 +49,11 @@
       '1280x768_fps': True
   }
 
-  GSC = None
-
   def setup(self):
     self.job.setup_dep(['glbench'])
 
   def initialize(self):
-    self.GSC = graphics_utils.GraphicsStateChecker()
+    super(graphics_GLBench, self).initialize()
     # If UI is running, we must stop it and restore later.
     self._services = service_stopper.ServiceStopper(['ui'])
     self._services.stop_services()
@@ -63,8 +61,7 @@
   def cleanup(self):
     if self._services:
       self._services.restore_services()
-    if self.GSC:
-      self.GSC.finalize()
+    super(graphics_GLBench, self).cleanup()
 
   def report_temperature(self, keyname):
     """Report current max observed temperature with given keyname.
@@ -112,6 +109,7 @@
       imagenames = f.read()
       return imagenames
 
+  @graphics_utils.GraphicsTest.failure_report_decorator('graphics_GLBench')
   def run_once(self, options='', hasty=False):
     dep = 'glbench'
     dep_dir = os.path.join(self.autodir, 'deps', dep)
diff --git a/client/site_tests/graphics_GpuReset/graphics_GpuReset.py b/client/site_tests/graphics_GpuReset/graphics_GpuReset.py
index 486ea16..7e76b06 100644
--- a/client/site_tests/graphics_GpuReset/graphics_GpuReset.py
+++ b/client/site_tests/graphics_GpuReset/graphics_GpuReset.py
@@ -18,14 +18,13 @@
 # start ui
 
 
-class graphics_GpuReset(test.test):
+class graphics_GpuReset(graphics_utils.GraphicsTest):
   """
   Reset the GPU and check recovery mechanism.
   """
   version = 1
   preserve_srcdir = True
   loops = 1
-  GSC = None
 
   def setup(self):
     os.chdir(self.srcdir)
@@ -35,12 +34,12 @@
   def initialize(self):
     # GpuReset should pretty much be the only test where we don't want to raise
     # a test error when we detect a GPU hang.
-    self.GSC = graphics_utils.GraphicsStateChecker(raise_error_on_hang=False)
+    super(graphics_GpuReset, self).initialize(raise_error_on_hang=False)
 
   def cleanup(self):
-    if self.GSC:
-      self.GSC.finalize()
+    super(graphics_GpuReset, self).cleanup()
 
+  @graphics_utils.GraphicsTest.failure_report_decorator('graphics_GpuReset')
   def run_once(self, options=''):
     exefile = os.path.join(self.srcdir, 'gpureset')
     if not os.path.isfile(exefile):
diff --git a/client/site_tests/graphics_KernelMemory/graphics_KernelMemory.py b/client/site_tests/graphics_KernelMemory/graphics_KernelMemory.py
index 2ff1be3..aa4bfd9 100644
--- a/client/site_tests/graphics_KernelMemory/graphics_KernelMemory.py
+++ b/client/site_tests/graphics_KernelMemory/graphics_KernelMemory.py
@@ -7,16 +7,16 @@
 from autotest_lib.client.cros.graphics import graphics_utils
 
 
-class graphics_KernelMemory(test.test):
+class graphics_KernelMemory(graphics_utils.GraphicsTest):
     """
     Reads from sysfs to determine kernel gem objects and memory info.
     """
     version = 1
-    GSC = None
 
     def initialize(self):
-        self.GSC = graphics_utils.GraphicsStateChecker()
+        super(graphics_KernelMemory, self).initialize()
 
+    @graphics_utils.GraphicsTest.failure_report_decorator('graphics_KernelMemory')
     def run_once(self):
         # TODO(ihf): We want to give this test something well-defined to
         # measure. For now that will be the CrOS login-screen memory use.
@@ -24,8 +24,8 @@
         # still flaky. So for now we, lame as we are, just sleep a bit.
         time.sleep(10.0)
 
-        self.GSC.finalize()
+        self._GSC.finalize()
         # We should still be in the login screen and memory use > 0.
-        if self.GSC.get_memory_access_errors() > 0:
+        if self._GSC.get_memory_access_errors() > 0:
             raise error.TestFail('Failed: Detected %d errors accessing graphics'
                                  ' memory.' % self.GKM.num_errors)
diff --git a/client/site_tests/graphics_PerfControl/graphics_PerfControl.py b/client/site_tests/graphics_PerfControl/graphics_PerfControl.py
index c00cc2c..51450f1 100644
--- a/client/site_tests/graphics_PerfControl/graphics_PerfControl.py
+++ b/client/site_tests/graphics_PerfControl/graphics_PerfControl.py
@@ -8,21 +8,25 @@
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.cros import perf
 from autotest_lib.client.cros import service_stopper
+from autotest_lib.client.cros.graphics import graphics_utils
 
 
-class graphics_PerfControl(test.test):
+class graphics_PerfControl(graphics_utils.GraphicsTest):
   version = 1
 
   # None-init vars used by cleanup() here, in case setup() fails
   _services = None
 
   def initialize(self):
+    super(graphics_PerfControl, self).initialize()
     self._services = service_stopper.ServiceStopper(['ui'])
 
   def cleanup(self):
     if self._services:
       self._services.restore_services()
+    super(graphics_PerfControl, self).cleanup()
 
+  @graphics_utils.GraphicsTest.failure_report_decorator('graphics_PerfControl')
   def run_once(self):
     logging.info(utils.get_board_with_frequency_and_memory())
 
diff --git a/client/site_tests/graphics_VTSwitch/graphics_VTSwitch.py b/client/site_tests/graphics_VTSwitch/graphics_VTSwitch.py
index ce4abce..861090b 100644
--- a/client/site_tests/graphics_VTSwitch/graphics_VTSwitch.py
+++ b/client/site_tests/graphics_VTSwitch/graphics_VTSwitch.py
@@ -34,17 +34,16 @@
     return round(100. * diff_bytes / os.path.getsize(file1))
 
 
-class graphics_VTSwitch(test.test):
+class graphics_VTSwitch(graphics_utils.GraphicsTest):
     """
     Verify that VT switching works.
     """
     version = 2
-    GSC = None
     _WAIT = 5
     # TODO(crosbug.com/36417): Need to handle more than one display screen.
 
     def initialize(self):
-        self.GSC = graphics_utils.GraphicsStateChecker()
+        super(graphics_VTSwitch, self).initialize()
         self._player = input_playback.InputPlayback()
         self._player.emulate(input_type='keyboard')
         self._player.find_connected_inputs()
@@ -61,6 +60,7 @@
             input_type='keyboard', filename='keyboard_ctrl+alt+f1')
         time.sleep(self._WAIT)
 
+    @graphics_utils.GraphicsTest.failure_report_decorator('graphics_VTSwitch')
     def run_once(self,
                  num_iterations=2,
                  similarity_percent_threshold=95,
@@ -202,6 +202,5 @@
         # Return to VT1 when done.  Ideally, the screen should already be in VT1
         # but the test might fail and terminate while in VT2.
         self._open_vt1()
-        if self.GSC:
-            self.GSC.finalize()
         self._player.close()
+        super(graphics_VTSwitch, self).cleanup()
diff --git a/client/site_tests/graphics_WebGLClear/graphics_WebGLClear.py b/client/site_tests/graphics_WebGLClear/graphics_WebGLClear.py
index 7807bff..fc603e0 100644
--- a/client/site_tests/graphics_WebGLClear/graphics_WebGLClear.py
+++ b/client/site_tests/graphics_WebGLClear/graphics_WebGLClear.py
@@ -26,10 +26,9 @@
 from autotest_lib.client.cros.graphics import graphics_utils
 
 
-class graphics_WebGLClear(test.test):
+class graphics_WebGLClear(graphics_utils.GraphicsTest):
     """WebGL clear graphics test."""
     version = 1
-    GSC = None
     perf_keyval = {}
     test_duration_secs = 30
 
@@ -37,12 +36,11 @@
         self.job.setup_dep(['webgl_clear'])
 
     def initialize(self):
-        self.GSC = graphics_utils.GraphicsStateChecker()
+        super(graphics_WebGLClear, self).initialize()
         self.perf_keyval = {}
 
     def cleanup(self):
-        if self.GSC:
-            self.GSC.finalize()
+        super(graphics_WebGLClear, self).cleanup()
 
     def run_clear_test(self, browser, test_url):
         """Runs the clear test from the given url.
@@ -66,6 +64,7 @@
 
         tab.Close()
 
+    @graphics_utils.GraphicsTest.failure_report_decorator('graphics_WebGLClear')
     def run_once(self, test_duration_secs=30):
         """Finds a brower with telemetry, and run the test.