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
42verify_runnable "global"
43
44enabled_features="com.test:xxx_unsup1 com.test:xxx_unsup3"
45active_features="com.test:xxx_unsup0 com.test:xxx_unsup2"
46
47function cleanup
48{
49	poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
50
51	log_must rm $VDEV0
52	log_must mkfile $FILE_SIZE $VDEV0
53}
54
55log_assert "Pool with active unsupported features cannot be imported."
56log_onexit cleanup
57
58log_must zpool create $TESTPOOL1 $VDEV0
59log_must zpool export $TESTPOOL1
60
61for feature in $enabled_features $active_features; do
62	log_must zhack -d $DEVICE_DIR feature enable $TESTPOOL1 $feature
63done
64
65for feature in $active_features; do
66	log_must zhack -d $DEVICE_DIR feature ref $TESTPOOL1 $feature
67done
68
69log_mustnot zpool import -d $DEVICE_DIR $TESTPOOL1
70
71# error message should not mention "readonly"
72log_mustnot eval "zpool import -d $DEVICE_DIR $TESTPOOL1 | grep readonly"
73log_mustnot poolexists $TESTPOOL1
74
75for feature in $active_features; do
76	log_must eval "zpool import -d $DEVICE_DIR $TESTPOOL1 \
77	    | grep $feature"
78	log_mustnot poolexists $TESTPOOL1
79done
80
81for feature in $enabled_features; do
82	log_mustnot eval "zpool import -d $DEVICE_DIR $TESTPOOL1 \
83	    | grep $feature"
84	log_mustnot poolexists $TESTPOOL1
85done
86
87log_pass
88