コード例 #1
0
    def test_shell(self):
        '''
        Test shell.
        '''
        # test running command and the command success (retcode 0)
        str_ret = textwrap.dedent('''\
                                  test_result
                                  0''')
        expected_ret = 'test_result'
        excepted_retcode = 0
        self.mock_obj.communicate.return_value = [str_ret, None]
        self.mock_popen.return_value = self.mock_obj
        ret, retcode = AdbWrapper.adb_shell('b2g-test')
        self.assertEqual(ret, expected_ret,
                         'The result should be {}, not {}.'.format(expected_ret, ret))
        self.assertEqual(retcode, excepted_retcode,
                         'The return code should be {}, not {}.'.format(excepted_retcode, retcode))

        # test running command and the command failed (retcode 1)
        str_ret = textwrap.dedent('''\
                                  test_result
                                  1''')
        expected_ret = 'test_result'
        not_excepted_retcode = 0
        self.mock_obj.communicate.return_value = [str_ret, None]
        self.mock_popen.return_value = self.mock_obj
        ret, retcode = AdbWrapper.adb_shell('b2g-test')
        self.assertEqual(ret, expected_ret,
                         'The result should be {}, not {}.'.format(expected_ret, ret))
        self.assertNotEqual(retcode, not_excepted_retcode,
                         'The return code cannot be {}, but it is.'.format(not_excepted_retcode))
コード例 #2
0
 def test_shell_fail(self):
     '''
     Test shell fail.
     '''
     str_ret = 'error: device not found'
     with self.assertRaises(Exception) as cm:
         self.mock_obj.returncode = 1
         self.mock_obj.communicate.return_value = [str_ret, None]
         self.mock_popen.return_value = self.mock_obj
         ret = AdbWrapper.adb_shell('foo')
コード例 #3
0
 def test_shell_fail(self):
     """
     Test shell fail.
     """
     str_ret = 'error: device not found'
     with self.assertRaises(Exception) as cm:
         self.mock_obj.returncode = 1
         self.mock_obj.communicate.return_value = [str_ret, None]
         self.mock_popen.return_value = self.mock_obj
         ret = AdbWrapper.adb_shell('foo')
コード例 #4
0
ファイル: b2g_crash_util.py プロジェクト: Conjuror/mozMinions
    def get_crash(self):
        crash_info = self.fetch_crash_info()
        submitted = crash_info['submitted']
        pending = crash_info['pending']
        processed = set()
        for pendi in set(pending):
            # Get pending dump and submit
            dmp = pendi + ".dmp"
            extra = pendi + ".extra"
            AdbWrapper.adb_pull(PENDING_DIR + "/" + dmp, dmp, self.serial)
            AdbWrapper.adb_pull(PENDING_DIR + "/" + extra, extra, self.serial)

            ret = cli([dmp])
            if ret:
                processed.add(pendi)
                submitted.append(ret[0])
                AdbWrapper.adb_shell("rm \"" + PENDING_DIR + "/" + dmp + "\"",
                                     self.serial)
                AdbWrapper.adb_shell(
                    "rm \"" + PENDING_DIR + "/" + extra + "\"", self.serial)
                AdbWrapper.adb_shell("rm -r \"" + SUBMITTED_DIR + "\"",
                                     self.serial)
            os.remove(dmp)
            os.remove(extra)
        return {
            'crash_info': {
                'submitted': submitted,
                'pending': list(set(pending) - processed)
            }
        }
コード例 #5
0
    def test_shell(self):
        """
        Test shell.
        """
        # test running command and the command success (retcode 0)
        str_ret = textwrap.dedent("""\
                                  test_result
                                  0""")
        expected_ret = 'test_result'
        excepted_retcode = 0
        self.mock_obj.communicate.return_value = [str_ret, None]
        self.mock_popen.return_value = self.mock_obj
        ret, retcode = AdbWrapper.adb_shell('b2g-test')
        self.assertEqual(
            ret, expected_ret,
            'The result should be {}, not {}.'.format(expected_ret, ret))
        self.assertEqual(
            retcode, excepted_retcode,
            'The return code should be {}, not {}.'.format(
                excepted_retcode, retcode))

        # test running command and the command failed (retcode 1)
        str_ret = textwrap.dedent("""\
                                  test_result
                                  1""")
        expected_ret = 'test_result'
        not_excepted_retcode = 0
        self.mock_obj.communicate.return_value = [str_ret, None]
        self.mock_popen.return_value = self.mock_obj
        ret, retcode = AdbWrapper.adb_shell('b2g-test')
        self.assertEqual(
            ret, expected_ret,
            'The result should be {}, not {}.'.format(expected_ret, ret))
        self.assertNotEqual(
            retcode, not_excepted_retcode,
            'The return code cannot be {}, but it is.'.format(
                not_excepted_retcode))
コード例 #6
0
    def get_crash(self):
        crash_info = self.fetch_crash_info()
        submitted = crash_info['submitted']
        pending = crash_info['pending']
        processed = set()
        for pendi in set(pending):
            # Get pending dump and submit
            dmp = pendi + ".dmp"
            extra = pendi + ".extra"
            AdbWrapper.adb_pull(PENDING_DIR + "/" + dmp,
                                dmp,
                                self.serial)
            AdbWrapper.adb_pull(PENDING_DIR + "/" + extra,
                                extra,
                                self.serial)

            ret = cli([dmp])
            if ret:
                processed.add(pendi)
                submitted.append(ret[0])
                AdbWrapper.adb_shell("rm \""
                                     + PENDING_DIR
                                     + "/" + dmp + "\"",
                                     self.serial)
                AdbWrapper.adb_shell("rm \""
                                     + PENDING_DIR
                                     + "/" + extra + "\"",
                                     self.serial)
                AdbWrapper.adb_shell("rm -r \""
                                     + SUBMITTED_DIR + "\"",
                                     self.serial)
            os.remove(dmp)
            os.remove(extra)
        return {'crash_info': {
                'submitted': submitted,
                'pending': list(set(pending) - processed)}}