]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_mountpoint.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zfs_rename / zfs_rename_mountpoint.ksh
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # This file and its contents are supplied under the terms of the
6 # Common Development and Distribution License ("CDDL"), version 1.0.
7 # You may only use this file in accordance with the terms of version
8 # 1.0 of the CDDL.
9 #
10 # A full copy of the text of the CDDL should have accompanied this
11 # source.  A copy is of the CDDL is also available via the Internet
12 # at http://www.illumos.org/license/CDDL.
13 #
14 # CDDL HEADER END
15 #
16
17 #
18 # Copyright (c) 2018 Datto Inc.
19 #
20
21 . $STF_SUITE/include/libtest.shlib
22
23 #
24 # DESCRIPTION:
25 #       zfs rename should rename datasets even for mountpoint=none children
26 #
27 # STRATEGY:
28 #       1. Create a set of nested datasets with mountpoint=none
29 #       2. Verify datasets aren't mounted except for the parent
30 #       3. Rename mountpoint and verify all child datasets are renamed
31 #
32
33 verify_runnable "both"
34
35 function rename_cleanup
36 {
37         log_note zfs destroy -fR $TESTPOOL/rename_test
38         log_note zfs destroy -fR $TESTPOOL/renamed
39 }
40
41 log_onexit rename_cleanup
42
43
44 log_must zfs create $TESTPOOL/rename_test
45 log_must zfs create $TESTPOOL/rename_test/ds
46 log_must zfs create -o mountpoint=none $TESTPOOL/rename_test/child
47 log_must zfs create $TESTPOOL/rename_test/child/grandchild
48
49 if ! ismounted $TESTPOOL/rename_test; then
50         log_fail "$TESTPOOL/rename_test is not mounted"
51 fi
52 if ! ismounted $TESTPOOL/rename_test/ds; then
53         log_fail "$TESTPOOL/rename_test/ds is not mounted"
54 fi
55 if ismounted $TESTPOOL/rename_test/child; then
56         log_fail "$TESTPOOL/rename_test/child is mounted"
57 fi
58 if ismounted $TESTPOOL/rename_test/child/grandchild; then
59         log_fail "$TESTPOOL/rename_test/child/grandchild is mounted"
60 fi
61
62 log_must zfs rename $TESTPOOL/rename_test $TESTPOOL/renamed
63
64 log_mustnot zfs list $TESTPOOL/rename_test
65 log_mustnot zfs list $TESTPOOL/rename_test/ds
66 log_mustnot zfs list $TESTPOOL/rename_test/child
67 log_mustnot zfs list $TESTPOOL/rename_test/child/grandchild
68
69 log_must zfs list $TESTPOOL/renamed
70 log_must zfs list $TESTPOOL/renamed/ds
71 log_must zfs list $TESTPOOL/renamed/child
72 log_must zfs list $TESTPOOL/renamed/child/grandchild
73
74 if ! ismounted $TESTPOOL/renamed; then
75         log_must zfs get all $TESTPOOL/renamed
76         log_fail "$TESTPOOL/renamed is not mounted"
77 fi
78 if ! ismounted $TESTPOOL/renamed/ds; then
79         log_fail "$TESTPOOL/renamed/ds is not mounted"
80 fi
81 if ismounted $TESTPOOL/renamed/child; then
82         log_fail "$TESTPOOL/renamed/child is mounted"
83 fi
84 if ismounted $TESTPOOL/renamed/child/grandchild; then
85         log_fail "$TESTPOOL/renamed/child/grandchild is mounted"
86 fi
87
88 log_pass "Verified rename for mountpoint=none children."