Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: forwarding: Remove duplicated lib.sh content

commit 25ae948b4478 ("selftests/net: add lib.sh") added net/lib.sh to
contain code shared by tests under net/ and net/forwarding/. However, this
caused issues with selftests from directories other than net/forwarding/,
in particular those under drivers/net/. Those issues were avoided in a
simple way by duplicating some content in commit 2114e83381d3 ("selftests:
forwarding: Avoid failures to source net/lib.sh").

In order to remove the duplicated content, restore the inclusion of
net/lib.sh from net/forwarding/lib.sh but with the following changes:

* net/lib.sh is imported through the net_forwarding_dir path
The original expression "source ../lib.sh" would look for lib.sh in the
directory above the script file's one, which did not work for tests under
drivers/net/.

* net/lib.sh is added to TEST_INCLUDES
Since net/forwarding/lib.sh now sources net/lib.sh, both of those files
must be exported along with tests which source net/forwarding/lib.sh.

Suggested-by: Hangbin Liu <liuhangbin@gmail.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Petr Machata and committed by
David S. Miller
521ed1ce 9f2af915

+10 -28
+2 -1
tools/testing/selftests/drivers/net/bonding/Makefile
··· 18 18 bond_topo_3d1c.sh 19 19 20 20 TEST_INCLUDES := \ 21 - ../../../net/forwarding/lib.sh 21 + ../../../net/forwarding/lib.sh \ 22 + ../../../net/lib.sh 22 23 23 24 include ../../../lib.mk
+2 -1
tools/testing/selftests/drivers/net/dsa/Makefile
··· 26 26 ../../../net/forwarding/local_termination.sh \ 27 27 ../../../net/forwarding/no_forwarding.sh \ 28 28 ../../../net/forwarding/tc_actions.sh \ 29 - ../../../net/forwarding/tc_common.sh 29 + ../../../net/forwarding/tc_common.sh \ 30 + ../../../net/lib.sh 30 31 31 32 include ../../../lib.mk
+2 -1
tools/testing/selftests/drivers/net/team/Makefile
··· 5 5 6 6 TEST_INCLUDES := \ 7 7 ../bonding/lag_lib.sh \ 8 - ../../../net/forwarding/lib.sh 8 + ../../../net/forwarding/lib.sh \ 9 + ../../../net/lib.sh 9 10 10 11 include ../../../lib.mk
+3
tools/testing/selftests/net/forwarding/Makefile
··· 129 129 sch_tbf_etsprio.sh \ 130 130 tc_common.sh 131 131 132 + TEST_INCLUDES := \ 133 + ../lib.sh 134 + 132 135 include ../../lib.mk
+1 -25
tools/testing/selftests/net/forwarding/lib.sh
··· 35 35 source "$net_forwarding_dir/forwarding.config" 36 36 fi 37 37 38 - # Kselftest framework requirement - SKIP code is 4. 39 - ksft_skip=4 40 - 41 - busywait() 42 - { 43 - local timeout=$1; shift 44 - 45 - local start_time="$(date -u +%s%3N)" 46 - while true 47 - do 48 - local out 49 - out=$("$@") 50 - local ret=$? 51 - if ((!ret)); then 52 - echo -n "$out" 53 - return 0 54 - fi 55 - 56 - local current_time="$(date -u +%s%3N)" 57 - if ((current_time - start_time > timeout)); then 58 - echo -n "$out" 59 - return 1 60 - fi 61 - done 62 - } 38 + source "$net_forwarding_dir/../lib.sh" 63 39 64 40 ############################################################################## 65 41 # Sanity checks