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

selftests: refactor get_netdev_name function

As pointed out by Michal Kubecek, getting the name
with the previous approach was racy, it's better
and easier to get the name of the device with this
patch's approach.

Essentialy the function doesn't need to exist
anymore as it's a simple 'ls' command.

Signed-off-by: Antonio Cardace <acardace@redhat.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Antonio Cardace and committed by
Jakub Kicinski
9e48ee80 fbb8531e

+2 -18
+2 -18
tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh
··· 20 20 21 21 trap cleanup EXIT 22 22 23 - function get_netdev_name { 24 - local -n old=$1 25 - 26 - new=$(ls /sys/class/net) 27 - 28 - for netdev in $new; do 29 - for check in $old; do 30 - [ $netdev == $check ] && break 31 - done 32 - 33 - if [ $netdev != $check ]; then 34 - echo $netdev 35 - break 36 - fi 37 - done 38 - } 39 - 40 23 function check { 41 24 local code=$1 42 25 local str=$2 ··· 48 65 fi 49 66 50 67 echo $NSIM_ID > /sys/bus/netdevsim/new_device 51 - echo `get_netdev_name old_netdevs` 68 + # get new device name 69 + ls /sys/bus/netdevsim/devices/netdevsim${NSIM_ID}/net/ 52 70 }