class CheckHalctl_add(UIATestBase): """ check haclctl -l """ def setUp(self): super(CheckHalctl_add, self).setUp() cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \ 'tests.tablet.system_domains.conf') self._test_name = __name__ self.hal = AutodetectImpl(self.config.read(cfg_file, 'system_domain')) print "[Setup]: %s" % self._test_name self.cfg = self.config.read(cfg_file, 'system_domain') def tearDown(self): print "[Teardown]: %s" % self._test_name super(CheckHalctl_add, self).tearDown() self.cfg = None self.hal = None def testCheckHalctl_add(self): """ This test case is to check : adb shell haclctl -add Test Case Precondition: NoneSystemImpl Test Case Step: 1 adb root 2 adb shell 3 Type halctl --add new_module_alias 4 Type halctl -l press return return and check the Expect Result: 1 No error occurs. 2 No new entry was added. refcount was incremented. 3 No error occurs 4 New Sensors module is listed anymore """ print "[RunTest]: %s" % self.__str__() res = g_common_obj2.root_on_device() print res modalias2 = 'usbbbbb' self.hal.halctl_a(modalias2) halctl_i_search = self.hal.halctl_i(modalias2).count('usbbbbb') assert halctl_i_search > 0, "[ERROR]: halctl -i %s is fail" % modalias2 print "[INFO]: halctl -i %s is success" % modalias2
class Check_stress_halctl_add_del(UIATestBase): """ Stress - halctl --add/--del """ def setUp(self): super(Check_stress_halctl_add_del, self).setUp() cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \ 'tests.tablet.system_domains.conf') self._test_name = __name__ self.cfg = self.config.read(cfg_file, 'system_domain') self.hal = AutodetectImpl() print "[Setup]: %s" % self._test_name # self.cfg = self.config.read(cfg_file, 'system_domain') def tearDown(self): print "[Teardown]: %s" % self._test_name super(Check_stress_halctl_add_del, self).tearDown() self.hal = None self.hal = None def testCheck_stress_halctl_add_del(self): """ This test case is to check : Stress - halctl --add/--del Test Case Precondition: NoneSystemImpl Test Case Step: 1 Type halctl --add new_entries 2 Halctl -l 3 Type halctl --del new_entries 4 Halctl -l 5 Repeat steps 1 to 4 ten times Expect Result: 1 No error occurs. 2 No new entry was added. refcount was incremented. 3 No error occurs 4 New_entries is not listed anymore 5 No error uccurs """ print "[RunTest]: %s" % self.__str__() res = g_common_obj2.root_on_device() print res #modalias=self.cfg.get("sensors_module_alias") modalias2 = 'usbbbbb' i = 5 while i > 0: print "loop times: %s" % i self.hal.halctl_a(modalias2) time.sleep(3) self.hal.halctl_s(modalias2) i = i - 1
class CheckHalctl_del(UIATestBase): """ check haclctl -l """ def setUp(self): super(CheckHalctl_del, self).setUp() cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \ 'tests.tablet.system_domains.conf') self._test_name = __name__ print "[Setup]: %s" % self._test_name self.cfg = self.config.read(cfg_file, 'system_domain') self.cfg = self.config.read(cfg_file, 'sensors_module_alias') self.hal = AutodetectImpl(self.config.read(cfg_file, 'system_domain')) print "[Setup]: %s" % self._test_name def tearDown(self): print "[Teardown]: %s" % self._test_name super(CheckHalctl_del, self).tearDown() self.cfg = None def testCheckHalctl_del(self): """ This test case is to check : adb shell haclctl --del sensors_module_alias Test Case Precondition: None Test Case Step: 1. Run "adb shell haclctl -l" Expect Result: 1. It shows more than 100 modalias """ print "[RunTest]: %s" % self.__str__() res = g_common_obj2.root_on_device() print res modalias2 = 'usbbbbb' self.hal.halctl_a(modalias2) halctl_i_search = self.hal.halctl_i(modalias2).count('usbbbbb') assert halctl_i_search > 0, "[ERROR]: halctl -i %s is fail" % modalias2 print "[INFO]: halctl -i %s is success" % modalias2 self.hal.halctl_s(modalias2) halctl_i_search = self.hal.halctl_i(modalias2).count('usbbbbb') assert halctl_i_search == 0, "[ERROR]: halctl -i %s is fail" % modalias2 print "[INFO]: halctl -i %s is success" % modalias2