mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-04-06 17:49:11 +03:00
ZTS: Provide an alternative to shuf for FreeBSD
There was a shuf package but the upstream for the port has recently disappeared, so it is no longer available. Create a function to hide the usage of shuf. Implement using seq|random on FreeBSD. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: John Kennedy <john.kennedy@delphix.com> Signed-off-by: Ryan Moeller <ryan@ixsystems.com> Closes #9824
This commit is contained in:
parent
4abd7d80b2
commit
90ae48733c
@ -82,7 +82,6 @@ export SYSTEM_FILES_COMMON='arp
|
|||||||
seq
|
seq
|
||||||
setfacl
|
setfacl
|
||||||
sh
|
sh
|
||||||
shuf
|
|
||||||
sleep
|
sleep
|
||||||
sort
|
sort
|
||||||
ssh
|
ssh
|
||||||
@ -122,6 +121,7 @@ export SYSTEM_FILES_FREEBSD='chflags
|
|||||||
mkfifo
|
mkfifo
|
||||||
newfs
|
newfs
|
||||||
pw
|
pw
|
||||||
|
random
|
||||||
sha256
|
sha256
|
||||||
swapctl
|
swapctl
|
||||||
sysctl
|
sysctl
|
||||||
@ -157,6 +157,7 @@ export SYSTEM_FILES_LINUX='attr
|
|||||||
setenforce
|
setenforce
|
||||||
setfattr
|
setfattr
|
||||||
sha256sum
|
sha256sum
|
||||||
|
shuf
|
||||||
udevadm
|
udevadm
|
||||||
useradd
|
useradd
|
||||||
userdel
|
userdel
|
||||||
|
@ -3934,3 +3934,18 @@ function faketty
|
|||||||
script --return --quiet -c "$*" /dev/null
|
script --return --quiet -c "$*" /dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Produce a random permutation of the integers in a given range (inclusive).
|
||||||
|
#
|
||||||
|
function range_shuffle # begin end
|
||||||
|
{
|
||||||
|
typeset -i begin=$1
|
||||||
|
typeset -i end=$2
|
||||||
|
|
||||||
|
if is_freebsd; then
|
||||||
|
seq ${begin} ${end} | random -f -
|
||||||
|
else
|
||||||
|
shuf -i ${begin}-${end}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
@ -51,7 +51,7 @@ function get_rand_prop
|
|||||||
|
|
||||||
typeset prop_max=$((${#prop_array[@]} - 1))
|
typeset prop_max=$((${#prop_array[@]} - 1))
|
||||||
typeset -i i
|
typeset -i i
|
||||||
for i in $(shuf -i $start-$prop_max -n $num_props); do
|
for i in $(range_shuffle $start $prop_max | head -n $num_props); do
|
||||||
retstr="${prop_array[$i]} $retstr"
|
retstr="${prop_array[$i]} $retstr"
|
||||||
done
|
done
|
||||||
echo $retstr
|
echo $retstr
|
||||||
|
@ -11,7 +11,7 @@ DIR="${TESTDIR}/RANDOM_SMALL"
|
|||||||
log_must mkdir "${DIR}"
|
log_must mkdir "${DIR}"
|
||||||
|
|
||||||
count=0
|
count=0
|
||||||
for i in $(shuf -i 1-"${RC_PASS1}") ; do
|
for i in $(range_shuffle 1 "${RC_PASS1}") ; do
|
||||||
if ! touch "${DIR}/${i}" ; then
|
if ! touch "${DIR}/${i}" ; then
|
||||||
log_fail "error creating ${i} after ${count} files"
|
log_fail "error creating ${i} after ${count} files"
|
||||||
fi
|
fi
|
||||||
|
@ -63,9 +63,9 @@ typeset -i pageblocks volblocks max_swaplow
|
|||||||
((max_swaplow = (volblocks - (pageblocks * 2))))
|
((max_swaplow = (volblocks - (pageblocks * 2))))
|
||||||
|
|
||||||
for i in {0..10}; do
|
for i in {0..10}; do
|
||||||
swaplow=$(shuf -n 1 -i ${pageblocks}-${max_swaplow})
|
swaplow=$(range_shuffle ${pageblocks} ${max_swaplow} | head -n 1)
|
||||||
((maxlen = max_swaplow - swaplow))
|
((maxlen = max_swaplow - swaplow))
|
||||||
swaplen=$(shuf -n 1 -i ${pageblocks}-${maxlen})
|
swaplen=$(range_shuffle ${pageblocks} ${maxlen} | head -n 1)
|
||||||
log_must swap -a $swapname $swaplow $swaplen
|
log_must swap -a $swapname $swaplow $swaplen
|
||||||
log_must swap -d $swapname $swaplow
|
log_must swap -d $swapname $swaplow
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user