1#!/bin/ksh -p
2
3#
4# This file and its contents are supplied under the terms of the
5# Common Development and Distribution License ("CDDL"), version 1.0.
6# You may only use this file in accordance with the terms of version
7# 1.0 of the CDDL.
8#
9# A full copy of the text of the CDDL should have accompanied this
10# source.  A copy of the CDDL is also available via the Internet at
11# http://www.illumos.org/license/CDDL.
12#
13
14#
15# Copyright (c) 2017, Intel Corporation.
16# Copyright (c) 2018 by Delphix. All rights reserved.
17# Copyright 2019 Joyent, Inc.
18#
19
20. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
21
22#
23# DESCRIPTION:
24#	Adding an additional special device to a pool with special succeeds.
25#
26claim="Adding an additional special device succeeds."
27
28verify_runnable "global"
29
30log_assert $claim
31log_onexit cleanup
32
33log_must disk_setup
34
35typeset special_type=""
36typeset create_disks=""
37typeset added_disks=""
38
39for type in "" "raidz"
40do
41	if [ "$type" = "raidz" ]; then
42		special_type="mirror"
43		create_disks="${CLASS_DISK0} ${CLASS_DISK1}"
44		added_disks="${CLASS_DISK2} ${CLASS_DISK3}"
45	else
46		special_type=""
47		create_disks="${CLASS_DISK0}"
48		added_disks="${CLASS_DISK1}"
49	fi
50	log_must zpool create $TESTPOOL $type $ZPOOL_DISKS \
51	    special $special_type $create_disks
52	log_must zpool add $TESTPOOL special $special_type $added_disks
53	for d in $added_disks
54	do
55		log_must zpool status $TESTPOOL | nawk -v dev=$d \
56		   'BEGIN {res=1} {if ($1 == dev) res=0} END {exit res}'
57	done
58	log_must zpool destroy -f $TESTPOOL
59done
60
61log_pass $claim
62