Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

riotctrl_shell: provide netif interactions and parsers #14441

Merged
merged 3 commits into from
Jul 7, 2020

Conversation

miri64
Copy link
Member

@miri64 miri64 commented Jul 6, 2020

Contribution description

Probably our hardest shell command to parse and execute, now as a riotctrl shell interaction. :-).

This PR also contains some fixes to the output of ifconfig to make it easier to parse. I can move them to a separate PR, if preferred, the options changed don't seem to have been checked in any tests however.

Testing procedure

tox should succeed for riotctrl_shell:

cd dist/pythonlibs/riotcrtl_shell; tox

Issues/PRs references

Follow-up on #11406

@miri64 miri64 added Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Area: tools Area: Supplementary tools CI: run tests If set, CI server will run tests on hardware for the labeled PR labels Jul 6, 2020
@miri64 miri64 added this to the Release 2020.07 milestone Jul 6, 2020
@miri64
Copy link
Member Author

miri64 commented Jul 6, 2020

@jia200x @benpicco: it would be great if you could provide example outputs of ifconfig for the respective modules you provided for testing:

I think, if possible, one example per bullet point would be enough.

Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some nits reported by the static-tests (flake8 + typos). Also some questions regarding the names of classes. Why Netif ? This seems confusing since it's a wrapper around ifconfig, same with NetifSend, it could just be Txtsnd ?
I think you could also use pytest.parametrize to factorize some test functions. I'd like to see the new interactions and parser used in our real tests :)

dist/pythonlibs/riotctrl_shell/netif.py Outdated Show resolved Hide resolved
dist/pythonlibs/riotctrl_shell/tests/test_netif.py Outdated Show resolved Hide resolved
dist/pythonlibs/riotctrl_shell/tests/test_netif.py Outdated Show resolved Hide resolved
sys/shell/commands/sc_gnrc_netif.c Outdated Show resolved Hide resolved
sys/shell/commands/sc_gnrc_netif.c Outdated Show resolved Hide resolved
sys/shell/commands/sc_gnrc_netif.c Outdated Show resolved Hide resolved
sys/shell/commands/sc_gnrc_netif.c Outdated Show resolved Hide resolved
dist/pythonlibs/riotctrl_shell/tests/test_netif.py Outdated Show resolved Hide resolved
dist/pythonlibs/riotctrl_shell/netif.py Outdated Show resolved Hide resolved
@miri64
Copy link
Member Author

miri64 commented Jul 6, 2020

Why Netif ? This seems confusing since it's a wrapper around ifconfig, same with NetifSend, it could just be Txtsnd ?

Mostly because the module is called like this. My idea was to name the classes like the module. I could name the methods like the shell command if you prefer (which I mostly already have done for netif_txtsnd()).

@miri64 miri64 force-pushed the riotctrl_shell/feat/netif branch from ceb33a7 to 1664f12 Compare July 6, 2020 08:14
@miri64
Copy link
Member Author

miri64 commented Jul 6, 2020

Why Netif ? This seems confusing since it's a wrapper around ifconfig, same with NetifSend, it could just be Txtsnd ?

Mostly because the module is called like this. My idea was to name the classes like the module. I could name the methods like the shell command if you prefer (which I mostly already have done for netif_txtsnd()).

Okay, I decided to rename Netif* to Ifconfig* after all, since it would make sense to rename the parser IfconfigListParser if the method was name ifconfig_list() and then things get confusing when the classes are prefixed differently. The python module still bares the same name of the RIOT module, so that should be enough hint :-).

@miri64
Copy link
Member Author

miri64 commented Jul 6, 2020

@jia200x @benpicco: it would be great if you could provide example outputs of ifconfig for the respective modules you provided for testing:

* `gnrc_netif_lora_cmd` (@jia200x or maybe @leandrolanzieri)

* All those IEEE 802.15.4 extensions like `multimode`, `oqpsk`, `mr_oqpsk`, `mr_ofdm` (@benpicco)

I think, if possible, one example per bullet point would be enough.

LoRa output was provided by @leandrolanzieri offline.

@benpicco
Copy link
Contributor

benpicco commented Jul 6, 2020

(legacy) O-QPSK

