1#!/bin/ksh -p
2
3#
4# This file and its contents are supplied under the terms of the
5# Common Development and Distribution License ("CDDL"), version 1.0.
6# You may only use this file in accordance with the terms of version
7# 1.0 of the CDDL.
8#
9# A full copy of the text of the CDDL should have accompanied this
10# source.  A copy of the CDDL is also available via the Internet at
11# http://www.illumos.org/license/CDDL.
12#
13
14#
15# Copyright (c) 2020 by Delphix. All rights reserved.
16#
17
18. $STF_SUITE/tests/functional/rsend/rsend.kshlib
19
20#
21# Description:
22# Verify that send -L can be changed to on in an incremental.
23# Verify that send -L can not be turned off in an incremental.
24#
25
26function cleanup
27{
28	log_must_busy zfs destroy -r $TESTPOOL/fs
29	log_must_busy zfs destroy -r $TESTPOOL/recv
30}
31
32verify_runnable "both"
33
34log_assert "Verify toggling send -L works as expected"
35log_onexit cleanup
36
37log_must zfs create -o compression=on -o recordsize=1m $TESTPOOL/fs
38
39log_must dd if=/dev/urandom of=/$TESTPOOL/fs/file bs=1024 count=1500
40
41log_must zfs snapshot $TESTPOOL/fs@snap
42
43log_must dd if=/dev/urandom of=/$TESTPOOL/fs/file bs=1024 count=1500 conv=notrunc seek=2048
44
45log_must zfs snapshot $TESTPOOL/fs@snap2
46
47log_must zfs create $TESTPOOL/recv
48
49log_must zfs send -c $TESTPOOL/fs@snap | zfs recv $TESTPOOL/recv/noL-noL
50log_must zfs send -c -i @snap $TESTPOOL/fs@snap2| zfs recv $TESTPOOL/recv/noL-noL
51log_must diff /$TESTPOOL/fs/file /$TESTPOOL/recv/noL-noL/file
52
53log_must zfs send -c -L $TESTPOOL/fs@snap | zfs recv $TESTPOOL/recv/L-L
54log_must zfs send -c -L -i @snap $TESTPOOL/fs@snap2 | zfs recv $TESTPOOL/recv/L-L
55log_must diff /$TESTPOOL/fs/file /$TESTPOOL/recv/L-L/file
56
57log_must zfs send -c $TESTPOOL/fs@snap | zfs recv $TESTPOOL/recv/noL-L
58log_must zfs send -c -L -i @snap $TESTPOOL/fs@snap2 | zfs recv $TESTPOOL/recv/noL-L
59log_must diff /$TESTPOOL/fs/file /$TESTPOOL/recv/noL-L/file
60
61log_must zfs send -c -L $TESTPOOL/fs@snap | zfs recv $TESTPOOL/recv/L-noL
62log_mustnot zfs send -c -i @snap $TESTPOOL/fs@snap2 | zfs recv $TESTPOOL/recv/L-noL
63log_must diff /$TESTPOOL/fs/.zfs/snapshot/snap/file /$TESTPOOL/recv/L-noL/file
64
65log_pass "Verify toggling send -L works as expected"
66