Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zts: avoid piping to special devices #11478

Merged
merged 1 commit into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contrib/pyzfs/libzfs_core/test/test_libzfs_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ def os_open(name, mode):

@contextlib.contextmanager
def dev_null():
with os_open('/dev/null', os.O_WRONLY) as fd:
yield fd
with tempfile.TemporaryFile(suffix='.zstream') as fd:
yield fd.fileno()


@contextlib.contextmanager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ log_must zfs snapshot $init_snap
log_must eval "zfs send $init_snap > $full_bkup"

log_note "'zfs receive' fails with invalid send streams."
log_mustnot eval "zfs receive $rst_init_snap < /dev/zero"
log_mustnot eval "zfs receive -d $rst_root </dev/zero"
log_mustnot eval "cat </dev/zero | zfs receive $rst_init_snap"
log_mustnot eval "cat </dev/zero | zfs receive -d $rst_root"

log_must eval "zfs receive $rst_init_snap < $full_bkup"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ log_must zfs set "org.openzfs:snapprop=val" "$SENDFS@s1"
# 2. Verify command line options interact with '-b' correctly
typeset opts=("" "p" "Rp" "cew" "nv" "D" "DLPRcenpvw")
for opt in ${opts[@]}; do
log_must eval "zfs send -b$opt $SENDFS@s1 > /dev/null"
log_must eval "zfs send -b$opt -i $SENDFS@s1 $SENDFS@s2 > /dev/null"
log_must eval "zfs send -b$opt -I $SENDFS@s1 $SENDFS@s2 > /dev/null"
log_must eval "zfs send -b$opt $SENDFS@s1 >$TEST_BASE_DIR/devnull"
log_must eval "zfs send -b$opt -i $SENDFS@s1 $SENDFS@s2 >$TEST_BASE_DIR/devnull"
log_must eval "zfs send -b$opt -I $SENDFS@s1 $SENDFS@s2 >$TEST_BASE_DIR/devnull"
done
for opt in ${opts[@]}; do
log_mustnot eval "zfs send -b$opt $SENDFS > /dev/null"
log_mustnot eval "zfs send -b$opt $SENDFS#bm > /dev/null"
log_mustnot eval "zfs send -b$opt $SENDFS >$TEST_BASE_DIR/devnull"
log_mustnot eval "zfs send -b$opt $SENDFS#bm >$TEST_BASE_DIR/devnull"
done

# Do 3..6 in a loop to verify various combination of "zfs send" options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ log_must zfs snapshot $snap2

