dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / test / zfs-tests / tests / functional / nopwrite / nopwrite_negative.ksh
blob2c166c2414916609fb82850c84c04b9b065e5fe5
1 #!/usr/bin/ksh
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.
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.
15 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
18 . $STF_SUITE/include/libtest.shlib
19 . $STF_SUITE/tests/functional/nopwrite/nopwrite.shlib
22 # Description:
23 # Verify that duplicate writes to a clone are accounted as new data if the
24 # prerequisites for nopwrite are not met.
26 # Scenarios:
27 # 1. The file in the origin ds is written without compression or sha256.
28 # 2. The file in the origin ds is written before sha256 checksum is turned on.
29 # 3. The clone does not have compression.
30 # 4. The clone does not have the appropriate checksum.
33 verify_runnable "global"
34 origin="$TESTPOOL/$TESTFS"
35 log_onexit cleanup
37 function cleanup
39 datasetexists $origin && log_must zfs destroy -R $origin
40 log_must zfs create -o mountpoint=$TESTDIR $origin
43 log_assert "nopwrite isn't enabled without the prerequisites"
45 # Data written into origin fs without compression or sha256
46 dd if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
47 >/dev/null 2>&1 || log_fail "dd of $TESTDIR/file failed."
48 zfs snapshot $origin@a || log_fail "zfs snap failed"
49 log_must zfs clone -o compress=on $origin@a $origin/clone
50 log_must zfs set checksum=sha256 $origin/clone
51 dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
52 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
53 log_mustnot verify_nopwrite $origin $origin@a $origin/clone
54 zfs destroy -R $origin@a || log_fail "zfs destroy failed"
55 log_must rm -f $TESTDIR/file
57 # Data written to origin fs before checksum enabled
58 log_must zfs set compress=on $origin
59 dd if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
60 >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed."
61 log_must zfs set checksum=sha256 $origin
62 zfs snapshot $origin@a || log_fail "zfs snap failed"
63 log_must zfs clone $origin@a $origin/clone
64 dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
65 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
66 log_mustnot verify_nopwrite $origin $origin@a $origin/clone
67 zfs destroy -R $origin@a || log_fail "zfs destroy failed"
68 log_must rm -f $TESTDIR/file
70 # Clone with compression=off
71 dd if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
72 >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed."
73 zfs snapshot $origin@a || log_fail "zfs snap failed"
74 log_must zfs clone -o compress=off $origin@a $origin/clone
75 dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
76 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
77 log_mustnot verify_nopwrite $origin $origin@a $origin/clone
78 zfs destroy -R $origin@a || log_fail "zfs destroy failed"
79 log_must rm -f $TESTDIR/file
81 # Clone with fletcher4, rather than sha256
82 dd if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
83 >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed."
84 zfs snapshot $origin@a || log_fail "zfs snap failed"
85 log_must zfs clone -o checksum=fletcher4 $origin@a $origin/clone
86 dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
87 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
88 log_mustnot verify_nopwrite $origin $origin@a $origin/clone
90 log_pass "nopwrite isn't enabled without the prerequisites"