2020-07-06 12:12:43,064 # Iface  7  HWaddr: 3A:A4  Channel: 26  Page: 0  NID: 0x23  PHY: O-QPSK 
2020-07-06 12:12:43,064 #           
2020-07-06 12:12:43,065 #           Long HWaddr: 22:68:31:23:59:F5:D2:38 
2020-07-06 12:12:43,066 #            TX-Power: 0dBm  State: IDLE  max. Retrans.: 3  CSMA Retries: 4 
2020-07-06 12:12:43,080 #           AUTOACK  ACK_REQ  CSMA  L2-PDU:102 MTU:1280  HL:64  RTR  
2020-07-06 12:12:43,081 #           6LO  IPHC  
2020-07-06 12:12:43,082 #           Source address length: 8
2020-07-06 12:12:43,082 #           Link type: wireless
2020-07-06 12:12:43,095 #           inet6 addr: fe80::2068:3123:59f5:d238  scope: link  VAL
2020-07-06 12:12:43,096 #           inet6 group: ff02::2
2020-07-06 12:12:43,097 #           inet6 group: ff02::1
2020-07-06 12:12:43,098 #           inet6 group: ff02::1:fff5:d238
2020-07-06 12:12:43,098 #           
2020-07-06 12:12:43,098 #           Statistics for Layer 2
2020-07-06 12:12:43,111 #             RX packets 0  bytes 0
2020-07-06 12:12:43,112 #             TX packets 2 (Multicast: 2)  bytes 86
2020-07-06 12:12:43,113 #             TX succeeded 2 errors 0
2020-07-06 12:12:43,113 #           Statistics for IPv6
2020-07-06 12:12:43,114 #             RX packets 0  bytes 0
2020-07-06 12:12:43,127 #             TX packets 2 (Multicast: 2)  bytes 128
2020-07-06 12:12:43,128 #             TX succeeded 2 errors 0

MR-O-QPSK

2020-07-06 12:13:34,996 #  ifconfig 7 set phy mr-o-qpsk
2020-07-06 12:13:34,997 # success: set PHY mode MR-O-QPSK
> ifconfig 7
2020-07-06 12:13:37,636 #  ifconfig 7
2020-07-06 12:13:37,653 # Iface  7  HWaddr: 3A:A4  Channel: 26  NID: 0x23  PHY: MR-O-QPSK 
2020-07-06 12:13:37,654 #            chip rate: 2000  rate mode: 0 
2020-07-06 12:13:37,655 #           Long HWaddr: 22:68:31:23:59:F5:D2:38 
2020-07-06 12:13:37,669 #            TX-Power: 0dBm  State: IDLE  max. Retrans.: 3  CSMA Retries: 4 
2020-07-06 12:13:37,671 #           AUTOACK  ACK_REQ  CSMA  L2-PDU:2022 MTU:1280  HL:64  RTR  
2020-07-06 12:13:37,671 #           6LO  IPHC  
2020-07-06 12:13:37,672 #           Source address length: 8
2020-07-06 12:13:37,684 #           Link type: wireless
2020-07-06 12:13:37,686 #           inet6 addr: fe80::2068:3123:59f5:d238  scope: link  VAL
2020-07-06 12:13:37,686 #           inet6 group: ff02::2
2020-07-06 12:13:37,687 #           inet6 group: ff02::1
2020-07-06 12:13:37,688 #           inet6 group: ff02::1:fff5:d238
2020-07-06 12:13:37,700 #           
2020-07-06 12:13:37,701 #           Statistics for Layer 2
2020-07-06 12:13:37,702 #             RX packets 1  bytes 43
2020-07-06 12:13:37,703 #             TX packets 6 (Multicast: 6)  bytes 258
2020-07-06 12:13:37,704 #             TX succeeded 6 errors 0
2020-07-06 12:13:37,716 #           Statistics for IPv6
2020-07-06 12:13:37,717 #             RX packets 1  bytes 64
2020-07-06 12:13:37,718 #             TX packets 6 (Multicast: 6)  bytes 384
2020-07-06 12:13:37,719 #             TX succeeded 6 errors 0

MR-OFDM

