• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import logging
6
7from autotest_lib.client.common_lib import error
8from autotest_lib.server import autotest
9from autotest_lib.server import test
10
11
12class component_UpdateFlash(test.test):
13    version = 1
14
15    def _run_client_test(self, name, CU_action):
16        """Runs client test."""
17        logging.info('+++++ component_UpdateFlash +++++')
18        logging.info('Performing %s', CU_action)
19        try:
20            self.autotest_client.run_test(name,
21                                          CU_action=CU_action,
22                                          tag=CU_action,
23                                          check_client_result=True)
24        except:
25            raise error.TestError('Failed: %s.' % CU_action)
26
27    def _run_flash_sanity(self):
28        """Verify that simple Flash site runs."""
29        self._run_client_test('desktopui_FlashSanityCheck', CU_action='sanity')
30
31    def _delete_component(self):
32        """Deletes any installed Flash component binaries."""
33        self._run_client_test(
34            'desktopui_FlashSanityCheck', CU_action='delete-component')
35        # Unfortunately deleting the component requires a reboot to get rid of
36        # the mount at /run/imageloader/PepperFlashPlayer.
37        self._reboot()
38
39    def _download_omaha_component(self):
40        """Forces the download of components from Omaha server."""
41        self._run_client_test(
42            'desktopui_FlashSanityCheck', CU_action='download-omaha-component')
43
44    def _verify_component_flash(self):
45        """Runs Flash and verifies it uses component binaries."""
46        self._run_client_test(
47            'desktopui_FlashSanityCheck', CU_action='verify-component-flash')
48
49    def _verify_system_flash(self):
50        """Runs Flash and verifies it uses system binaries."""
51        self._run_client_test(
52            'desktopui_FlashSanityCheck', CU_action='verify-system-flash')
53
54    def _reboot(self):
55        """Reboot the DUT."""
56        self.host.reboot()
57
58    def cleanup(self):
59        """Leaves this test without a component Flash installed."""
60        logging.info('+++++ Cleaning DUT for other tests +++++')
61        self._delete_component()
62
63    def run_once(self, host):
64        """Runs Flash component update test."""
65        self.host = host
66        self.autotest_client = autotest.Autotest(self.host)
67        # Paranoia: by rebooting the DUT we protect this test from other tests
68        # leaving running webservers behind.
69        logging.info('+++++ Rebooting DUT on start to reduce flakes +++++')
70        self._reboot()
71        # Test Flash once with whatever was the default on the DUT.
72        self._run_flash_sanity()
73        # Start with a clean slate.
74        self._delete_component()
75        self._verify_system_flash()
76        # Force a download.
77        self._download_omaha_component()
78        # Currently mounting the component binaries requires a reboot.
79        self._reboot()
80        self._verify_component_flash()
81