diff options
author | Antonio Cardace <acardace@redhat.com> | 2020-11-18 21:45:21 +0100 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2020-11-20 12:51:54 -0800 |
commit | 9e48ee80ac4e04c9985379d58248dd2a96a170ef (patch) | |
tree | 49b1250028d0732de49384d407f9b562080ed496 | |
parent | fbb8531e58bd989868db3c2513d06870c46bd87f (diff) |
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>
-rw-r--r-- | tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh b/tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh index fa44cf6e732c..9f64d5c7107b 100644 --- a/tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh +++ b/tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh @@ -20,23 +20,6 @@ function cleanup { trap cleanup EXIT -function get_netdev_name { - local -n old=$1 - - new=$(ls /sys/class/net) - - for netdev in $new; do - for check in $old; do - [ $netdev == $check ] && break - done - - if [ $netdev != $check ]; then - echo $netdev - break - fi - done -} - function check { local code=$1 local str=$2 @@ -65,5 +48,6 @@ function make_netdev { fi echo $NSIM_ID > /sys/bus/netdevsim/new_device - echo `get_netdev_name old_netdevs` + # get new device name + ls /sys/bus/netdevsim/devices/netdevsim${NSIM_ID}/net/ } |