ZTS: Simplify some libtest functions
Don't echo the results of arithmetic expressions, it's not necessary. Use hw.clockrate sysctl to get CPU freq instead of parsing dmesg.boot for a line that might not even be there anymore. Reduce bookkeeping in fill_fs, making it easier to follow. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: John Kennedy <john.kennedy@delphix.com> Signed-off-by: Ryan Moeller <ryan@iXsystems.com> Closes #10113
This commit is contained in:
parent
5ecbb293c6
commit
9be70c3784
|
@ -1175,7 +1175,7 @@ function partition_disk #<slice_size> <whole_disk_name> <total_slices>
|
||||||
# data: the data that will be written
|
# data: the data that will be written
|
||||||
#
|
#
|
||||||
# E.g.
|
# E.g.
|
||||||
# file_fs /testdir 20 25 1024 256 0
|
# fill_fs /testdir 20 25 1024 256 0
|
||||||
#
|
#
|
||||||
# Note: bytes * num_writes equals the size of the testfile
|
# Note: bytes * num_writes equals the size of the testfile
|
||||||
#
|
#
|
||||||
|
@ -1188,33 +1188,12 @@ function fill_fs # destdir dirnum filenum bytes num_writes data
|
||||||
typeset -i num_writes=${5:-10240}
|
typeset -i num_writes=${5:-10240}
|
||||||
typeset data=${6:-0}
|
typeset data=${6:-0}
|
||||||
|
|
||||||
typeset -i odirnum=1
|
mkdir -p $destdir/{1..$dirnum}
|
||||||
typeset -i idirnum=0
|
for f in $destdir/{1..$dirnum}/$TESTFILE{1..$filenum}; do
|
||||||
typeset -i fn=0
|
file_write -o create -f $f -b $bytes -c $num_writes -d $data \
|
||||||
typeset -i retval=0
|
|| return $?
|
||||||
|
|
||||||
mkdir -p $destdir/$idirnum
|
|
||||||
while (($odirnum > 0)); do
|
|
||||||
if ((dirnum >= 0 && idirnum >= dirnum)); then
|
|
||||||
odirnum=0
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
file_write -o create -f $destdir/$idirnum/$TESTFILE.$fn \
|
|
||||||
-b $bytes -c $num_writes -d $data
|
|
||||||
retval=$?
|
|
||||||
if (($retval != 0)); then
|
|
||||||
odirnum=0
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
if (($fn >= $filenum)); then
|
|
||||||
fn=0
|
|
||||||
((idirnum = idirnum + 1))
|
|
||||||
mkdir -p $destdir/$idirnum
|
|
||||||
else
|
|
||||||
((fn = fn + 1))
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
return $retval
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -3302,7 +3281,7 @@ function get_cpu_freq
|
||||||
if is_linux; then
|
if is_linux; then
|
||||||
lscpu | awk '/CPU MHz/ { print $3 }'
|
lscpu | awk '/CPU MHz/ { print $3 }'
|
||||||
elif is_freebsd; then
|
elif is_freebsd; then
|
||||||
cat /var/run/dmesg.boot | grep '^CPU:' | cut -d '(' -f 2 | cut -d ')' -f 1
|
sysctl -n hw.clockrate
|
||||||
else
|
else
|
||||||
psrinfo -v 0 | awk '/processor operates at/ {print $6}'
|
psrinfo -v 0 | awk '/processor operates at/ {print $6}'
|
||||||
fi
|
fi
|
||||||
|
@ -3360,7 +3339,7 @@ function get_max
|
||||||
shift
|
shift
|
||||||
|
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
max=$(echo $((max > i ? max : i)))
|
max=$((max > i ? max : i))
|
||||||
done
|
done
|
||||||
|
|
||||||
echo $max
|
echo $max
|
||||||
|
@ -3372,7 +3351,7 @@ function get_min
|
||||||
shift
|
shift
|
||||||
|
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
min=$(echo $((min < i ? min : i)))
|
min=$((min < i ? min : i))
|
||||||
done
|
done
|
||||||
|
|
||||||
echo $min
|
echo $min
|
||||||
|
|
Loading…
Reference in New Issue