This patch set aims to add the necessary support so that bash written selftests are also able to easily run with a remote traffic generator system, either be it in another netns or one accessible through ssh.
This patch set is a result of the discussion from v1: https://lore.kernel.org/all/[email protected]/ Even though the python infrastructure is already established, some things are easier in bash and it would be a shame to leave behind the bash tests that we already have. Version 1 of this patch set also had patches exporting standard statistics in the dpaa2 drivers. Those patches will be submitted separately so that they do not depend on this set. This support is based on the requirements described in the tools/testing/selftests/drivers/net/README.rst file. Mainly, the drivers/net selftests should be able to run on a interface specified through the NETIF env variable. On top of that, variables such as REMOTE_TYPE and REMOTE_ARGS define how the remote traffic generator can be accessed. Patch 2/9 parses these env variables and constructs the NETIFS array that bash tests are accustomed to. This is with the intention of enabling already written tests to incur minimal changes. The second patch also defines the TARGETS array which will hold the necessary information about the target on which a specific interface is located. For example, a net.config which looks like below: NETIF=eth0 LOCAL_V4=192.168.1.1 REMOTE_V4=192.168.1.2 REMOTE_TYPE=ssh [email protected] will generate the NETIFS and TARGETS arrays with the following data. NETIFS[p1]="eth0" NETIFS[p2]="eth2" TARGETS[eth0]="local:" TARGETS[eth2]="ssh:[email protected]" The above will be true if on the remote target, the interface which has the 192.168.1.2 address is named eth2. The values held in the TARGETS array will be used by the new 'run_on' helper added in patch 3/9 to know how to run a specific command, on the local system, on another netns or by using ssh. Patch 4/9 updates some helpers to use run_on so that, for example, lib.sh is able to ensure stable MAC addresses even with the remote interface located in another netns. The next 4 patches, 4/9-8/9 update the ethtool_rmon.sh script so that it can work with the kselftest infrastructure and the new NETIF/REMOTE_TYPE etc way of working. Beside updating each ip link or ethtool command to use the run_on helper, the patches also remove any testing done on the remote interface. The last patch adds a new test which checks the standard counters - eth-ctrl, eth-mac and pause - and uses the new infrastructure put in place by the first patches. With this patch set, both tests can be run using a net.config file and run_kselftest.sh as shown below. $ make -C tools/testing/selftests/ TARGETS="drivers/net drivers/net/hw" \ install INSTALL_PATH=/tmp/ksft-net-drv $ cd /tmp/ksft-net-drv/ $ cat > ./drivers/net/net.config <<EOF NETIF=endpmac17 LOCAL_V4=17.0.0.1 REMOTE_V4=17.0.0.2 REMOTE_TYPE=ssh [email protected] EOF $ ./run_kselftest.sh -t drivers/net/hw:ethtool_rmon.sh TAP version 13 1..1 # timeout set to 0 # selftests: drivers/net/hw: ethtool_rmon.sh # TEST: rx-pkts64to64 on endpmac17 [ OK ] # TEST: rx-pkts65to127 on endpmac17 [ OK ] # TEST: rx-pkts128to255 on endpmac17 [ OK ] # TEST: rx-pkts256to511 on endpmac17 [ OK ] # TEST: rx-pkts512to1023 on endpmac17 [ OK ] # TEST: rx-pkts1024to1518 on endpmac17 [ OK ] # TEST: rx-pkts1519to10240 on endpmac17 [ OK ] # TEST: tx-pkts64to64 on endpmac17 [ OK ] # TEST: tx-pkts65to127 on endpmac17 [ OK ] # TEST: tx-pkts128to255 on endpmac17 [ OK ] # TEST: tx-pkts256to511 on endpmac17 [ OK ] # TEST: tx-pkts512to1023 on endpmac17 [ OK ] # TEST: tx-pkts1024to1518 on endpmac17 [ OK ] # TEST: tx-pkts1519to10240 on endpmac17 [ OK ] ok 1 selftests: drivers/net/hw: ethtool_rmon.sh $ ./run_kselftest.sh -t drivers/net/hw:ethtool_std_stats.sh TAP version 13 1..1 # timeout set to 0 # selftests: drivers/net/hw: ethtool_std_stats.sh # TEST: eth-ctrl-MACControlFramesTransmitted on endpmac17 [ OK ] # TEST: eth-ctrl-MACControlFramesReceived on endpmac17 [ OK ] # TEST: eth-mac-FrameCheckSequenceErrors on endpmac17 [ OK ] # TEST: eth-mac-AlignmentErrors on endpmac17 [ OK ] # TEST: eth-mac-FramesLostDueToIntMACXmitError on endpmac17 [ OK ] # TEST: eth-mac-CarrierSenseErrors on endpmac17 (not supported) [SKIP] # TEST: eth-mac-FramesLostDueToIntMACRcvError on endpmac17 [ OK ] # TEST: eth-mac-InRangeLengthErrors on endpmac17 (not supported) [SKIP] # TEST: eth-mac-OutOfRangeLengthField on endpmac17 (not supported) [SKIP] # TEST: eth-mac-FrameTooLongErrors on endpmac17 (not supported) [SKIP] # TEST: eth-mac-FramesAbortedDueToXSColls on endpmac17 (not supported) [SKIP] # TEST: eth-mac-SingleCollisionFrames on endpmac17 (not supported) [SKIP] # TEST: eth-mac-MultipleCollisionFrames on endpmac17 (not supported) [SKIP] # TEST: eth-mac-FramesWithDeferredXmissions on endpmac17 (not supported) [SKIP] # TEST: eth-mac-LateCollisions on endpmac17 (not supported) [SKIP] # TEST: eth-mac-FramesWithExcessiveDeferral on endpmac17 (not supported) [SKIP] # TEST: eth-mac-BroadcastFramesXmittedOK on endpmac17 [ OK ] # TEST: eth-mac-OctetsTransmittedOK on endpmac17 [ OK ] # TEST: eth-mac-BroadcastFramesReceivedOK on endpmac17 [ OK ] # TEST: eth-mac-OctetsReceivedOK on endpmac17 [ OK ] # TEST: eth-mac-FramesTransmittedOK on endpmac17 [ OK ] # TEST: eth-mac-MulticastFramesXmittedOK on endpmac17 [ OK ] # TEST: eth-mac-FramesReceivedOK on endpmac17 [ OK ] # TEST: eth-mac-MulticastFramesReceivedOK on endpmac17 [ OK ] # TEST: pause-tx_pause_frames on endpmac17 [ OK ] # TEST: pause-rx_pause_frames on endpmac17 [ OK ] ok 1 selftests: drivers/net/hw: ethtool_std_stats.sh # SKIP Changes in v2: - 1/9: Convert jq to the --arg usage form - Patches 2/9-8/9 are new in this version - 9/9: Use the new run_on helper - 9/9: No longer checking that each counter has a 1% tolerance against the target. The only upper limit is UINT32_MAX. - 9/9: Check that both the error counters and the collision related ones are zero since this is the most probable scenario (we don't expect errors with the traffic that we are sending). - 9/9: Removed any checks performed on the remot interface counters since that is being used only as a traffic generator. Ioana Ciornei (9): selftests: forwarding: extend ethtool_std_stats_get with pause statistics selftests: net: extend lib.sh to parse drivers/net/net.config selftests: net: add helpers for running a command on other targets selftests: net: update some helpers to use run_on selftests: drivers: hw: cleanup shellcheck warnings in the rmon test selftests: drivers: hw: test rmon counters only on first interface selftests: drivers: hw: replace counter upper limit with UINT32_MAX in rmon test selftests: drivers: hw: update ethtool_rmon to work with a single local interface selftests: drivers: hw: add test for the ethtool standard counters .../testing/selftests/drivers/net/README.rst | 3 + .../testing/selftests/drivers/net/hw/Makefile | 1 + .../selftests/drivers/net/hw/ethtool_rmon.sh | 55 +++--- .../drivers/net/hw/ethtool_std_stats.sh | 187 ++++++++++++++++++ tools/testing/selftests/net/forwarding/lib.sh | 138 +++++++++++-- tools/testing/selftests/net/lib.sh | 39 +++- 6 files changed, 379 insertions(+), 44 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/hw/ethtool_std_stats.sh -- 2.25.1

