1# Copyright (c) 2021 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
5import logging
6
7from autotest_lib.client.common_lib import error
8from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
9
10
11class firmware_ECSystemLocked(FirmwareTest):
12    """
13    Ensure that CONFIG_SYSTEM_UNLOCKED is not set.
14    """
15    version = 1
16
17    def run_once(self):
18        """Runs a single iteration of the test."""
19        if not self.check_ec_capability():
20            raise error.TestNAError(
21                    "Nothing needs to be tested on this device")
22
23        self.set_ec_write_protect_and_reboot(True)
24
25        logging.info("Querying sysinfo.")
26        verdict = self.ec.send_command_get_output("sysinfo",
27                                                  ["Flags:\s+([^\s]+)\s*.*$"])
28
29        if len(verdict) > 0 and len(verdict[0]) > 1:
30            if verdict[0][1] != 'locked':
31                raise error.TestFail(
32                        "Device is not locked, sysinfo returned %s" %
33                        verdict[0][0])
34        else:
35            raise error.TestFail("Could not parse sysinfo")
36