tests: clean out unused/single-use/useless commands from the list

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13259
This commit is contained in:
наб 2022-03-14 01:41:03 +01:00 committed by Brian Behlendorf
parent df6e0f0092
commit caccfc870f
13 changed files with 35 additions and 149 deletions

View File

@ -291,7 +291,7 @@ User: %s
self.result.starttime = monotonic_time() self.result.starttime = monotonic_time()
if kmemleak: if kmemleak:
cmd = f'echo clear | {SUDO} tee {KMEMLEAK_FILE}' cmd = f'{SUDO} sh -c "echo clear > {KMEMLEAK_FILE}"'
check_output(cmd, shell=True) check_output(cmd, shell=True)
proc = Popen(privcmd, stdout=PIPE, stderr=PIPE) proc = Popen(privcmd, stdout=PIPE, stderr=PIPE)
@ -305,7 +305,7 @@ User: %s
self.result.stdout, self.result.stderr = self.collect_output(proc) self.result.stdout, self.result.stderr = self.collect_output(proc)
if kmemleak: if kmemleak:
cmd = f'echo scan | {SUDO} tee {KMEMLEAK_FILE}' cmd = f'{SUDO} sh -c "echo scan > {KMEMLEAK_FILE}"'
check_output(cmd, shell=True) check_output(cmd, shell=True)
cmd = f'{SUDO} cat {KMEMLEAK_FILE}' cmd = f'{SUDO} cat {KMEMLEAK_FILE}'
self.result.kmemleak = check_output(cmd, shell=True) self.result.kmemleak = check_output(cmd, shell=True)
@ -880,7 +880,7 @@ class TestRun(object):
self.outputdir, LOG_ERR) self.outputdir, LOG_ERR)
if options.kmemleak: if options.kmemleak:
cmd = f'echo scan=0 | {SUDO} tee {KMEMLEAK_FILE}' cmd = f'{SUDO} -c "echo scan=0 > {KMEMLEAK_FILE}"'
check_output(cmd, shell=True) check_output(cmd, shell=True)
iteration = 0 iteration = 0

View File

@ -8,9 +8,7 @@
# Please keep the contents of each variable sorted for ease of reading # Please keep the contents of each variable sorted for ease of reading
# and maintenance. # and maintenance.
# #
export SYSTEM_FILES_COMMON='arp export SYSTEM_FILES_COMMON='awk
awk
base64
basename basename
bc bc
bunzip2 bunzip2
@ -52,10 +50,10 @@ export SYSTEM_FILES_COMMON='arp
ksh ksh
ldd ldd
ln ln
logname
ls ls
mkdir mkdir
mknod mknod
mkfifo
mktemp mktemp
mount mount
mv mv
@ -67,12 +65,9 @@ export SYSTEM_FILES_COMMON='arp
pgrep pgrep
ping ping
pkill pkill
printenv
printf printf
ps ps
pwd
python3 python3
quotaon
readlink readlink
rm rm
rmdir rmdir
@ -88,32 +83,26 @@ export SYSTEM_FILES_COMMON='arp
ssh ssh
stat stat
strings strings
su
sudo sudo
swapoff swapoff
swapon swapon
sync sync
tail tail
tar tar
tee
timeout timeout
touch touch
tr tr
true true
truncate truncate
umask
umount umount
uname uname
uniq uniq
uuidgen
vmstat vmstat
wait
wc' wc'
export SYSTEM_FILES_FREEBSD='chflags export SYSTEM_FILES_FREEBSD='chflags
compress compress
diskinfo diskinfo
dumpon
fsck fsck
getextattr getextattr
gpart gpart
@ -123,7 +112,6 @@ export SYSTEM_FILES_FREEBSD='chflags
lsextattr lsextattr
md5 md5
mdconfig mdconfig
mkfifo
newfs newfs
pw pw
rmextattr rmextattr
@ -135,14 +123,11 @@ export SYSTEM_FILES_FREEBSD='chflags
uncompress' uncompress'
export SYSTEM_FILES_LINUX='attr export SYSTEM_FILES_LINUX='attr
bash
blkid blkid
blockdev blockdev
chattr chattr
dmidecode
exportfs exportfs
fallocate fallocate
fdisk
free free
getfattr getfattr
groupadd groupadd
@ -159,16 +144,17 @@ export SYSTEM_FILES_LINUX='attr
mkswap mkswap
modprobe modprobe
mpstat mpstat
nproc
parted parted
perf perf
setenforce
setfattr setfattr
sha256sum sha256sum
udevadm udevadm
useradd useradd
userdel userdel
usermod' usermod
flock
logger'
export ZFS_FILES='zdb export ZFS_FILES='zdb
zfs zfs

