test: Shellcheck - correct rule: loops over find output are fragile

Correct shellcheck rule SC2044: For loops over find output
are fragile. Use find -exec or a while read loop.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: I3fd84ab60daab7c6971769ff4dee8a24d5d3e1bb
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470746
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Maciej Wawryk 2019-10-08 12:22:47 +02:00 committed by Jim Harris
parent 644fc12061
commit f1131f1d19
3 changed files with 7 additions and 5 deletions

View File

@ -79,7 +79,8 @@ if [ $(uname -s) = Linux ]; then
# discover if it is OCSSD or not so load the kernel driver first.
for dev in $(find /dev -maxdepth 1 -regex '/dev/nvme[0-9]+'); do
while IFS= read -r -d '' dev
do
# Send Open Channel 2.0 Geometry opcode "0xe2" - not supported by NVMe device.
if nvme admin-passthru $dev --namespace-id=1 --data-len=4096 --opcode=0xe2 --read >/dev/null; then
bdf="$(basename $(readlink -e /sys/class/nvme/${dev#/dev/}/device))"
@ -87,7 +88,7 @@ if [ $(uname -s) = Linux ]; then
PCI_BLACKLIST+=" $bdf"
OCSSD_PCI_DEVICES+=" $bdf"
fi
done
done < <(find /dev -maxdepth 1 -regex '/dev/nvme[0-9]+' -print0)
export OCSSD_PCI_DEVICES

View File

@ -243,7 +243,7 @@ if hash shellcheck 2>/dev/null; then
SHCK_EXCLUDE="SC1001,SC1003,\
SC1083,SC1113,SC2001,SC2002,SC2003,SC2004,SC2005,\
SC2010,SC2012,SC2013,SC2016,\
SC2034,SC2044,SC2045,SC2046,\
SC2034,SC2045,SC2046,\
SC2068,SC2086,SC2089,SC2090,\
SC2097,SC2098,SC2103,SC2115,SC2116,SC2119,SC2120,SC2121,SC2124,SC2126,SC2128,\
SC2129,SC2140,SC2142,SC2143,SC2145,SC2146,SC2148,SC2152,SC2153,SC2154,SC2155,\

View File

@ -312,7 +312,8 @@ function report_test_completion() {
function process_core() {
ret=0
for core in $(find . -type f \( -name 'core\.?[0-9]*' -o -name '*.core' \)); do
while IFS= read -r -d '' core;
do
exe=$(eu-readelf -n "$core" | grep psargs | sed "s/.*psargs: \([^ \'\" ]*\).*/\1/")
if [[ ! -f "$exe" ]]; then
exe=$(eu-readelf -n "$core" | grep -oP -m1 "$exe.+")
@ -327,7 +328,7 @@ function process_core() {
mv $core $output_dir
chmod a+r $output_dir/$core
ret=1
done
done < <(find . -type f \( -name 'core\.?[0-9]*' -o -name '*.core' \) -print0)
return $ret
}