def run_once(self, args=[]):
        """Runs the PyAuto performance tests."""
        if isinstance(args, str):
          args = args.split()
        options, test_args = self.parse_args(args)
        test_args = ' '.join(test_args)

        # Enable Chrome testing interface and login to a default account.
        deps_dir = os.path.join(self.autodir, 'deps')
        pyautolib_dir = os.path.join(self.cr_source_dir,
                                     'chrome', 'test', 'pyautolib')
        login_cmd = cros_ui.xcommand_as(
            'python %s chromeos_utils.ChromeosUtils.LoginToDefaultAccount '
            '-v --no-http-server' %
                os.path.join(pyautolib_dir, 'chromeos', 'chromeos_utils.py'))
        utils.system(login_cmd)

        # Run the PyAuto performance tests.
        print 'About to run the pyauto performance tests.'
        print 'Note: you will see two timestamps for each logging message.'
        print '      The outer timestamp occurs when the autotest dumps the '
        print '      pyauto output, which only occurs after all tests are '
        print '      complete. The inner timestamp is the time at which the '
        print '      message was logged by pyauto while the test was actually '
        print '      running.'
        functional_cmd = cros_ui.xcommand_as(
            '%s/chrome_test/test_src/chrome/test/functional/'
            'pyauto_functional.py --suite=%s %s' % (
                deps_dir, options.suite, test_args))
        environment = os.environ.copy()

        environment['NUM_ITERATIONS'] = str(options.num_iterations)
        self.write_perf_keyval({'iterations': options.num_iterations})

        if options.max_timeouts:
          environment['MAX_TIMEOUT_COUNT'] = str(options.max_timeouts)

        proc = subprocess.Popen(
            functional_cmd, shell=True, stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT, env=environment)
        output = proc.communicate()[0]
        print output  # Ensure pyauto test output is stored in autotest logs.

        # Output perf keyvals for any perf results recorded during the tests.
        re_compiled = re.compile('%s(.+)%s' % (self._PERF_MARKER_PRE,
                                               self._PERF_MARKER_POST))
        perf_lines = [line for line in output.split('\n')
                      if re_compiled.match(line)]
        if perf_lines:
            perf_dict = dict([eval(re_compiled.match(line).group(1))
                              for line in perf_lines])
            self.write_perf_keyval(perf_dict)

        # Fail the autotest if any pyauto tests failed.  This is done after
        # writing perf keyvals so that any computed results from passing tests
        # are still graphed.
        if proc.returncode != 0:
            raise error.TestFail(
                'Unexpected return code from pyauto_functional.py when running '
                'with the CHROMEOS_PERF suite: %d' % proc.returncode)
