• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2020 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.bin import test
8from autotest_lib.client.common_lib import error
9from autotest_lib.client.common_lib.cros.cfm.apollo import apollo_utils
10
11
12class enterprise_CFM_ApolloPeripheralPowerCycle(test.test):
13    """
14    Disables then re-enables Power over Ethernet for the given IP port.
15
16    NOTE: This test turns off the given peripheral, which could impact other Apollo tests.
17    (autotests shouldn't assume anything about the device state.)
18    """
19    version = 1
20
21    def run_once(self, port):
22        apollo_utils.ectool_pse_disable(port)
23        status = apollo_utils.ectool_pse_status(port)
24
25        if status != 'disabled':
26            raise error.TestError('IP port status not disabled')
27
28        # TODO: Is there meaningful check we can add here?
29        # (We may need to add a "peripheral" param as well)
30
31        apollo_utils.ectool_pse_enable(port)
32        status = apollo_utils.ectool_pse_status(port)
33
34        if status not in ['enabled', 'powered']:
35            raise error.TestError('IP port status not enabled')
36