コード例 #1
0
    def test_SC004(self):
        """Hard reset each MYDX"""
        RUN_TIMES = 30
        case_id = get_current_func_name()[5:]

        self._run_server('{}'.format(case_id), stop=False)
        parser = ParserLog(self.server.get_log())
        parser.start()
        # waitting parser log read log
        time.sleep(self.parser_log_wait_time)

        try:
            device_ids = self._get_device_id(parser.get_device_snapshot()[0])
        except IndexError:
            raise ValueError('please set device_snapshot_mode: full')
        rs = ResetDevice()
        try:
            for index, device_id in enumerate(device_ids):
                for i in range(1, RUN_TIMES):
                    rs.reset(device_id)
                    time.sleep(self.restore_time_for_one_device)
                    result = parser.get_device_snapshot()[6][1:]
                    LOGGER.info('reset {}-{} times, ({})'.format(device_id, i, result))
                    result = [int(device_id) for device_id in result]
                    result.sort()
                    LOGGER.debug('i:{}.index:{},result:{}'.format(i, index, result))
                    self.assertEqual(i, result[len(result)-index-1])
        finally:
            self.server.stop_run()
            parser.stop()
コード例 #2
0
    def test_SC003(self):
        """Hard reset whole HDDL-R AIC"""
        RUN_TIMES = 30
        case_id = get_current_func_name()[5:]

        self._run_server('{}'.format(case_id), stop=False)
        parser = ParserLog(self.server.get_log())
        parser.start()
        # waitting parser log read log
        time.sleep(self.parser_log_wait_time)

        try:
            device_ids = self._get_device_id(parser.get_device_snapshot()[0])
        except IndexError:
            raise ValueError('please set device_snapshot_mode: full')
        rs = ResetDevice()
        restore_time = min(self.restore_time_for_one_device * self.device_count, 60)
        try:
            for i in range(1, RUN_TIMES):
                for device_id in device_ids:
                    rs.reset(device_id)
                time.sleep(restore_time)
                result = parser.get_device_snapshot()[6][1:]
                LOGGER.info('reset {} times({})'.format(i, result))
                self.assertEqual([str(i)]*len(result), result)
        finally:
            self.server.stop_run()
            parser.stop()
コード例 #3
0
ファイル: test_sc.py プロジェクト: mc7025/myProject
 def test_SC004_with_hddldaemon(self):
     RUN_TIMES = 50
     case_id = get_current_func_name()[5:]
     try:
         self._run_server('{}'.format(case_id), stop=False)
         # waitting parser log read log
         try:
             device_ids = self._get_device_id(
                 self.server.parser_log.get_device_snapshot()[0])
         except IndexError:
             raise ValueError('please set device_snapshot_mode: full')
         LOGGER.info('Device ids: {}'.format(device_ids.sort()))
         reset = BslReset()
         pre_result = [0] * self.device_count
         restore_time = min(
             self.restore_time_for_one_device * self.device_count, 60)
         for i in range(1, RUN_TIMES):
             for did in device_ids:
                 reset.reset_device(did, self.device_mode)
                 time.sleep(5)
             time.sleep(restore_time)
             result = self.server.parser_log.get_device_snapshot()[6][1:]
             result = [int(i) for i in result]
             result.sort()
             LOGGER.debug('pre_resettimes:{},cur_resettimes:{}'.format(
                 pre_result, result))
             self.assertGreater(result, pre_result)
             self.assertEqual(len(result), self.device_count)
             pre_result = result.copy()
             LOGGER.info('Reset device {} times({})'.format(i, result))
     finally:
         self.server.stop_run()
         self.server.parser_log.stop()
コード例 #4
0
ファイル: test_sc.py プロジェクト: mc7025/myProject
    def test_SC004(self):
        """Hard reset each MYDX"""
        RUN_TIMES = 50
        case_id = get_current_func_name()[5:]

        # _root_no_password('dmesg -c')
        self._run_server('{}'.format(case_id), stop=False)
        # waitting parser log read log
        try:
            device_ids = self._get_device_id(
                self.server.parser_log.get_device_snapshot()[0])
        except IndexError:
            raise ValueError('please set device_snapshot_mode: full')
        device_ids = [int(did) for did in device_ids]
        LOGGER.info('Device ids: {}'.format(device_ids))
        self.server.parser_log.stop()
        self.server.stop_run()

        bsl_reset = BslReset()
        for times in range(1, RUN_TIMES):
            server = Server('{}_{}'.format(case_id, times))
            server.start_run()
            server.stop_run()
            out = get_myx_count()[1]
            self.assertEqual(self.device_count, out)
            for i, did in enumerate(device_ids):
                bsl_reset.reset_device(did, self.device_mode)
                if os.name == 'nt':
                    time.sleep(10)
                else:
                    time.sleep(1)
                booted, unbooted = get_myx_count()[1:]
                self.assertEqual(self.device_count - i - 1, booted)
                self.assertEqual(i + 1, unbooted)
            LOGGER.info('Ran BslReset {} times'.format(times))