Ejemplo n.º 2
0
    def run_once(self):
        # Make sure Chrome minidumps are written locally.
        minidumps_file = "/mnt/stateful_partition/etc/enable_chromium_minidumps"
        if not os.path.exists(minidumps_file):
            open(minidumps_file, "w").close()
            pgrep_process = subprocess.Popen(["pgrep", "session_manager"], stdout=subprocess.PIPE)
            old_pid = pgrep_process.communicate()[0].strip()
            subprocess.call(["pkill", constants.SESSION_MANAGER])
            utils.poll_for_condition(lambda: self._session_manager_ready(old_pid), timeout=20)
        assert os.path.exists(minidumps_file)

        # Enable chrome testing interface and Login
        deps_dir = os.path.join(self.autodir, "deps")
        pyautolib_dir = os.path.join(self.cr_source_dir, "chrome", "test", "pyautolib")
        login_cmd = cros_ui.xcommand_as(
            "python %s chromeos_utils.ChromeosUtils.LoginToDefaultAccount "
            "-v --no-http-server" % os.path.join(pyautolib_dir, "chromeos", "chromeos_utils.py")
        )
        utils.system(login_cmd)

        # Run pyauto tests in the "FULL" suite
        functional_cmd = cros_ui.xcommand_as(
            "%s/chrome_test/test_src/chrome/test/functional/" "pyauto_functional.py --suite=FULL -v" % deps_dir
        )
        utils.system(functional_cmd)
    def run_once(self):
        # Make sure Chrome minidumps are written locally.
        minidumps_file = '/mnt/stateful_partition/etc/enable_chromium_minidumps'
        if not os.path.exists(minidumps_file):
            open(minidumps_file, 'w').close()
            pgrep_process = subprocess.Popen(['pgrep', 'session_manager'],
                                             stdout=subprocess.PIPE)
            old_pid = pgrep_process.communicate()[0].strip()
            subprocess.call(['pkill', constants.SESSION_MANAGER])
            utils.poll_for_condition(
                lambda: self._session_manager_ready(old_pid), timeout=20)
        assert os.path.exists(minidumps_file)

        # Enable Chrome testing interface and Login
        deps_dir = os.path.join(self.autodir, 'deps')
        pyautolib_dir = os.path.join(self.cr_source_dir,
                                     'chrome', 'test', 'pyautolib')
        login_cmd = cros_ui.xcommand_as(
            'python %s chromeos_utils.ChromeosUtils.LoginToDefaultAccount '
            '-v --no-http-server' %
                os.path.join(pyautolib_dir, 'chromeos', 'chromeos_utils.py'))
        utils.system(login_cmd)

        # Run pyauto tests in the "CHROMEOS_FLASH" test suite
        chronos_id = pwd.getpwnam('chronos')
        os.chown(os.getcwd(), chronos_id.pw_uid, chronos_id.pw_gid)
        functional_cmd = cros_ui.xcommand_as(
            '%s/chrome_test/test_src/chrome/test/functional/'
            'pyauto_functional.py --suite=CHROMEOS_FLASH -v' % deps_dir)
        utils.system(functional_cmd)
    def run_once(self):
        # Make sure Chrome minidumps are written locally.
        minidumps_file = '/mnt/stateful_partition/etc/enable_chromium_minidumps'
        if not os.path.exists(minidumps_file):
            open(minidumps_file, 'w').close()
            pgrep_process = subprocess.Popen(['pgrep', 'session_manager'],
                                             stdout=subprocess.PIPE)
            old_pid = pgrep_process.communicate()[0].strip()
            subprocess.call(['pkill', constants.SESSION_MANAGER])
            utils.poll_for_condition(
                lambda: self._session_manager_ready(old_pid), timeout=20)
        assert os.path.exists(minidumps_file)

        # Enable Chrome testing interface and Login
        deps_dir = os.path.join(self.autodir, 'deps')
        pyautolib_dir = os.path.join(self.cr_source_dir, 'chrome', 'test',
                                     'pyautolib')
        login_cmd = cros_ui.xcommand_as(
            'python %s chromeos_utils.ChromeosUtils.LoginToDefaultAccount '
            '-v --no-http-server' %
            os.path.join(pyautolib_dir, 'chromeos', 'chromeos_utils.py'))
        utils.system(login_cmd)

        # Run pyauto tests in the "CHROMEOS_FLASH" test suite
        chronos_id = pwd.getpwnam('chronos')
        os.chown(os.getcwd(), chronos_id.pw_uid, chronos_id.pw_gid)
        functional_cmd = cros_ui.xcommand_as(
            '%s/chrome_test/test_src/chrome/test/functional/'
            'pyauto_functional.py --suite=CHROMEOS_FLASH -v' % deps_dir)
        utils.system(functional_cmd)
    def run_once(self, args=[]):
        """Runs the PyAuto performance tests."""
        options, test_args = self.parse_args(args)
        test_args = ' '.join(test_args)

        # Enable Chrome testing interface and login to a default account.
        deps_dir = os.path.join(self.autodir, 'deps')
        pyautolib_dir = os.path.join(self.cr_source_dir, 'chrome', 'test',
                                     'pyautolib')
        login_cmd = cros_ui.xcommand_as(
            'python %s chromeos_utils.ChromeosUtils.LoginToDefaultAccount '
            '-v --no-http-server' %
            os.path.join(pyautolib_dir, 'chromeos', 'chromeos_utils.py'))
        utils.system(login_cmd)

        # Run the PyAuto performance tests.
        functional_cmd = cros_ui.xcommand_as(
            '%s/chrome_test/test_src/chrome/test/functional/'
            'pyauto_functional.py --suite=CHROMEOS_PERF -v %s' %
            (deps_dir, test_args))
        environment = os.environ.copy()
        if options.num_iterations:
            environment['NUM_ITERATIONS'] = str(options.num_iterations)
        if options.max_timeouts:
            environment['MAX_TIMEOUT_COUNT'] = str(options.max_timeouts)
        proc = subprocess.Popen(functional_cmd,
                                shell=True,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT,
                                env=environment)
        output = proc.communicate()[0]
        print output  # Ensure pyauto test output is stored in autotest logs.

        # Output perf keyvals for any perf results recorded during the tests.
        re_compiled = re.compile(
            '%s(.+)%s' % (self._PERF_MARKER_PRE, self._PERF_MARKER_POST))
        perf_lines = [
            line for line in output.split('\n') if re_compiled.match(line)
        ]
        if perf_lines:
            perf_dict = dict([
                eval(re_compiled.match(line).group(1)) for line in perf_lines
            ])
            self.write_perf_keyval(perf_dict)

        # Fail the autotest if any pyauto tests failed.  This is done after
        # writing perf keyvals so that any computed results from passing tests
        # are still graphed.
        if proc.returncode != 0:
            raise error.TestFail(
                'Unexpected return code from pyauto_functional.py when running '
                'with the CHROMEOS_PERF suite: %d' % proc.returncode)
    def run_once(self):
        # Enable chrome testing interface and Login
        deps_dir = os.path.join(self.autodir, 'deps')
        pyautolib_dir = os.path.join(self.cr_source_dir,
                                     'chrome', 'test', 'pyautolib')
        login_cmd = cros_ui.xcommand_as(
            'python %s chromeos_utils.ChromeosUtils.LoginToDefaultAccount '
            '-v --no-http-server' %
                os.path.join(pyautolib_dir, 'chromeos', 'chromeos_utils.py'))
        utils.system(login_cmd)

        # Run pyauto tests in the "FULL" suite
        functional_cmd = cros_ui.xcommand_as(
            '%s/chrome_test/test_src/chrome/test/functional/' \
            'pyauto_functional.py --suite=FULL ' \
            '-v --no-http-server' % deps_dir)
        utils.system(functional_cmd)
    def run_once(self,
                 suite=None,
                 tests=None,
                 as_chronos=True,
                 auto_login=True):
        """Run pyauto functional tests.

        Args:
            suite: the pyauto functional suite to run.
            tests: the test modules to run.
            as_chronos: if True, run tests as chronos.
            auto_login: if True, login to default account before firing off.

        Either suite or tests should be specified, not both.
        """
        assert suite or tests, 'Should specify suite or tests'
        assert not (suite and tests), \
            'Should specify either suite or tests, not both'

        deps_dir = os.path.join(self.autodir, 'deps')
        if auto_login:
            # Enable chrome testing interface and Login.
            pyautolib_dir = os.path.join(self.cr_source_dir, 'chrome', 'test',
                                         'pyautolib')
            login_cmd = cros_ui.xcommand_as(
                'python %s chromeos_utils.ChromeosUtils.LoginToDefaultAccount '
                '-v --no-http-server' %
                os.path.join(pyautolib_dir, 'chromeos', 'chromeos_utils.py'))
            print 'Login cmd', login_cmd
            utils.system(login_cmd)

        # Run tests.
        functional_cmd = 'python %s/chrome_test/test_src/' \
            'chrome/test/functional/pyauto_functional.py -v ' % deps_dir
        if suite:
            functional_cmd += ' --suite=%s' % suite
        elif tests:
            functional_cmd += tests

        if as_chronos:
            launch_cmd = cros_ui.xcommand_as(functional_cmd)
        else:
            launch_cmd = cros_ui.xcommand(functional_cmd)
        print 'Test launch cmd', launch_cmd
        utils.system(launch_cmd)
