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 """Downloads, installs, and verifies component updated flash.""" 14 version = 1 15 16 def _run_client_test(self, name, CU_action): 17 """Runs client test.""" 18 logging.info('+++++ component_UpdateFlash +++++') 19 logging.info('Performing %s', CU_action) 20 try: 21 self.autotest_client.run_test(name, 22 CU_action=CU_action, 23 tag=CU_action, 24 check_client_result=True) 25 except: 26 raise error.TestFail('Failed: %s.' % CU_action) 27 28 def _run_flash_sanity(self): 29 """Verify that simple Flash site runs.""" 30 self._run_client_test('desktopui_FlashSanityCheck', CU_action='sanity') 31 32 def _delete_component(self): 33 """Deletes any installed Flash component binaries.""" 34 self._run_client_test( 35 'desktopui_FlashSanityCheck', CU_action='delete-component') 36 # Unfortunately deleting the component requires a reboot to get rid of 37 # the mount at /run/imageloader/PepperFlashPlayer. 38 self._reboot() 39 40 def _download_omaha_component(self): 41 """Forces the download of components from Omaha server.""" 42 self._run_client_test( 43 'desktopui_FlashSanityCheck', CU_action='download-omaha-component') 44 45 def _verify_component_flash(self): 46 """Runs Flash and verifies it uses component binaries.""" 47 self._run_client_test( 48 'desktopui_FlashSanityCheck', CU_action='verify-component-flash') 49 50 def _verify_system_flash(self): 51 """Runs Flash and verifies it uses system binaries.""" 52 self._run_client_test( 53 'desktopui_FlashSanityCheck', CU_action='verify-system-flash') 54 55 def _verify_clean_shutdown(self): 56 """Verifies that the stateful partition was cleaned up on shutdown.""" 57 try: 58 self.autotest_client.run_test('platform_CleanShutdown', 59 check_client_result=True) 60 except: 61 raise error.TestFail('Failed: platform_CleanShutdown') 62 63 def _reboot(self): 64 """Reboot the DUT.""" 65 self.host.reboot() 66 67 def cleanup(self): 68 """Leaves this test without a component Flash installed.""" 69 logging.info('+++++ Cleaning DUT for other tests +++++') 70 self._delete_component() 71 72 def run_once(self, host): 73 """Runs Flash component update test.""" 74 self.host = host 75 self.autotest_client = autotest.Autotest(self.host) 76 # Paranoia: by rebooting the DUT we protect this test from other tests 77 # leaving running webservers behind. 78 logging.info('+++++ Rebooting DUT on start to reduce flakes +++++') 79 self._reboot() 80 # Test Flash once with whatever was the default on the DUT. 81 self._run_flash_sanity() 82 # Start with a clean slate. 83 self._delete_component() 84 self._verify_system_flash() 85 # Force a download. 86 self._download_omaha_component() 87 # Currently mounting the component binaries requires a reboot. 88 self._reboot() 89 self._verify_component_flash() 90 # Reboot again to see if a clean unmount happens. 91 self._reboot() 92 self._verify_clean_shutdown() 93