2020-07-06 12:14:22,098 #  ifconfig 7 set phy mr-ofdm
2020-07-06 12:14:22,099 # success: set PHY mode MR-OFDM
> ifconfig 7
2020-07-06 12:14:28,836 # Iface  7  HWaddr: 3A:A4  Channel: 26  NID: 0x23  PHY: MR-OFDM 
2020-07-06 12:14:28,837 #            Option: 1  MCS: 0 (BPSK, rate 1/2, 4x frequency repetition) 
2020-07-06 12:14:28,849 #           Long HWaddr: 22:68:31:23:59:F5:D2:38 
2020-07-06 12:14:28,851 #            TX-Power: 0dBm  State: IDLE  max. Retrans.: 3  CSMA Retries: 4 
2020-07-06 12:14:28,852 #           AUTOACK  ACK_REQ  CSMA  L2-PDU:2022 MTU:1280  HL:64  RTR  
2020-07-06 12:14:28,852 #           6LO  IPHC  
2020-07-06 12:14:28,866 #           Source address length: 8
2020-07-06 12:14:28,866 #           Link type: wireless
2020-07-06 12:14:28,867 #           inet6 addr: fe80::2068:3123:59f5:d238  scope: link  VAL
2020-07-06 12:14:28,868 #           inet6 group: ff02::2
2020-07-06 12:14:28,881 #           inet6 group: ff02::1
2020-07-06 12:14:28,882 #           inet6 group: ff02::1:fff5:d238
2020-07-06 12:14:28,883 #           
2020-07-06 12:14:28,884 #           Statistics for Layer 2
2020-07-06 12:14:28,885 #             RX packets 1  bytes 43
2020-07-06 12:14:28,886 #             TX packets 7 (Multicast: 7)  bytes 301
2020-07-06 12:14:28,897 #             TX succeeded 7 errors 0
2020-07-06 12:14:28,898 #           Statistics for IPv6
2020-07-06 12:14:28,899 #             RX packets 1  bytes 64
2020-07-06 12:14:28,900 #             TX packets 7 (Multicast: 7)  bytes 448
2020-07-06 12:14:28,900 #             TX succeeded 7 errors 0
2020-07-06 12:14:28,900 # 

MR-FSK

(WIP branch)

2020-07-06 12:14:54,304 #  ifconfig 7 set phy mr-fsk
2020-07-06 12:14:54,305 # success: set PHY mode MR-FSK
> ifconfig 7
2020-07-06 12:14:57,104 #  ifconfig 7
2020-07-06 12:14:57,105 # Iface  7  HWaddr: 3A:A4  Channel: 26  NID: 0x23  PHY: MR-FSK 
2020-07-06 12:14:57,106 #            modulation index: 1  2-FSK  symbol rate: 50 kHz  FEC: none  BW: 400kHz 
2020-07-06 12:14:57,120 #           Long HWaddr: 22:68:31:23:59:F5:D2:38 
2020-07-06 12:14:57,121 #            TX-Power: 0dBm  State: IDLE  max. Retrans.: 3  CSMA Retries: 4 
2020-07-06 12:14:57,123 #           AUTOACK  ACK_REQ  CSMA  L2-PDU:2022 MTU:1280  HL:64  RTR  
2020-07-06 12:14:57,136 #           6LO  IPHC  
2020-07-06 12:14:57,136 #           Source address length: 8
2020-07-06 12:14:57,137 #           Link type: wireless
2020-07-06 12:14:57,138 #           inet6 addr: fe80::2068:3123:59f5:d238  scope: link  VAL
2020-07-06 12:14:57,139 #           inet6 group: ff02::2
2020-07-06 12:14:57,152 #           inet6 group: ff02::1
2020-07-06 12:14:57,153 #           inet6 group: ff02::1:fff5:d238
2020-07-06 12:14:57,153 #           
2020-07-06 12:14:57,154 #           Statistics for Layer 2
2020-07-06 12:14:57,155 #             RX packets 1  bytes 43
2020-07-06 12:14:57,168 #             TX packets 8 (Multicast: 8)  bytes 344
2020-07-06 12:14:57,168 #             TX succeeded 8 errors 0
2020-07-06 12:14:57,169 #           Statistics for IPv6
2020-07-06 12:14:57,170 #             RX packets 1  bytes 64
2020-07-06 12:14:57,171 #             TX packets 8 (Multicast: 8)  bytes 512
2020-07-06 12:14:57,184 #             TX succeeded 8 errors 0

