brintos

brintos / linux-shallow public Read only

0
0
Text · 4.0 KiB · 3b6a29e Raw
137 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3Running driver tests4====================5 6Networking driver tests are executed within kselftest framework like any7other tests. They support testing both real device drivers and emulated /8software drivers (latter mostly to test the core parts of the stack).9 10SW mode11~~~~~~~12 13By default, when no extra parameters are set or exported, tests execute14against software drivers such as netdevsim. No extra preparation is required15the software devices are created and destroyed as part of the test.16In this mode the tests are indistinguishable from other selftests and17(for example) can be run under ``virtme-ng`` like the core networking selftests.18 19HW mode20~~~~~~~21 22Executing tests against a real device requires external preparation.23The netdevice against which tests will be run must exist, be running24(in UP state) and be configured with an IP address.25 26Refer to list of :ref:`Variables` later in this file to set up running27the tests against a real device.28 29Both modes required30~~~~~~~~~~~~~~~~~~~31 32All tests in drivers/net must support running both against a software device33and a real device. SW-only tests should instead be placed in net/ or34drivers/net/netdevsim, HW-only tests in drivers/net/hw.35 36Variables37=========38 39The variables can be set in the environment or by creating a net.config40file in the same directory as this README file. Example::41 42  $ NETIF=eth0 ./some_test.sh43 44or::45 46  $ cat tools/testing/selftests/drivers/net/net.config47  # Variable set in a file48  NETIF=eth049 50Local test (which don't require endpoint for sending / receiving traffic)51need only the ``NETIF`` variable. Remaining variables define the endpoint52and communication method.53 54NETIF55~~~~~56 57Name of the netdevice against which the test should be executed.58When empty or not set software devices will be used.59 60LOCAL_V4, LOCAL_V6, REMOTE_V4, REMOTE_V661~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~62 63Local and remote endpoint IP addresses.64 65REMOTE_TYPE66~~~~~~~~~~~67 68Communication method used to run commands on the remote endpoint.69Test framework has built-in support for ``netns`` and ``ssh`` channels.70``netns`` assumes the "remote" interface is part of the same71host, just moved to the specified netns.72``ssh`` communicates with remote endpoint over ``ssh`` and ``scp``.73Using persistent SSH connections is strongly encouraged to avoid74the latency of SSH connection setup on every command.75 76Communication methods are defined by classes in ``lib/py/remote_{name}.py``.77It should be possible to add a new method without modifying any of78the framework, by simply adding an appropriately named file to ``lib/py``.79 80REMOTE_ARGS81~~~~~~~~~~~82 83Arguments used to construct the communication channel.84Communication channel dependent::85 86  for netns - name of the "remote" namespace87  for ssh - name/address of the remote host88 89Example90=======91 92Build the selftests::93 94  # make -C tools/testing/selftests/ TARGETS="drivers/net drivers/net/hw"95 96"Install" the tests and copy them over to the target machine::97 98  # make -C tools/testing/selftests/ TARGETS="drivers/net drivers/net/hw" \99     install INSTALL_PATH=/tmp/ksft-net-drv100 101  # rsync -ra --delete /tmp/ksft-net-drv root@192.168.1.1:/root/102 103On the target machine, running the tests will use netdevsim by default::104 105  [/root] # ./ksft-net-drv/run_kselftest.sh -t drivers/net:ping.py106  TAP version 13107  1..1108  # timeout set to 45109  # selftests: drivers/net: ping.py110  # KTAP version 1111  # 1..3112  # ok 1 ping.test_v4113  # ok 2 ping.test_v6114  # ok 3 ping.test_tcp115  # # Totals: pass:3 fail:0 xfail:0 xpass:0 skip:0 error:0116  ok 1 selftests: drivers/net: ping.py117 118Create a config with remote info::119 120  [/root] # cat > ./ksft-net-drv/drivers/net/net.config <<EOF121  NETIF=eth0122  LOCAL_V4=192.168.1.1123  REMOTE_V4=192.168.1.2124  REMOTE_TYPE=ssh125  REMOTE_ARGS=root@192.168.1.2126  EOF127 128Run the test::129 130  [/root] # ./ksft-net-drv/drivers/net/ping.py131  KTAP version 1132  1..3133  ok 1 ping.test_v4134  ok 2 ping.test_v6 # SKIP Test requires IPv6 connectivity135  ok 3 ping.test_tcp136  # Totals: pass:2 fail:0 xfail:0 xpass:0 skip:1 error:0137