1# Copyright 2017 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 5AUTHOR = "mruthven" 6NAME = "firmware_Cr50Update" 7PURPOSE = "Verify Cr50 update" 8ATTRIBUTES = "suite:faft_cr50_experimental" 9TIME = "SHORT" 10TEST_TYPE = "server" 11DEPENDENCIES = "servo_state:WORKING" 12PY_VERSION = 3 13 14DOC = """ 15This test verifies Cr50 update works or recovery from erased nvmem. 16 17To test postinstall cr50 update script set test to "post_install" or use 18firmware_Cr50Update.post_install. To test the startup script leave the test arg 19blank 20 21The test will rollback to the oldest Cr50 image and then verify each update to 22the next newest image runs successfully. If testing post install, the test will 23update using cr50-update.sh. If testing the startup script the updates will be 24run with cr50-update.conf after reboot.. 25 26The old release needs to have a version lower than the release image. The 27release image needs to have a version lower than the dev image. The dev image 28has to be newer than all of the images including the original cr50 image on 29the dut to be able to guarantee that the original state can be restored. 30If no_release path or old_release_path are given, the test will use 31old_release_ver and release_ver to fetch the images from gs://. 32 33If a valid path is given the version will be ignored. For example 34release_path='/tmp/cr50.bin.prod' or release_ver='0.0.23/ZZAF:ffffffff:7f00' 35could be used. The test will attempt to get the cr50 image from 36/tmp/cr50.bin.prod first. If that doesn't exist then it will download the 37version .23 image stored in google cloud storage. The version string needs to 38contain the epoch, major, and minor versions separated by '.' and the image 39board id. The image board id is optional. The tests can be run against all 40versions since '0.0.13'. 41 42If cr50_dbg_image_path is not specified, then the test will get the cr50 43devids and attempt to get the debug image from gs://. 44 45After the test is complete the original Cr50 image will be reflashed onto the 46device. 47 48@param iterations: the number of iterations to run 49@param cr50_dbg_image_path: the location of the DBG image. Must be built with 50 CR50_DEV=1 51@param release_path: the location of the release image 52@param release_ver: RW and BID version string used to fetch the image from gs 53@param old_release_path: the location of the old release image. 54@param old_release_ver: RW version string used to fetch the image from gs 55@param test: string representing the update type. use "post_install" if the test 56 should verify the cr50-update.sh post install script. Anything else 57 the test will run using the cr50-update.conf startup script. 58""" 59 60from autotest_lib.client.common_lib import error 61from autotest_lib.server import utils 62 63if 'args_dict' not in locals(): 64 args_dict = {} 65 66args_dict.update(utils.args_to_dict(args)) 67servo_args = hosts.CrosHost.get_servo_arguments(args_dict) 68 69iterations = int(args_dict.get("iterations", 1)) 70old_release_path = args_dict.get("old_release_path", "") 71old_release_ver = args_dict.get("old_release_ver", "") 72release_path = args_dict.get("release_path", "") 73release_ver = args_dict.get("release_ver", "") 74test = args_dict.get("test", "") 75 76def run(machine): 77 host = hosts.create_host(machine, servo_args=servo_args) 78 79 job.run_test("firmware_Cr50Update", host=host, cmdline_args=args, 80 release_path=release_path, release_ver=release_ver, 81 old_release_path=old_release_path, 82 old_release_ver=old_release_ver, test=test, 83 iterations=iterations, full_args=args_dict) 84 85parallel_simple(run, machines) 86