Commit 6e410658 authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

test/nvmf: Make sure pci_net_devs[@] holds actual net devices



Since there's no global nullglob around, the pci_net_devs[@] may
end up consisting of a single item including the entire sysfs/*
path in case the net class is empty.

Avoid that by proper expansion. Ideally, nullglob should be around
globally, but this will be adressed in a separate refactor patch.

Change-Id: I257ebd361d3929c4f6ede8ffa61ca52ac1d4d520
Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19549


Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent e87490cf
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -371,16 +371,18 @@ function gather_supported_nvmf_pci_devs() {

	# All devices detected, kernel modules loaded. Now look under net class to see if there
	# are any net devices bound to the controllers.
	shopt -s nullglob
	for pci in "${pci_devs[@]}"; do
		if [[ ! -e /sys/bus/pci/devices/$pci/net ]]; then
		pci_net_devs=("/sys/bus/pci/devices/$pci/net/"*)
		if ((${#pci_net_devs[@]} == 0)); then
			echo "No net devices associated with $pci"
			continue
		fi
		pci_net_devs=("/sys/bus/pci/devices/$pci/net/"*)
		pci_net_devs=("${pci_net_devs[@]##*/}")
		echo "Found net devices under $pci: ${pci_net_devs[*]}"
		net_devs+=("${pci_net_devs[@]}")
	done
	shopt -u nullglob

	if ((${#net_devs[@]} == 0)); then
		return 1