• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 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 autotest
9from autotest_lib.server import test
10
11
12class policy_ExternalStorageServer(test.test):
13    """
14    This test connects the servo repair USB stick then runs a client-side test
15    that relies on a USB being connected.
16
17    """
18    version = 1
19
20
21    def _run_client_test(self, name, case):
22        """
23        Run client test.
24
25        @raises error.TestFail: In the instance were the client test fails.
26
27        """
28        logging.info('Performing %s' % case)
29        self.autotest_client.run_test(name,
30                                      case=case,
31                                      check_client_result=True)
32
33
34    def cleanup(self):
35        """Disconnect USB stick."""
36        self.host.servo.switch_usbkey('host')
37
38
39    def run_once(self, host, client_test=''):
40        """
41        @param host: A host object representing the DUT.
42        @param client_test: Name of client test to run.
43
44        """
45        self.host = host
46        self.autotest_client = autotest.Autotest(self.host)
47
48        # Connect servo repair USB stick
49        self.host.servo.switch_usbkey('dut')
50
51        policy_values = ['True_Block', 'NotSet_Allow', 'False_Allow']
52
53        for case in policy_values:
54            self._run_client_test(client_test, case)
55