View File

@ -2970,59 +2970,6 @@ function get_device_state #pool disk field("", "spares","logs")
($1==field || $1 ~ "^spares$" || $1 ~ "^logs$") {startfield=0}' ($1==field || $1 ~ "^spares$" || $1 ~ "^logs$") {startfield=0}'
} }
#
# Given a disk, label it to VTOC regardless what label was on the disk
# $1 disk
#
function labelvtoc
{
typeset disk=$1
if [[ -z $disk ]]; then
log_fail "The disk name is unspecified."
fi
typeset label_file=/var/tmp/labelvtoc.$$
typeset arch=$(uname -p)
if is_linux || is_freebsd; then
log_note "Currently unsupported by the test framework"
return 1
fi
if [[ $arch == "i386" ]]; then
echo "label" > $label_file
echo "0" >> $label_file
echo "" >> $label_file
echo "q" >> $label_file
echo "q" >> $label_file
fdisk -B $disk >/dev/null 2>&1
# wait a while for fdisk finishes
sleep 60
elif [[ $arch == "sparc" ]]; then
echo "label" > $label_file
echo "0" >> $label_file
echo "" >> $label_file
echo "" >> $label_file
echo "" >> $label_file
echo "q" >> $label_file
else
log_fail "unknown arch type"
fi
format -e -s -d $disk -f $label_file
typeset -i ret_val=$?
rm -f $label_file
#
# wait the format to finish
#
sleep 60
if ((ret_val != 0)); then
log_fail "unable to label $disk as VTOC."
fi
return 0
}
# #
# get the root filesystem name if it's zfsroot system. # get the root filesystem name if it's zfsroot system.
# #
@ -3077,22 +3024,19 @@ function verify_disk_count
function ds_is_volume function ds_is_volume
{ {
typeset type=$(get_prop type $1) typeset type=$(get_prop type $1)
[[ $type = "volume" ]] && return 0 [ $type = "volume" ]
return 1
} }
function ds_is_filesystem function ds_is_filesystem
{ {
typeset type=$(get_prop type $1) typeset type=$(get_prop type $1)
[[ $type = "filesystem" ]] && return 0 [ $type = "filesystem" ]
return 1
} }
function ds_is_snapshot function ds_is_snapshot
{ {
typeset type=$(get_prop type $1) typeset type=$(get_prop type $1)
[[ $type = "snapshot" ]] && return 0 [ $type = "snapshot" ]
return 1
} }
# #
@ -3108,7 +3052,7 @@ function is_mp
{ {
case $(uname) in case $(uname) in
Linux) Linux)
(($(nproc) > 1)) (($(grep -c '^processor' /proc/cpuinfo) > 1))
;; ;;
FreeBSD) FreeBSD)
sysctl -n kern.smp.cpus sysctl -n kern.smp.cpus

View File