コード例 #5
0
ファイル: test_sc.py プロジェクト: mc7025/myProject
 def test_SC002(self):
     """Boot up  MYDX"""
     RUN_TIMES = 50
     rv = None
     case_id = get_current_func_name()[5:]
     for i in range(RUN_TIMES):
         self._run_server('{}_{}'.format(case_id, i))
         with open(self.server.get_log()) as f:
             for line in f:
                 if 'SERVICE IS READY' in line:
                     rv = True
                     break
                 elif 'ERROR' in line:
                     rv = False
         LOGGER.info('Ran {} times.'.format(i))
         # can normally start hddldamon
         self.assertTrue(rv)
コード例 #6
0
ファイル: test_sc.py プロジェクト: mc7025/myProject
    def test_SC005(self):
        """Soft reset each MYDX"""
        RUN_TIMES = 50
        case_id = get_current_func_name()[5:]
        rv = None
        try:
            for i in range(RUN_TIMES):
                self._run_server('{}_{}'.format(case_id, i))
                with open(self.server.get_log()) as f:
                    for line in f:
                        if 'SERVICE IS READY' in line:
                            rv = True
                            break
                        elif 'ERROR' in line:
                            rv = False
                # can normally start hddldamon
                boot_device_count = get_myx_count()[1]
                LOGGER.info('Ran {} times.'.format(i))
                self.assertEqual(self.device_count, boot_device_count)
                self.assertTrue(rv)
        finally:
            self.server.stop_run()
            self.server.parser_log.stop()


# class SampleTest(unittest.TestCase):
#
#         base_dir = os.path.join(HDDL_SOURCE_DIR, 'hddl-samples')
#
#     def setUpClass(cls):
#         if not os.path.exists(cls.base_dir):
#             raise ValueError('HDDL Sample source Dir not exists')
#         current_pwd = os.getcwd()
#         os.chdir(os.path.join(cls.base_dir,))
#         _root_no_password('')
#
#     def test_barrier(self):
#         pass
#
#     def test_cross_road(self):
#         pass
#
#     def test_indoor(self):
#         pass
コード例 #7
0
ファイル: test_sc.py プロジェクト: mc7025/myProject
 def test_SC003(self):
     """Bsl reset whole HDDL-R AIC"""
     RUN_TIMES = 50
     case_id = get_current_func_name()[5:]
     # _root_no_password('dmesg -c')
     bsl_reset = BslReset()
     for i in range(1, RUN_TIMES):
         server = Server(case_id)
         server.start_run()
         server.stop_run()
         out = get_myx_count()[1]
         self.assertEqual(self.device_count, out)
         bsl_reset.reset_all()
         if os.name == 'nt':
             time.sleep(10)
         else:
             time.sleep(1)
         booted, unbooted = get_myx_count()[1:]
         self.assertEqual(0, booted)
         self.assertEqual(self.device_count, unbooted)
         LOGGER.info('Ran BslReset {} times'.format(i))
コード例 #8
0
ファイル: test_sc.py プロジェクト: mc7025/myProject
    def test_SC001(self):
        """Check unique ID"""
        RUN_TIMES = 20
        device_ids = []
        case_id = get_current_func_name()[5:]
        LOGGER.info('Begin run:{}'.format(case_id))

        for i in range(RUN_TIMES):
            self._run_server('{}_{}'.format(case_id, i), config={'mvnc_log_level': 0})
            time.sleep(self.parser_log_wait_time)
            with open(self.server.get_log()) as f:
                for line in f:
                    if 'SERVICE IS READY' in line:
                        break
                    elif 'Device ID is' in line:
                        device_ids.append(int(line.split(' ')[-1].strip()))
            LOGGER.info('Ran {} times.Device_Ids:{}'.format(i, device_ids))
            # device id is unique
            self.assertEqual(len(device_ids), len(set(device_ids)), ''.format(device_ids))
            # device count equals cls.device_count
            self.assertEqual(len(device_ids), self.device_count)
            device_ids.clear()
コード例 #9
0
ファイル: test_sc.py プロジェクト: mc7025/myProject
 def test_SC003_with_hddldaemon(self):
     RUN_TIMES = 50
     case_id = get_current_func_name()[5:]
     try:
         self._run_server('{}'.format(case_id), stop=False)
         reset = BslReset()
         pre_result = [0] * self.device_count
         restore_time = min(
             self.restore_time_for_one_device * self.device_count, 60)
         for i in range(1, RUN_TIMES):
             reset.reset_all()
             time.sleep(restore_time)
             result = self.server.parser_log.get_device_snapshot()[6][1:]
             result = [int(i) for i in result]
             result.sort()
             LOGGER.debug('pre_resettimes:{},cur_resettimes:{}'.format(
                 pre_result, result))
             self.assertGreater(result, pre_result)
             self.assertEqual(len(result), self.device_count)
             pre_result = result.copy()
             LOGGER.info('Reset all device {} times({})'.format(i, result))
     finally:
         self.server.stop_run()
         self.server.parser_log.stop()