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 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 can be imported with inactive unsupported features.
33#
34#  1. Create new pool.
35#  2. Export and inject unsuppored features with zhack.
36#  3. Import pool normally with no problems.
37#  4. Verify that unsupported@ properties exist for the unsupported features.
38#
39################################################################################
40
41verify_runnable "global"
42
43features="com.test:xxx_unsup0 com.test:xxx_unsup1 com.test:xxx_unsup2"
44
45function cleanup
46{
47	poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
48
49	log_must $RM $VDEV0
50	log_must $MKFILE $FILE_SIZE $VDEV0
51}
52
53log_assert "Pool with inactive unsupported features can be imported."
54log_onexit cleanup
55
56log_must $ZPOOL create $TESTPOOL1 $VDEV0
57log_must $ZPOOL export $TESTPOOL1
58
59for feature in $features; do
60	log_must $ZHACK -d $DEVICE_DIR feature enable $TESTPOOL1 $feature
61done
62
63log_must $ZPOOL import -d $DEVICE_DIR $TESTPOOL1
64for feature in $features; do
65	state=$($ZPOOL list -Ho unsupported@$feature $TESTPOOL1)
66        if [[ "$state" != "inactive" ]]; then
67		log_fail "unsupported@$feature is '$state'"
68        fi
69done
70
71log_pass
72