1# Copyright 2018 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 5from autotest_lib.client.common_lib import error 6from autotest_lib.client.common_lib.cros import tpm_utils 7from autotest_lib.server.cros.update_engine import update_engine_test 8 9class autoupdate_NonBlockingOOBEUpdate(update_engine_test.UpdateEngineTest): 10 """Try a non-critical (non-blocking) update at OOBE which should fail.""" 11 version = 1 12 13 _NON_CRITICAL_ERROR = 'finished OmahaRequestAction with code ' \ 14 'ErrorCode::kNonCriticalUpdateInOOBE' 15 16 def cleanup(self): 17 """Remove the custom lsb-release used by the test.""" 18 self._clear_custom_lsb_release() 19 super(autoupdate_NonBlockingOOBEUpdate, self).cleanup() 20 21 22 def run_once(self, full_payload=True, job_repo_url=None): 23 """ 24 Tries an autoupdate during ChromeOS OOBE without a deadline. 25 26 An Omaha response to update with a deadline attribute is considered 27 critical and should be performed during OOBE. Non critical updates do 28 not have a deadline and should not be executed. 29 30 @param full_payload: True for a full payload. False for delta. 31 @param job_repo_url: Used for debugging locally. This is used to figure 32 out the current build and the devserver to use. 33 The test will read this from a host argument 34 when run in the lab. 35 36 """ 37 tpm_utils.ClearTPMOwnerRequest(self._host) 38 payload_url = self.get_payload_for_nebraska(job_repo_url, 39 full_payload=full_payload) 40 self._run_client_test_and_check_result('autoupdate_StartOOBEUpdate', 41 payload_url=payload_url, 42 full_payload=full_payload, 43 critical_update=False) 44 45 # Check that the update failed as expected. 46 if self._check_update_engine_log_for_entry(self._NON_CRITICAL_ERROR): 47 return 48 49 err_str = "The update was expected to fail with error code " \ 50 "'kNonCriticalUpdateInOOBE' because the update response " \ 51 "was not critical and we are still at OOBE. This didn't " \ 52 "happen." 53 54 # Is there an update in progress? 55 if not self._is_update_engine_idle(): 56 raise error.TestFail('An update was in progress when it should ' 57 'not have started. %s' % err_str) 58 # Were any update requests fired? 59 elif not self._get_update_requests(): 60 raise error.TestFail('There were no update requests in ' 61 'update_engine.log. OOBE update screen was ' 62 'missed. %s' % err_str) 63 else: 64 err_code = self._get_last_error_string() 65 if err_code is not None: 66 err_str = '%s Actual Error: %s' % (err_str, err_code) 67 raise error.TestFail(err_str) 68