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