ZTS: fix flakiness in cp_files_002_pos

Fix RANDOM to not return zero.

Overwriting with `dd ... count=0` does not test anything.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Robert Evans <evansr@google.com>
Closes #16029
This commit is contained in:
Robert Evans 2024-03-27 17:59:16 -04:00 committed by Tony Hutter
parent 67995229a8
commit d088fb7d24
1 changed files with 3 additions and 3 deletions

View File

@ -76,7 +76,7 @@ log_onexit cleanup
SRC_FILE=src.data SRC_FILE=src.data
DST_FILE=dst.data DST_FILE=dst.data
SRC_SIZE=$(($RANDOM % 2048)) SRC_SIZE=$((1024 + $RANDOM % 1024))
# A smaller recordsize is used merely to speed up the test. # A smaller recordsize is used merely to speed up the test.
RECORDSIZE=4096 RECORDSIZE=4096
@ -120,7 +120,7 @@ for mode in "never" "auto" "always"; do
# Overwrite a random range of an existing file and immediately copy it. # Overwrite a random range of an existing file and immediately copy it.
sync_pool $TESTPOOL sync_pool $TESTPOOL
log_must dd if=/dev/urandom of=$SRC_FILE bs=$((RECORDSIZE / 2)) \ log_must dd if=/dev/urandom of=$SRC_FILE bs=$((RECORDSIZE / 2)) \
seek=$(($RANDOM % $SRC_SIZE)) count=$(($RANDOM % 16)) conv=notrunc seek=$(($RANDOM % $SRC_SIZE)) count=$((1 + $RANDOM % 16)) conv=notrunc
if [[ "$mode" == "always" ]]; then if [[ "$mode" == "always" ]]; then
log_mustnot cp --reflink=$mode $SRC_FILE $DST_FILE log_mustnot cp --reflink=$mode $SRC_FILE $DST_FILE
log_must ls -l $CP_TESTDIR log_must ls -l $CP_TESTDIR
@ -152,7 +152,7 @@ for mode in "never" "auto" "always"; do
# Overwrite a random range of an existing file and immediately copy it. # Overwrite a random range of an existing file and immediately copy it.
log_must dd if=/dev/urandom of=$SRC_FILE bs=$((RECORDSIZE / 2)) \ log_must dd if=/dev/urandom of=$SRC_FILE bs=$((RECORDSIZE / 2)) \
seek=$(($RANDOM % $SRC_SIZE)) count=$(($RANDOM % 16)) conv=notrunc seek=$(($RANDOM % $SRC_SIZE)) count=$((1 + $RANDOM % 16)) conv=notrunc
log_must cp --reflink=$mode $SRC_FILE $DST_FILE log_must cp --reflink=$mode $SRC_FILE $DST_FILE
verify_copy $SRC_FILE $DST_FILE verify_copy $SRC_FILE $DST_FILE
log_must rm -f $SRC_FILE $DST_FILE log_must rm -f $SRC_FILE $DST_FILE