Skip to content

Commit

Permalink
ZTS: fix flakiness in cp_files_002_pos
Browse files Browse the repository at this point in the history
Overwriting with `dd ... count=0` does not test anything.

Then `cp --reflink=always` spuriously succeeds when it shouldn't.

```
11:25:52.09 SUCCESS: zpool sync testpool
11:25:52.10 SUCCESS: dd if=/dev/urandom of=src.data bs=2048 seek=240 count=0 conv=notrunc
11:25:52.13 ERROR: cp --reflink=always src.data dst.data unexpectedly exited 0
```

Signed-off-by: Robert Evans <evansr@google.com>
  • Loading branch information
rrevans committed Mar 26, 2024
1 parent 8cd8ccc commit 1dc4a04
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ log_onexit cleanup

SRC_FILE=src.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.
RECORDSIZE=4096
Expand Down Expand Up @@ -120,7 +120,7 @@ for mode in "never" "auto" "always"; do
# Overwrite a random range of an existing file and immediately copy it.
sync_pool $TESTPOOL
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
log_mustnot cp --reflink=$mode $SRC_FILE $DST_FILE
log_must ls -l $CP_TESTDIR
Expand Down Expand Up @@ -152,7 +152,7 @@ for mode in "never" "auto" "always"; do

# Overwrite a random range of an existing file and immediately copy it.
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
verify_copy $SRC_FILE $DST_FILE
log_must rm -f $SRC_FILE $DST_FILE
Expand Down

0 comments on commit 1dc4a04

Please sign in to comment.