]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_remap/zfs_remap_cliargs.ksh
9a0b7d6192093369ce0c69fd8c54fa8ad2c344e6
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zfs_remap / zfs_remap_cliargs.ksh
1 #!/bin/ksh -p
2 #
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
6 # 1.0 of the CDDL.
7 #
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
11 #
12
13 #
14 # Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
15 #
16
17 . $STF_SUITE/include/libtest.shlib
18 . $STF_SUITE/tests/functional/removal/removal.kshlib
19
20 #
21 # DESCRIPTION:
22 # 'zfs remap' should only work with supported parameters.
23 #
24 # STRATEGY:
25 # 1. Prepare a pool where a top-level VDEV has been removed
26 # 2. Verify every supported parameter to 'zfs remap' is accepted
27 # 3. Verify other unsupported parameters raise an error
28 #
29
30 verify_runnable "both"
31
32 function cleanup
33 {
34 destroy_pool $TESTPOOL
35 rm -f $DISK1 $DISK2
36 }
37
38 log_assert "'zfs remap' should only work with supported parameters"
39 log_onexit cleanup
40
41 f="$TESTPOOL/fs"
42 v="$TESTPOOL/vol"
43 s="$TESTPOOL/fs@snap"
44 b="$TESTPOOL/fs#bmark"
45 c="$TESTPOOL/clone"
46
47 typeset goodparams=("$f" "$v" "$c")
48 typeset badparams=("-H" "-p" "-?" "$s" "$b" "$f $f" "$f $v" "$f $s")
49
50 DISK1="$TEST_BASE_DIR/zfs_remap-1"
51 DISK2="$TEST_BASE_DIR/zfs_remap-2"
52
53 # 1. Prepare a pool where a top-level VDEV has been removed
54 log_must truncate -s $(($MINVDEVSIZE * 2)) $DISK1
55 log_must zpool create $TESTPOOL $DISK1
56 log_must zfs create $f
57 log_must zfs create -V 1M -s $v
58 log_must zfs snap $s
59 log_must zfs bookmark $s $b
60 log_must zfs clone $s $c
61 log_must truncate -s $(($MINVDEVSIZE * 2)) $DISK2
62 log_must zpool add $TESTPOOL $DISK2
63 log_must zpool remove $TESTPOOL $DISK1
64 log_must wait_for_removal $TESTPOOL
65
66 # 2. Verify every supported parameter to 'zfs remap' is accepted
67 for param in "${goodparams[@]}"
68 do
69 log_must zfs remap $param
70 done
71
72 # 3. Verify other unsupported parameters raise an error
73 for param in "${badparams[@]}"
74 do
75 log_mustnot zfs remap $param
76 done
77
78 log_pass "'zfs remap' only works with supported parameters"