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 5 import logging 6 7 from autotest_lib.server.cros.update_engine import update_engine_test 8 9 10 class autoupdate_DataPreserved(update_engine_test.UpdateEngineTest): 11 """Ensure user data and preferences are preserved during an update.""" 12 version = 1 13 14 def cleanup(self): 15 # Get the last two update_engine logs: before and after reboot. 16 files = self._host.run('ls -t -1 %s' % 17 self._UPDATE_ENGINE_LOG_DIR).stdout.splitlines() 18 for i in range(2): 19 self._host.get_file('%s%s' % (self._UPDATE_ENGINE_LOG_DIR, 20 files[i]), self.resultsdir) 21 super(autoupdate_DataPreserved, self).cleanup() 22 23 24 def run_once(self, host, full_payload=True, job_repo_url=None): 25 """ 26 Tests that users timezone, input methods, and downloads are preserved 27 during an update. 28 29 @param host: The DUT that we are running on. 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 self._host = host 38 39 update_url = self.get_update_url_for_test(job_repo_url, 40 full_payload=full_payload, 41 critical_update=True) 42 logging.info('Update url: %s', update_url) 43 44 # Change input method and timezone, create a file, then start update. 45 self._run_client_test_and_check_result('autoupdate_UserData', 46 update_url=update_url) 47 self._wait_for_update_to_complete() 48 self._host.reboot() 49 50 # Ensure preferences and downloads are the same as before the update. 51 self._run_client_test_and_check_result('autoupdate_UserData', 52 update_url=update_url, 53 after_update=True) 54