@ -145,7 +145,6 @@ function histo_check_test_pool
typeset -i this_rs typeset -i this_rs
typeset -i this_ri typeset -i this_ri
typeset -i sum_filesizes=0 typeset -i sum_filesizes=0
typeset dumped
typeset stripped typeset stripped
let histo_check_pool_size=$(get_pool_prop size ${pool}) let histo_check_pool_size=$(get_pool_prop size ${pool})
@ -157,11 +156,9 @@ function histo_check_test_pool
log_fail "hctp: max_pool_record_size is not numeric ${max_pool_record_size}" log_fail "hctp: max_pool_record_size is not numeric ${max_pool_record_size}"
fi fi
dumped="${TEST_BASE_DIR}/${pool}_dump.txt"
stripped="${TEST_BASE_DIR}/${pool}_stripped.txt" stripped="${TEST_BASE_DIR}/${pool}_stripped.txt"
zdb -Pbbb ${pool} | \ zdb -Pbbb ${pool} | \
tee ${dumped} | \
sed -e '1,/^block[ ][ ]*psize[ ][ ]*lsize.*$/d' \ sed -e '1,/^block[ ][ ]*psize[ ][ ]*lsize.*$/d' \
-e '/^size[ ]*Count/d' -e '/^$/,$d' \ -e '/^size[ ]*Count/d' -e '/^$/,$d' \
> ${stripped} > ${stripped}

View File

@ -111,11 +111,7 @@ verify_object_class "$MNTPOINT/cdev" "C"
# 2. | (Named pipe) # 2. | (Named pipe)
log_must zfs snapshot "$TESTSNAP1" log_must zfs snapshot "$TESTSNAP1"
if is_freebsd; then log_must mkfifo "$MNTPOINT/fifo"
log_must mkfifo "$MNTPOINT/fifo"
else
log_must mknod "$MNTPOINT/fifo" p
fi
log_must zfs snapshot "$TESTSNAP2" log_must zfs snapshot "$TESTSNAP2"
verify_object_class "$MNTPOINT/fifo" "|" verify_object_class "$MNTPOINT/fifo" "|"

View File

@ -74,7 +74,7 @@ child_pools=""
function zpool_stress function zpool_stress
{ {
typeset pool=$1 typeset pool="$1-$$"
typeset vdev0="$TEST_BASE_DIR/$pool-vdev0.img" typeset vdev0="$TEST_BASE_DIR/$pool-vdev0.img"
typeset vdev1="$TEST_BASE_DIR/$pool-vdev1.img" typeset vdev1="$TEST_BASE_DIR/$pool-vdev1.img"
typeset -i iters=$2 typeset -i iters=$2
@ -118,13 +118,11 @@ function zpool_stress
# 1. Create 128 process each of which create/destroy a pool 5 times. # 1. Create 128 process each of which create/destroy a pool 5 times.
typeset i=0 typeset i=0
while [[ $i -lt 128 ]]; do while [[ $i -lt 128 ]]; do
typeset uuid=$(uuidgen | cut -c1-13) zpool_stress $TESTPOOL-$i 5 &
zpool_stress $TESTPOOL-$uuid 5 &
typeset pid=$! typeset pid=$!
child_pids="$child_pids $pid" child_pids="$child_pids $pid"
child_pools="$child_pools $TESTPOOL-$uuid" child_pools="$child_pools $TESTPOOL-$i-$pid"
((i = i + 1)) ((i = i + 1))
done done

View File

@ -44,22 +44,15 @@
# #
# #
# check to see if we have zfs allow
zfs 2>&1 | grep "allow" > /dev/null
if (($? != 0)) then
log_unsupported "ZFS allow not supported on this machine."
fi
log_assert "zfs allow returns an error when run as a user" log_assert "zfs allow returns an error when run as a user"
log_must zfs allow $TESTPOOL/$TESTFS log_must zfs allow $TESTPOOL/$TESTFS
log_mustnot zfs allow $(logname) create $TESTPOOL/$TESTFS log_mustnot zfs allow $(id -un) create $TESTPOOL/$TESTFS
# now verify that the above command actually did nothing by # now verify that the above command actually did nothing by
# checking for any allow output. ( if no allows are granted, # checking for any allow output. ( if no allows are granted,
# nothing should be output ) # nothing should be output )
OUTPUT=$(zfs allow $TESTPOOL/$TESTFS | grep "Local+Descendent" ) if zfs allow $TESTPOOL/$TESTFS | grep -q "Local+Descendent"
if [ -n "$OUTPUT" ]
then then
log_fail "zfs allow permissions were granted on $TESTPOOL/$TESTFS" log_fail "zfs allow permissions were granted on $TESTPOOL/$TESTFS"
fi fi

View File

@ -58,7 +58,7 @@ BATCH=1000
log_must mkdir $TESTDIR/src log_must mkdir $TESTDIR/src
log_must mkdir $TESTDIR/dst log_must mkdir $TESTDIR/dst
WD=$(pwd) WD=$PWD
cd $TESTDIR/src cd $TESTDIR/src
# create NR_FILES in BATCH at a time to prevent overflowing argument buffer # create NR_FILES in BATCH at a time to prevent overflowing argument buffer
for i in $(seq $(($NR_FILES/$BATCH))); do touch $(seq $((($i-1)*$BATCH+1)) $(($i*$BATCH))); done for i in $(seq $(($NR_FILES/$BATCH))); do touch $(seq $((($i-1)*$BATCH+1)) $(($i*$BATCH))); done

View File

@ -69,8 +69,6 @@ function try_pool_import # pool opts message
typeset msg=$3 typeset msg=$3
zpool import $opts $pool 2>&1 | grep -i "$msg" zpool import $opts $pool 2>&1 | grep -i "$msg"
return $?
} }
function mmp_set_hostid function mmp_set_hostid
@ -79,11 +77,7 @@ function mmp_set_hostid
zgenhostid $1 zgenhostid $1
if [ $(hostid) != "$hostid" ]; then [ $(hostid) = "$hostid" ]
return 1
fi
return 0
} }
function mmp_clear_hostid function mmp_clear_hostid