@miri64
Copy link
Member Author

miri64 commented Jul 6, 2020

@benpicco Thanks!

@miri64
Copy link
Member Author

miri64 commented Jul 6, 2020

Added @benpicco's examples, moved examples to their own test suite, applied fixes according to new tests

@miri64 miri64 force-pushed the riotctrl_shell/feat/netif branch from d489f17 to fb2c101 Compare July 6, 2020 13:55
@miri64
Copy link
Member Author

miri64 commented Jul 6, 2020

Rebased to current master to include GitHub actions for tool testing:

git range-diff upstream/master origin/riotctrl_shell/feat/netif riotctrl_shell/feat/netif 
 1:  cabc548d38 =  1:  7f170a5e1a sc_gnrc_netif: fix whitespaces in output
 2:  c7870adcf8 =  2:  a91c9f3e9c riotctrl_shell: provide netif interactions and parsers
 3:  2f70739bc7 =  3:  94db78b2af riotctrl_shell: activate doctests for pytest
 4:  a95c04d7be =  4:  27da24e827 fixup! riotctrl_shell: provide netif interactions and parsers
 5:  8460450953 =  5:  736ac92bf5 fixup! riotctrl_shell: provide netif interactions and parsers
 6:  1664f129f9 =  6:  0e788a23e3 fixup! sc_gnrc_netif: fix whitespaces in output
 7:  d4bacd4985 =  7:  96f5cbaf21 fixup! riotctrl_shell: provide netif interactions and parsers
 8:  55e3eb3b8d =  8:  a5978a4658 fixup! riotctrl_shell: provide netif interactions and parsers
 9:  f2650c8889 =  9:  726512f0b8 fixup! riotctrl_shell: provide netif interactions and parsers
10:  edb5c0ac04 = 10:  9890f7e1c9 fixup! riotctrl_shell: provide netif interactions and parsers
11:  263c5dc8f7 = 11:  f6791b2bdd fixup! riotctrl_shell: provide netif interactions and parsers
12:  f0927d4b28 = 12:  741c7cf0f3 fixup! riotctrl_shell: provide netif interactions and parsers
13:  d3a655d4fe = 13:  8555e6e5c2 fixup! riotctrl_shell: provide netif interactions and parsers
14:  d489f179c0 = 14:  fb2c1011e9 fixup! riotctrl_shell: provide netif interactions and parsers

@aabadie aabadie self-assigned this Jul 7, 2020
Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, please squash !

ACK

Originally, the options and flags in the `netif` shell output were
separated by two spaces. For later added flags this is not the case,
making the parsing of those flags and options hard to impossible.

This change adds those missing spaces + comments so it might not happen
again in the future.
@miri64
Copy link
Member Author

miri64 commented Jul 7, 2020

Squashed

@miri64 miri64 force-pushed the riotctrl_shell/feat/netif branch from b947bab to f8d23b4 Compare July 7, 2020 10:25
@miri64
Copy link
Member Author

miri64 commented Jul 7, 2020

None of the failing tests check the ifconfig output, so we should be fine:

    failed:
    tests/netdev_test/nrf52dk:gnu
    examples/micropython/nrf52dk:gnu
    tests/pkg_libfixmath/nrf52dk:llvm
    tests/evtimer_msg/nrf52dk:llvm
    tests/pkg_cayenne-lpp/nrf52dk:llvm
    tests/pkg_cifra/nrf52dk:llvm

@miri64 miri64 added CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: run tests If set, CI server will run tests on hardware for the labeled PR CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jul 7, 2020
@aabadie aabadie merged commit db5070c into RIOT-OS:master Jul 7, 2020
@miri64
Copy link
Member Author

miri64 commented Jul 7, 2020

Thanks for the review @aabadie!

@miri64 miri64 deleted the riotctrl_shell/feat/netif branch July 7, 2020 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants