示例#1
0
    def run(self, local_info, router_context, gql_token, fp):
        """
      """
        # Ugly!
        test_info = self.test_info(local_info, router_context)
        self.output.test_start(test_info, status=Output.Status.OK)
        params = self.get_params()

        if self.check_user("root") != Output.Status.OK:
            return self.output.test_end(fp)

        self.output.progress_start(fp)

        json_data = {}
        error_lines = []
        ethtool = Linux.Ethtool(debug=self.debug, progobj=self)
        # Ugly....
        self.fp = fp
        shell_status = ethtool.run_linux_args(local_info, router_context,
                                              params['node_type'],
                                              params['linux_device'],
                                              error_lines, json_data)
        # Ugly...
        self.fp = None

        if self.debug:
            print('........ flattened list ..........')
            pprint.pprint(json_data)

        engine = EntryTest.Parser(debug=self.debug)
        engine.eval_entry_by_tests(json_data, params["entry_tests"])

        self.output.proc_test_result(json_data)
        return self.output.test_end(fp)
示例#2
0
def test_ethtool():
    ethtool_info_text = """
Settings for enp0s20f0:
    Supported ports: [ TP ]
    Supported link modes:   10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Full 
    Supported pause frame use: Symmetric
    Supports auto-negotiation: Yes
    Supported FEC modes: Not reported
    Advertised link modes:  10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Full 
    Advertised pause frame use: Symmetric
    Advertised auto-negotiation: Yes
    Advertised FEC modes: Not reported
    Speed: 1000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: on (auto)
    Supports Wake-on: pumbg
    Wake-on: g
    Current message level: 0x00000007 (7)
    drv probe link
    Link detected: yes
"""

    expected = {
        'Advertised_FEC_modes': 'Not reported',
        'Advertised_link_modes': '10baseT/Half 10baseT/Full ',
        'Advertised_pause_frame_use': 'Symmetric',
        'Current_message_level': '0x00000007 (7)',
        'Duplex': 'Full',
        'Link_detected': 'yes',
        'PHYAD': '0',
        'Port': 'Twisted Pair',
        'Speed': '1000Mb/s',
        'Supported_FEC_modes': 'Not reported',
        'Supported_link_modes': '10baseT/Half 10baseT/Full ',
        'Supported_pause_frame_use': 'Symmetric',
        'Supported_ports': '[ TP ]',
        'Transceiver': 'internal'
    }

    e = Linux.Ethtool(debug=True)
    output = ethtool_info_text.splitlines()
    json_dict = e.convert_to_json(output)
    assert json_dict == expected