Ejemplo n.º 8
0
 def run_once(self):
     """Run pyauto functional tests."""
     # Enable chrome testing interface and Login
     deps_dir = os.path.join(self.autodir, 'deps')
     pyautolib_dir = os.path.join(self.cr_source_dir, 'chrome', 'test',
                                  'pyautolib')
     functional_cmd = cros_ui.xcommand_as(
         '%s/chrome_test/test_src/chrome/test/functional/'
         'pyauto_functional.py --suite=CHROMEOS_CONNECTIVITY -v' % deps_dir)
     utils.system(functional_cmd)
 def run_once(self):
     """Run pyauto functional tests."""
     # Enable chrome testing interface and Login
     deps_dir = os.path.join(self.autodir, 'deps')
     pyautolib_dir = os.path.join(self.cr_source_dir,
                                  'chrome', 'test', 'pyautolib')
     functional_cmd = cros_ui.xcommand_as(
         '%s/chrome_test/test_src/chrome/test/functional/'
         'pyauto_functional.py --suite=CHROMEOS_CONNECTIVITY -v' % deps_dir)
     utils.system(functional_cmd)
    def run_once(self, suite=None, tests=None,
                 as_chronos=True, auto_login=True):
        """Run pyauto functional tests.

        Args:
            suite: the pyauto functional suite to run.
            tests: the test modules to run.
            as_chronos: if True, run tests as chronos.
            auto_login: if True, login to default account before firing off.

        Either suite or tests should be specified, not both.
        """
        assert suite or tests, 'Should specify suite or tests'
        assert not (suite and tests), \
            'Should specify either suite or tests, not both'

        deps_dir = os.path.join(self.autodir, 'deps')
        if auto_login:
            # Enable chrome testing interface and Login.
            pyautolib_dir = os.path.join(self.cr_source_dir,
                                         'chrome', 'test', 'pyautolib')
            login_cmd = cros_ui.xcommand_as(
                'python %s chromeos_utils.ChromeosUtils.LoginToDefaultAccount '
                '-v --no-http-server' % os.path.join(
                    pyautolib_dir, 'chromeos', 'chromeos_utils.py'))
            print 'Login cmd', login_cmd
            utils.system(login_cmd)

        # Run tests.
        functional_cmd = 'python %s/chrome_test/test_src/' \
            'chrome/test/functional/pyauto_functional.py -v ' % deps_dir
        if suite:
            functional_cmd += ' --suite=%s' % suite
        elif tests:
            functional_cmd += tests

        if as_chronos:
            launch_cmd = cros_ui.xcommand_as(functional_cmd)
        else:
            launch_cmd = cros_ui.xcommand(functional_cmd)
        print 'Test launch cmd', launch_cmd
        utils.system(launch_cmd)