Home | History | Annotate | Download | only in hidl_trace_recorder
      1 #!/usr/bin/env python
      2 #
      3 # Copyright (C) 2016 The Android Open Source Project
      4 #
      5 # Licensed under the Apache License, Version 2.0 (the "License");
      6 # you may not use this file except in compliance with the License.
      7 # You may obtain a copy of the License at
      8 #
      9 #      http://www.apache.org/licenses/LICENSE-2.0
     10 #
     11 # Unless required by applicable law or agreed to in writing, software
     12 # distributed under the License is distributed on an "AS IS" BASIS,
     13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 # See the License for the specific language governing permissions and
     15 # limitations under the License.
     16 #
     17 
     18 import logging
     19 import os
     20 
     21 from vts.runners.host import asserts
     22 from vts.runners.host import base_test
     23 from vts.runners.host import const
     24 from vts.runners.host import test_runner
     25 from vts.utils.python.controllers import android_device
     26 
     27 
     28 class HidlTraceRecorder(base_test.BaseTestClass):
     29     """A HIDL HAL API trace recorder.
     30 
     31     This class uses an apk which is packaged as part of VTS. It uses to test the
     32     VTS TF's instrumentation preparer and post-processing modules. Those two
     33     Java TF-side modules are cherry-picked to CTS to collect HIDL traces while
     34     running various CTS test cases without having to package them as part of
     35     VTS.
     36     """
     37 
     38     CTS_TESTS = [
     39         {"apk": "CtsAccelerationTestCases.apk",
     40          "package": "android.acceleration.cts",
     41          "runner": "android.support.test.runner.AndroidJUnitRunner"},
     42         # TODO(yim): reenable once tests in that apk are no more flaky.
     43         # {"apk": "CtsSensorTestCases.apk",
     44         #  "package": "android.hardware.sensor.cts",
     45         #  "runner": "android.support.test.runner.AndroidJUnitRunner"},
     46         ]
     47     TMP_DIR = "/data/local/tmp"
     48 
     49     def setUpClass(self):
     50         self.dut = self.registerController(android_device)[0]
     51 
     52     def testRunCtsSensorTestCases(self):
     53         """Runs all test cases in CtsSensorTestCases.apk."""
     54         for cts_test in self.CTS_TESTS:
     55           logging.info("Run %s", cts_test["apk"])
     56           self.dut.adb.shell(
     57               "am instrument -w -r %s/%s" % (cts_test["package"],
     58                                              cts_test["runner"]))
     59 
     60 if __name__ == "__main__":
     61     test_runner.main()
     62