Exemple #1
0
    def initialize(self):
        chrome_test.ChromeTestBase.initialize(self, nuke_browser_norestart=False)
        assert os.geteuid() == 0, "Need superuser privileges"

        deps_dir = os.path.join(self.autodir, "deps")
        subprocess.check_call(["chown", "-R", "chronos", self.cr_source_dir])

        # Setup suid python binary which can enable chrome testing interface.
        suid_python = os.path.join(self.test_binary_dir, "suid-python")
        py_path = subprocess.Popen(["which", "python"], stdout=subprocess.PIPE).communicate()[0]
        py_path = py_path.strip()
        assert os.path.exists(py_path), "Could not find python"
        if os.path.islink(py_path):
            linkto = os.readlink(py_path)
            py_path = os.path.join(os.path.dirname(py_path), linkto)
        shutil.copy(py_path, suid_python)
        os.chown(suid_python, 0, 0)
        os.chmod(suid_python, 04755)

        # chronos should own the current dir.
        chronos_id = pwd.getpwnam("chronos")
        os.chown(os.getcwd(), chronos_id.pw_uid, chronos_id.pw_gid)

        # Allow browser restart by its babysitter (session_manager)
        if os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE):
            os.remove(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE)
        assert not os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE)

        # 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()
            cros_ui.nuke()
        assert os.path.exists(minidumps_file)
    def initialize(self):
        chrome_test.ChromeTestBase.initialize(self)
        assert os.geteuid() == 0, 'Need superuser privileges'

        deps_dir = os.path.join(self.autodir, 'deps')
        subprocess.check_call(['chown', '-R', 'chronos', self.cr_source_dir])

        # Setup suid python binary which can enable chrome testing interface
        suid_python = os.path.join(self.test_binary_dir, 'suid-python')
        py_path = subprocess.Popen(['which', 'python'],
                                   stdout=subprocess.PIPE).communicate()[0]
        py_path = py_path.strip()
        assert os.path.exists(py_path), 'Could not find python'
        if os.path.islink(py_path):
            linkto = os.readlink(py_path)
            py_path = os.path.join(os.path.dirname(py_path), linkto)
        shutil.copy(py_path, suid_python)
        os.chown(suid_python, 0, 0)
        os.chmod(suid_python, 04755)

        # chronos should own the current dir
        chronos_id = pwd.getpwnam('chronos')
        os.chown(os.getcwd(), chronos_id.pw_uid, chronos_id.pw_gid)

        # 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()
            # Allow browser restart by its babysitter (session_manager)
            if os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE):
                os.remove(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE)
            cros_ui.nuke()
        assert os.path.exists(minidumps_file)

        # Setup /tmp/disable_chrome_restart
        # Disallow further browser restart by its babysitter
        if not os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE):
            open(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE, 'w').close()
        assert os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE)
    def initialize(self):
        chrome_test.ChromeTestBase.initialize(self)
        assert os.geteuid() == 0, 'Need superuser privileges'

        deps_dir = os.path.join(self.autodir, 'deps')
        subprocess.check_call(['chown', '-R', 'chronos', self.cr_source_dir])

        # Setup suid python binary which can enable Chrome testing interface.
        suid_python = os.path.join(self.test_binary_dir, 'suid-python')
        py_path = subprocess.Popen(['which', 'python'],
                                   stdout=subprocess.PIPE).communicate()[0]
        py_path = py_path.strip()
        assert os.path.exists(py_path), 'Could not find python'
        if os.path.islink(py_path):
            linkto = os.readlink(py_path)
            py_path = os.path.join(os.path.dirname(py_path), linkto)
        shutil.copy(py_path, suid_python)
        os.chown(suid_python, 0, 0)
        os.chmod(suid_python, 04755)

        # User chronos should own the current directory.
        chronos_id = pwd.getpwnam('chronos')
        os.chown(os.getcwd(), chronos_id.pw_uid, chronos_id.pw_gid)

        # 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()
            # Allow browser restart by its babysitter (session_manager).
            if os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE):
                os.remove(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE)
            cros_ui.nuke()
        assert os.path.exists(minidumps_file)

        # Setup /tmp/disable_chrome_restart.
        # Disallow further browser restart by its babysitter.
        if not os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE):
            open(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE, 'w').close()
        assert os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE)
        clean_exit = False
        try:
            time.sleep(1)
            new_pid = utils.system_output('pgrep %s' %
                constants.SESSION_MANAGER)
            if orig_pid != new_pid:
                # This is expected behaviour of the session manager.
                pass

            # Copy over chrome, chrome.pak, locales, chromeos needed for test.
            utils.system('cp -r %s/* .' % '/opt/google/chrome')

            # Setup parameters
            params = ('--url="%s" --wait_js_expr="%s" --wait_js_timeout=%d' %
                        (url, js_expr, timeout))
            utils.system('./%s %s' % (url_fetch_test, params))

        except error.CmdError, e:
            logging.debug(e)
            raise error.TestFail('Gmail Latency test was unsuccessful in %s'
                                 % os.getcwd())

        finally:
            # Allow chrome to be restarted again.
            os.unlink(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE)

            # Reset the UI but only if we need to (avoid double reset).
            if not clean_exit:
                cros_ui.nuke()
Exemple #5
0
 def cleanup(self):
     """Reset the UI, since this test killed Chrome."""
     cros_ui.nuke()