1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-23 00:29:59 +02:00

add ethtool parser tests

This commit is contained in:
Kelly Brazil
2024-03-01 13:52:45 -08:00
parent 5e88eb0c8b
commit abbd4820fd
8 changed files with 121 additions and 1 deletions

View File

@ -149,7 +149,7 @@ def _parse_default(data: str) -> JSONDictType:
raw_output['name'] = line.split()[2][:-1]
continue
data_line = line.replace('\t', ' ')
data_line = line.replace('\t', ' ')
if not data_line.startswith(' '): # 9 spaces
mode = ''

View File

@ -0,0 +1 @@
{"name":"enp0s3","supported_pause_frame_use":"No","supports_auto_negotiation":true,"supported_fec_modes":"Not reported","advertised_pause_frame_use":false,"advertised_auto_negotiation":true,"advertised_fec_modes":"Not reported","speed":"1000Mb/s","duplex":"Full","port":"Twisted Pair","phyad":"0","transceiver":"internal","auto_negotiation":false,"mdi_x":"off (auto)","supports_wake_on":"umbg","wake_on":"d","link_detected":true,"supported_ports":["TP"],"supported_link_modes":["10baseT/Half","10baseT/Full","100baseT/Half","100baseT/Full","1000baseT/Full"],"advertised_link_modes":["10baseT/Half","10baseT/Full","100baseT/Half","100baseT/Full","1000baseT/Full"],"current_message_level":["0x00000007 (7)","drv probe link"],"speed_bps":1000000000}

View File

@ -0,0 +1,26 @@
Settings for enp0s3:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: No
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: No
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: off (auto)
Supports Wake-on: umbg
Wake-on: d
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes

View File

@ -0,0 +1 @@
{"name":"enp1s0","supported_pause_frame_use":"Symmetric Receive-only","supports_auto_negotiation":true,"supported_fec_modes":"Not reported","advertised_pause_frame_use":false,"advertised_auto_negotiation":true,"advertised_fec_modes":"Not reported","speed":"40000Mb/s","duplex":"Full","auto_negotiation":false,"port":"FIBRE","phyad":"0","transceiver":"internal","supports_wake_on":"d","wake_on":"d","link_detected":true,"supported_ports":["FIBRE"],"supported_link_modes":["10000baseKX4/Full","40000baseCR4/Full","40000baseSR4/Full","56000baseCR4/Full","56000baseSR4/Full","1000baseX/Full","10000baseCR/Full","10000baseSR/Full"],"advertised_link_modes":["10000baseKX4/Full","40000baseCR4/Full","40000baseSR4/Full","1000baseX/Full","10000baseCR/Full","10000baseSR/Full"],"current_message_level":["0x00000014 (20)","link ifdown"],"speed_bps":40000000000}

View File

@ -0,0 +1,33 @@
Settings for enp1s0:
Supported ports: [ FIBRE ]
Supported link modes: 10000baseKX4/Full
40000baseCR4/Full
40000baseSR4/Full
56000baseCR4/Full
56000baseSR4/Full
1000baseX/Full
10000baseCR/Full
10000baseSR/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10000baseKX4/Full
40000baseCR4/Full
40000baseSR4/Full
1000baseX/Full
10000baseCR/Full
10000baseSR/Full
Advertised pause frame use: Symmetric
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Speed: 40000Mb/s
Duplex: Full
Auto-negotiation: off
Port: FIBRE
PHYAD: 0
Transceiver: internal
Supports Wake-on: d
Wake-on: d
Current message level: 0x00000014 (20)
link ifdown
Link detected: yes

View File

@ -0,0 +1 @@
{"identifier":"0x03 (SFP)","extended_identifier":"0x04 (GBIC/SFP defined by 2-wire interface ID)","connector":"0x21 (Copper pigtail)","transceiver_codes":"0x01 0x00 0x00 0x04 0x00 0x04 0x80 0xd5 0x00","transceiver_type":["Infiniband: 1X Copper Passive","Ethernet: 1000BASE-CX","Passive Cable","FC: Twin Axial Pair (TW)","FC: 1200 MBytes/sec","FC: 800 MBytes/sec","FC: 400 MBytes/sec","FC: 200 MBytes/sec","FC: 100 MBytes/sec"],"encoding":"0x00 (unspecified)","br_nominal":"10300MBd","rate_identifier":"0x00 (unspecified)","length_smf_km":"0km","length_smf":"0m","length_50um":"0m","length_62_5um":"0m","length_copper":"2m","length_om3":"0m","passive_cu_cmplnce":"0x01 (SFF-8431 appendix E) [SFF-8472 rev10.4 only]","vendor_name":"UbiquitiNetworks","vendor_oui":"00:40:20","vendor_pn":"UDC-2","vendor_rev":"","option_values":"0x00 0x00","br_margin_max":"0%","br_margin_min":"0%"}

View File

@ -0,0 +1,30 @@
Identifier : 0x03 (SFP)
Extended identifier : 0x04 (GBIC/SFP defined by 2-wire interface ID)
Connector : 0x21 (Copper pigtail)
Transceiver codes : 0x01 0x00 0x00 0x04 0x00 0x04 0x80 0xd5 0x00
Transceiver type : Infiniband: 1X Copper Passive
Transceiver type : Ethernet: 1000BASE-CX
Transceiver type : Passive Cable
Transceiver type : FC: Twin Axial Pair (TW)
Transceiver type : FC: 1200 MBytes/sec
Transceiver type : FC: 800 MBytes/sec
Transceiver type : FC: 400 MBytes/sec
Transceiver type : FC: 200 MBytes/sec
Transceiver type : FC: 100 MBytes/sec
Encoding : 0x00 (unspecified)
BR, Nominal : 10300MBd
Rate identifier : 0x00 (unspecified)
Length (SMF,km) : 0km
Length (SMF) : 0m
Length (50um) : 0m
Length (62.5um) : 0m
Length (Copper) : 2m
Length (OM3) : 0m
Passive Cu cmplnce. : 0x01 (SFF-8431 appendix E) [SFF-8472 rev10.4 only]
Vendor name : UbiquitiNetworks
Vendor OUI : 00:40:20
Vendor PN : UDC-2
Vendor rev :
Option values : 0x00 0x00
BR margin, max : 0%
BR margin, min : 0%

28
tests/test_ethtool.py Normal file
View File

@ -0,0 +1,28 @@
import unittest
from tests import utils_for_test as test_utils
# Execute these steps for standard tests:
# - Save this file as `test_{parser_name}.py` since the helper methods extract parser names from the filename.
# - Organize fixtures in `tests/fixtures` for optimal structure.
# - Format fixtures as follows (using double dashes):
# - `{parser_name}--{some_test_description}.out` for command output.
# - `{parser_name}--{some_test_description}.json` for expected JSON after parsing.
class MyTests(unittest.TestCase):
def test_ethtool_nodata(self):
"""
Test 'ethtool' with no data
"""
test_utils.run_no_data(self, __file__, {})
def test_ethtool_all_fixtures(self):
"""
Test 'ethtool' with various fixtures
"""
test_utils.run_all_fixtures(self, __file__)
if __name__ == '__main__':
unittest.main()