View File

@ -59,8 +59,8 @@ create_xattr $testfile passwd /etc/passwd
log_must chmod 000 $testfile log_must chmod 000 $testfile
if is_illumos; then if is_illumos; then
log_mustnot su $ZFS_USER -c "runat $testfile cat passwd" log_mustnot user_run $ZFS_USER runat $testfile cat passwd
log_mustnot su $ZFS_USER -c "runat $testfile cp /etc/passwd ." log_mustnot user_run $ZFS_USER runat $testfile cp /etc/passwd .
else else
log_mustnot user_run $ZFS_USER " log_mustnot user_run $ZFS_USER "
. $STF_SUITE/include/libtest.shlib . $STF_SUITE/include/libtest.shlib

View File

@ -61,6 +61,6 @@ log_mustnot runat $TESTDIR/myfile.$$ mknod block b 888 888
log_mustnot runat $TESTDIR/myfile.$$ mknod char c log_mustnot runat $TESTDIR/myfile.$$ mknod char c
log_mustnot runat $TESTDIR/myfile.$$ mknod fifo p log_mustnot runat $TESTDIR/myfile.$$ mkfifo fifo
log_pass "mkdir, mknod fail" log_pass "mkdir, mknod fail"

View File

@ -254,7 +254,7 @@ function do_collect_scripts
# Find a place to deposit performance data collected while under load. # Find a place to deposit performance data collected while under load.
function get_perf_output_dir function get_perf_output_dir
{ {
typeset dir="$(pwd)/perf_data" typeset dir="$PWD/perf_data"
[[ -d $dir ]] || mkdir -p $dir [[ -d $dir ]] || mkdir -p $dir
echo $dir echo $dir
@ -467,7 +467,7 @@ function get_system_config
echo "{" >>$config echo "{" >>$config
if is_linux; then if is_linux; then
echo " \"ncpus\": \"$(nproc --all)\"," >>$config echo " \"ncpus\": \"$(lscpu | awk '/^CPU\(s\)/ {print $2; exit}')\"," >>$config
echo " \"physmem\": \"$(free -b | \ echo " \"physmem\": \"$(free -b | \
awk '$1 == "Mem:" { print $2 }')\"," >>$config awk '$1 == "Mem:" { print $2 }')\"," >>$config
echo " \"c_max\": \"$(get_max_arc_size)\"," >>$config echo " \"c_max\": \"$(get_max_arc_size)\"," >>$config

View File

@ -1,5 +1,4 @@
#!/usr/bin/env bash #!/bin/sh
# shellcheck disable=SC1004
# #
# This file and its contents are supplied under the terms of the # This file and its contents are supplied under the terms of the
@ -21,33 +20,12 @@
# TBD if we can add additional kstats to achieve the desired results # TBD if we can add additional kstats to achieve the desired results
# #
zfs_kstats="/proc/spl/kstat/zfs" getstat() {
awk -v c="$1" '$1 == c {print $3; exit}' /proc/spl/kstat/zfs/arcstats
function get_prefetch_ios
{
typeset -l data_misses="$(awk '$1 == "prefetch_data_misses" \
{ print $3; exit }' "$zfs_kstats/arcstats")"
typeset -l metadata_misses="$(awk '$1 == "prefetch_metadata_misses" \
{ print $3; exit }' "$zfs_kstats/arcstats")"
typeset -l total_misses=$(( data_misses + metadata_misses ))
echo "$total_misses"
} }
function get_prefetched_demand_reads get_prefetch_ios() {
{ echo $(( $(getstat prefetch_data_misses) + $(getstat prefetch_metadata_misses) ))
typeset -l demand_reads="$(awk '$1 == "demand_hit_predictive_prefetch" \
{ print $3; exit }' "$zfs_kstats/arcstats")"
echo "$demand_reads"
}
function get_async_upgrade_sync
{
typeset -l sync_wait="$(awk '$1 == "async_upgrade_sync" \
{ print $3; exit }' "$zfs_kstats/arcstats")"
echo "$sync_wait"
} }
if [ $# -ne 2 ] if [ $# -ne 2 ]
@ -58,8 +36,8 @@ fi
interval=$2 interval=$2
prefetch_ios=$(get_prefetch_ios) prefetch_ios=$(get_prefetch_ios)
prefetched_demand_reads=$(get_prefetched_demand_reads) prefetched_demand_reads=$(getstat demand_hit_predictive_prefetch)
async_upgrade_sync=$(get_async_upgrade_sync) async_upgrade_sync=$(getstat async_upgrade_sync)
while true while true
do do
@ -68,12 +46,12 @@ do
$(( new_prefetch_ios - prefetch_ios )) $(( new_prefetch_ios - prefetch_ios ))
prefetch_ios=$new_prefetch_ios prefetch_ios=$new_prefetch_ios
new_prefetched_demand_reads=$(get_prefetched_demand_reads) new_prefetched_demand_reads=$(getstat demand_hit_predictive_prefetch)
printf '%-24s\t%u\n' "prefetched_demand_reads" \ printf '%-24s\t%u\n' "prefetched_demand_reads" \
$(( new_prefetched_demand_reads - prefetched_demand_reads )) $(( new_prefetched_demand_reads - prefetched_demand_reads ))
prefetched_demand_reads=$new_prefetched_demand_reads prefetched_demand_reads=$new_prefetched_demand_reads
new_async_upgrade_sync=$(get_async_upgrade_sync) new_async_upgrade_sync=$(getstat async_upgrade_sync)
printf '%-24s\t%u\n' "async_upgrade_sync" \ printf '%-24s\t%u\n' "async_upgrade_sync" \
$(( new_async_upgrade_sync - async_upgrade_sync )) $(( new_async_upgrade_sync - async_upgrade_sync ))
async_upgrade_sync=$new_async_upgrade_sync async_upgrade_sync=$new_async_upgrade_sync