1# Copyright 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 import test
9
10
11class firmware_FingerprintCrosConfig(test.test):
12    """Test ChromeOS config behavior for http://b/160271883."""
13    version = 1
14
15    def initialize(self, host):
16        self.host = host
17
18    def run_cmd(self, command, timeout=300):
19        """Runs command on the DUT; return result with output and exit code."""
20        logging.debug('DUT Execute: %s', command)
21        result = self.host.run(command, timeout=timeout, ignore_status=True)
22        logging.info('exit_code: %d', result.exit_status)
23        logging.info('stdout:\n%s', result.stdout)
24        logging.info('stderr:\n%s', result.stderr)
25        return result
26
27    def _run_cros_config_cmd_cat(self, command):
28        """Runs cat /run/chromeos-config/v1 on DUT; return result."""
29        cmd = "cat /run/chromeos-config/v1/{}".format(command)
30        return self.run_cmd(cmd)
31
32    def run_once(self):
33        """Run the test."""
34        result = self._run_cros_config_cmd_cat('fingerprint/board')
35        if result.exit_status != 0:
36            raise error.TestFail(
37                'Unable to get fingerprint board with cros_config')
38        logging.info('fingerprint board: %s\n', result.stdout.rstrip())
39