]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_features_002_neg.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zpool_import / zpool_import_features_002_neg.ksh
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
25 #
26
27 . $STF_SUITE/include/libtest.shlib
28 . $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.cfg
29
30 #################################################################################
31 #
32 #  Pool cannot be opened with active unsupported features. Error message should
33 #  list active unsupported features.
34 #
35 #  1. Create new pool.
36 #  2. Export and inject unsuppored features with zhack, make some of them active.
37 #  3. Try to import pool, error should only list active features. It should
38 #     not say anything about being able to import the pool in readonly mode.
39 #
40 ################################################################################
41
42 verify_runnable "global"
43
44 enabled_features="com.test:xxx_unsup1 com.test:xxx_unsup3"
45 active_features="com.test:xxx_unsup0 com.test:xxx_unsup2"
46
47 function cleanup
48 {
49         poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
50
51         log_must rm $VDEV0
52         log_must mkfile $FILE_SIZE $VDEV0
53 }
54
55 log_assert "Pool with active unsupported features cannot be imported."
56 log_onexit cleanup
57
58 log_must zpool create $TESTPOOL1 $VDEV0
59 log_must zpool export $TESTPOOL1
60
61 for feature in $enabled_features $active_features; do
62         log_must zhack -d $DEVICE_DIR feature enable $TESTPOOL1 $feature
63 done
64
65 for feature in $active_features; do
66         log_must zhack -d $DEVICE_DIR feature ref $TESTPOOL1 $feature
67 done
68
69 log_mustnot zpool import -d $DEVICE_DIR $TESTPOOL1
70
71 # error message should not mention "readonly"
72 log_mustnot eval "zpool import -d $DEVICE_DIR $TESTPOOL1 | grep readonly"
73 log_mustnot poolexists $TESTPOOL1
74
75 for feature in $active_features; do
76         log_must eval "zpool import -d $DEVICE_DIR $TESTPOOL1 \
77             | grep $feature"
78         log_mustnot poolexists $TESTPOOL1
79 done
80
81 for feature in $enabled_features; do
82         log_mustnot eval "zpool import -d $DEVICE_DIR $TESTPOOL1 \
83             | grep $feature"
84         log_mustnot poolexists $TESTPOOL1
85 done
86
87 log_pass