typeset -i i=0
while (( i < ${#args[*]} )); do
log_must eval "zfs send -i ${args[i]} > /dev/null"
log_must eval "zfs send -i ${args[i]} >$TEST_BASE_DIR/devnull"

(( i += 1 ))
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ log_must zfs snapshot $snap3
typeset -i i=0
while (( i < ${#badargs[*]} ))
do
log_mustnot eval "zfs send ${badargs[i]} >/dev/null"
log_mustnot eval "zfs send ${badargs[i]} >$TEST_BASE_DIR/devnull"

(( i = i + 1 ))
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ log_must zfs snapshot -r $TESTPOOL@snap
log_must zpool export $TESTPOOL
log_must zpool import -o readonly=on $TESTPOOL

log_must eval "zfs send -R $TESTPOOL@snap >/dev/null"
log_must eval "zfs send -R $TESTPOOL@snap >$TEST_BASE_DIR/devnull"

log_pass "'zfs send -R' can send from read-only pools"
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ log_must eval "echo $passphrase1 | zfs create -o encryption=on" \

log_must zfs snapshot -r $snap

log_must eval "zfs send $snap > /dev/null"
log_mustnot eval "zfs send -p $snap > /dev/null"
log_mustnot eval "zfs send -R $snap > /dev/null"
log_must eval "zfs send $snap >$TEST_BASE_DIR/devnull"
log_mustnot eval "zfs send -p $snap >$TEST_BASE_DIR/devnull"
log_mustnot eval "zfs send -R $snap >$TEST_BASE_DIR/devnull"

log_must zfs unmount $TESTPOOL/$TESTFS1
log_must zfs unload-key $TESTPOOL/$TESTFS1

log_mustnot eval "zfs send $snap > /dev/null"
log_must eval "zfs send $TESTPOOL/$TESTFS1/child@snap > /dev/null"
log_mustnot eval "zfs send $snap >$TEST_BASE_DIR/devnull"
log_must eval "zfs send $TESTPOOL/$TESTFS1/child@snap >$TEST_BASE_DIR/devnull"

log_pass "ZFS performs unencrypted sends of encrypted datasets, unless the" \
"'-p' or '-R' options are specified"
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ log_must eval "echo $passphrase | zfs create -o encryption=on" \
log_must zfs snapshot $snap
log_must zfs unmount $TESTPOOL/$TESTFS1
log_must zfs unload-key $TESTPOOL/$TESTFS1
log_mustnot eval "zfs send $snap > /dev/null"
log_mustnot eval "zfs send $snap >$TEST_BASE_DIR/devnull"

log_pass "ZFS does not perform unencrypted sends from encrypted datasets" \
"with unloaded keys."
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,21 @@ log_must eval "echo $passphrase | zfs create -o encryption=on" \
log_must zfs snapshot $snap
log_must zfs snapshot $snap1

log_must eval "zfs send -w $snap > /dev/null"
log_must eval "zfs send -w $snap1 > /dev/null"
log_must eval "zfs send -w $snap >$TEST_BASE_DIR/devnull"
log_must eval "zfs send -w $snap1 >$TEST_BASE_DIR/devnull"

log_note "Verify ZFS can perform raw sends with properties"
log_must eval "zfs send -wp $snap > /dev/null"
log_must eval "zfs send -wp $snap1 > /dev/null"
log_must eval "zfs send -wp $snap >$TEST_BASE_DIR/devnull"
log_must eval "zfs send -wp $snap1 >$TEST_BASE_DIR/devnull"

log_note "Verify ZFS can perform raw replication sends"
log_must eval "zfs send -wR $snap > /dev/null"
log_must eval "zfs send -wR $snap1 > /dev/null"
log_must eval "zfs send -wR $snap >$TEST_BASE_DIR/devnull"
log_must eval "zfs send -wR $snap1 >$TEST_BASE_DIR/devnull"

log_note "Verify ZFS can perform a raw send of an encrypted datasets with" \
"its key unloaded"
log_must zfs unmount $TESTPOOL/$TESTFS1
log_must zfs unload-key $TESTPOOL/$TESTFS1
log_must eval "zfs send -w $snap1 > /dev/null"
log_must eval "zfs send -w $snap1 >$TEST_BASE_DIR/devnull"

log_pass "ZFS performs raw sends of datasets"
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ log_must zfs snapshot $clone2@snap

# Incompatible flags
log_must zfs redact $sendfs@snap2 book $clone1@snap
log_mustnot eval "zfs send -R --redact book $sendfs@snap2 >/dev/null"
log_mustnot eval "zfs send -R --redact book $sendfs@snap2 >$TEST_BASE_DIR/devnull"

typeset arg
for arg in "$sendfs" "$clone1#book"; do
log_mustnot eval "zfs send --redact book $arg >/dev/null"
log_mustnot eval "zfs send --redact book $arg >$TEST_BASE_DIR/devnull"
done

# Bad redaction list arguments
Expand All @@ -58,15 +58,15 @@ log_mustnot zfs redact $sendfs@snap1 book
log_mustnot zfs redact $sendfs#book1 book4 $clone1
log_mustnot zfs redact $sendfs@snap1 book snap2 snap3
log_mustnot zfs redact $sendfs@snap1 book @snap2 @snap3
log_mustnot eval "zfs send --redact $sendfs#book $sendfs@snap >/dev/null"
log_mustnot eval "zfs send --redact $sendfs#book $sendfs@snap >$TEST_BASE_DIR/devnull"

# Redaction snapshots not a descendant of tosnap
log_mustnot zfs redact $sendfs@snap2 book $sendfs@snap2
log_must zfs redact $sendfs@snap2 book2 $clone1@snap $clone2@snap
log_must eval "zfs send --redact book2 $sendfs@snap2 >$stream"
log_must zfs redact $sendfs@snap2 book3 $clone1@snap $clone2@snap
log_must eval "zfs send -i $sendfs@snap1 --redact book3 $sendfs@snap2 \
>/dev/null"
>$TEST_BASE_DIR/devnull"
log_mustnot zfs redact $sendfs@snap3 $sendfs@snap3 $clone1@snap

# Full redacted sends of redacted datasets are not allowed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ log_must eval "zfs send --redact book1 $sendfs@snap >$stream"
dd if=$stream bs=64k count=1 | log_mustnot zfs receive -s $recvfs
[[ "-" = $(get_prop receive_resume_token $recvfs) ]] && \
log_fail "Receive token not found."
log_mustnot eval "zfs send --saved --redact book1 $recvfs > /dev/null"
log_mustnot eval "zfs send --saved --redact book1 $recvfs >$TEST_BASE_DIR/devnull"
log_must zfs recv -A $recvfs
log_must datasetnonexists $recvfs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function callback
{
create_snapshot $TESTPOOL/$TESTFS $TESTSNAP
log_must ksh -c \
"zfs send $TESTPOOL/$TESTFS@$TESTSNAP >/dev/null"
"zfs send $TESTPOOL/$TESTFS@$TESTSNAP >$TEST_BASE_DIR/devnull"
return 0
}

Expand Down
2 changes: 1 addition & 1 deletion tests/zfs-tests/tests/functional/rsend/send_invalid.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ log_must zfs snap $testfs@snap0
log_must zfs snap $testfs@snap1

# Test bad send with the CLI
log_mustnot eval "zfs send -i $testfs@snap1 $testfs@snap0 >/dev/null"
log_mustnot eval "zfs send -i $testfs@snap1 $testfs@snap0 >$TEST_BASE_DIR/devnull"

# Test bad send with libzfs/libzfs_core
log_must badsend $testfs@snap0 $testfs@snap1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ set -A badargs \

while (( i < ${#badargs[*]} ))
do
log_mustnot eval "zfs send --saved ${badargs[i]} >/dev/null"
log_mustnot eval "zfs send --saved ${badargs[i]} >$TEST_BASE_DIR/devnull"
(( i = i + 1 ))
done

Expand Down