• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 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"""Auto test for Atrus firmware updater functionality."""
5
6import logging
7
8from autotest_lib.client.bin import test
9from autotest_lib.client.common_lib import error
10from autotest_lib.client.common_lib.cros.cfm.atrus import atrus_utils
11
12
13class enterprise_CFM_AtrusUpdaterStress(test.test):
14    """
15    Atrus firmware updater functionality test for Chrome Box for Meetings.
16
17    The procedure of the test is:
18    1. Trigger forced upgrade of the atrus via atrusctl with dbus.
19    2. Wait for the updater to finish, and check status of upgrade.
20            The upgrade will be successfull if the transfer of the binary was
21            successfull, and if the writing of the binary to flash was
22            successfull.
23    3. Repeat
24    """
25
26    version = 1
27
28    def run_once(self, repeat=1):
29        """Main test procedure."""
30        successfull_upgrades = 0
31
32        # Check if Atrusctl is running and have dbus enabled
33        if not atrus_utils.check_dbus_available():
34            raise error.TestError('No DBus support in atrusd.')
35
36        for cycle in xrange(repeat):
37
38            atrus_utils.wait_for_atrus_enumeration()
39
40            if atrus_utils.force_upgrade_atrus():
41                successfull_upgrades += 1
42
43            logging.info('Successful attempts: {}/{}'
44                    .format(successfull_upgrades,cycle+1))
45
46        if successfull_upgrades < repeat:
47            raise error.TestFail('Upgrade failed in {}/{} of tries.'
48                    .format(repeat - successfull_upgrades, repeat))
49