Skip to content

Commit 9d5f69e

Browse files
authored
Merge pull request linux-blktests#171 from bvanassche/master
Multiple minor improvements for common scripts
2 parents 401420a + bdf0297 commit 9d5f69e

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

common/fio

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ _run_fio() {
177177
args+=("--runtime=$TIMEOUT")
178178
fi
179179

180+
echo "fio ${args[*]} $*" >>"$FULL"
180181
fio "${args[@]}" "$@"
181182
local rc=$?
182183
if [ $rc != 0 ]; then
@@ -219,20 +220,23 @@ _run_fio_verify_io() {
219220
}
220221

221222
_fio_perf_report() {
222-
# If there is more than one group, we don't know what to report.
223-
if [[ $(wc -l < "$TMPDIR/fio_perf") -gt 1 ]]; then
224-
echo "_fio_perf: too many terse lines" >&2
225-
return
226-
fi
223+
local name field value_array
224+
{
225+
IFS=';' read -ra value_array
226+
227+
# If there is more than one group, we don't know what to report.
228+
if read -r; then
229+
echo "_fio_perf: too many terse lines" >&2
230+
return
231+
fi
232+
} <"$TMPDIR/fio_perf"
227233

228-
local name field value
229234
for name in "${FIO_PERF_FIELDS[@]}"; do
230235
field="${FIO_TERSE_FIELDS["$name"]}"
231236
if [[ -z $field ]]; then
232237
echo "_fio_perf: unknown fio terse field '$name'" >&2
233238
continue
234239
fi
235-
value="$(cut -d ';' -f "$field" "$TMPDIR/fio_perf")"
236-
TEST_RUN["$FIO_PERF_PREFIX$name"]="$value"
240+
TEST_RUN["$FIO_PERF_PREFIX$name"]=${value_array[$((field - 1))]}
237241
done
238242
}

common/null_blk

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,29 @@ _init_null_blk() {
4949

5050
# Configure one null_blk instance with name $1 and parameters $2..${$#}.
5151
_configure_null_blk() {
52-
local nullb=/sys/kernel/config/nullb/$1 param val
52+
local nullb_path=/sys/kernel/config/nullb/$1 params param
5353
shift
5454

5555
if [[ ! -d /sys/module/null_blk ]]; then
5656
modprobe -q null_blk
5757
fi
5858

59-
mkdir "$nullb" || return $?
59+
mkdir "$nullb_path" || return $?
6060

61+
params=()
6162
if (( RUN_FOR_ZONED )); then
62-
echo "1" > "$nullb/zoned" || return 1
63+
params+=(zoned=1)
6364
fi
65+
params+=("$@")
6466

65-
while [[ $# -gt 0 ]]; do
66-
param="${1%%=*}"
67-
val="${1#*=}"
68-
shift
69-
echo "$val" > "$nullb/$param" || return 1
67+
echo "$nullb_path ${params[*]}" >>"${FULL}"
68+
69+
for param in "${params[@]}"; do
70+
local key="${param%%=*}" val="${param#*=}"
71+
if ! echo "$val" > "$nullb_path/$key"; then
72+
echo "Writing $val into $nullb_path/$key failed"
73+
return 1
74+
fi
7075
done
7176
}
7277

common/rc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ _module_file_exists()
3737
local ko_underscore=${1//-/_}.ko
3838
local ko_hyphen=${1//_/-}.ko
3939
local libpath
40-
local -i count
4140

4241
libpath="/lib/modules/$(uname -r)/kernel"
4342
[[ ! -d $libpath ]] && return 1
44-
count=$(find "$libpath" -name "$ko_underscore*" -o \
45-
-name "$ko_hyphen*" | wc -l)
46-
((count)) && return 0
47-
return 1
43+
local module_path
44+
module_path="$(find "$libpath" -name "$ko_underscore*" -o \
45+
-name "$ko_hyphen*")"
46+
[ -n "${module_path}" ]
4847
}
4948

5049
# Check that the specified module or driver is available, regardless of whether

0 commit comments

Comments
 (0)