1*5cabbc6bSPrashanth Sreenivasa#! /bin/ksh -p
2*5cabbc6bSPrashanth Sreenivasa#
3*5cabbc6bSPrashanth Sreenivasa# CDDL HEADER START
4*5cabbc6bSPrashanth Sreenivasa#
5*5cabbc6bSPrashanth Sreenivasa# This file and its contents are supplied under the terms of the
6*5cabbc6bSPrashanth Sreenivasa# Common Development and Distribution License ("CDDL"), version 1.0.
7*5cabbc6bSPrashanth Sreenivasa# You may only use this file in accordance with the terms of version
8*5cabbc6bSPrashanth Sreenivasa# 1.0 of the CDDL.
9*5cabbc6bSPrashanth Sreenivasa#
10*5cabbc6bSPrashanth Sreenivasa# A full copy of the text of the CDDL should have accompanied this
11*5cabbc6bSPrashanth Sreenivasa# source.  A copy of the CDDL is also available via the Internet at
12*5cabbc6bSPrashanth Sreenivasa# http://www.illumos.org/license/CDDL.
13*5cabbc6bSPrashanth Sreenivasa#
14*5cabbc6bSPrashanth Sreenivasa# CDDL HEADER END
15*5cabbc6bSPrashanth Sreenivasa#
16*5cabbc6bSPrashanth Sreenivasa
17*5cabbc6bSPrashanth Sreenivasa#
18*5cabbc6bSPrashanth Sreenivasa# Copyright (c) 2017 by Delphix. All rights reserved.
19*5cabbc6bSPrashanth Sreenivasa#
20*5cabbc6bSPrashanth Sreenivasa
21*5cabbc6bSPrashanth Sreenivasa. $STF_SUITE/include/libtest.shlib
22*5cabbc6bSPrashanth Sreenivasa. $STF_SUITE/tests/functional/removal/removal.kshlib
23*5cabbc6bSPrashanth Sreenivasa
24*5cabbc6bSPrashanth SreenivasaDISK1=$(echo $DISKS | awk '{print $1}')
25*5cabbc6bSPrashanth SreenivasaDISK2=$(echo $DISKS | awk '{print $2}')
26*5cabbc6bSPrashanth SreenivasaDISK3=$(echo $DISKS | awk '{print $3}')
27*5cabbc6bSPrashanth Sreenivasa
28*5cabbc6bSPrashanth SreenivasaDISKS="$DISK1 mirror $DISK2 $DISK3"
29*5cabbc6bSPrashanth Sreenivasa
30*5cabbc6bSPrashanth Sreenivasalog_must default_setup_noexit "$DISKS"
31*5cabbc6bSPrashanth Sreenivasalog_onexit default_cleanup_noexit
32*5cabbc6bSPrashanth Sreenivasa
33*5cabbc6bSPrashanth SreenivasaWORDS_FILE1="/usr/dict/words"
34*5cabbc6bSPrashanth SreenivasaWORDS_FILE2="/usr/share/dict/words"
35*5cabbc6bSPrashanth SreenivasaFILE_CONTENTS="Leeloo Dallas mul-ti-pass."
36*5cabbc6bSPrashanth Sreenivasa
37*5cabbc6bSPrashanth Sreenivasaif [[ -f $WORDS_FILE1 ]]; then
38*5cabbc6bSPrashanth Sreenivasa    log_must cp $WORDS_FILE1 $TESTDIR
39*5cabbc6bSPrashanth Sreenivasaelif [[ -f $WORDS_FILE2 ]]; then
40*5cabbc6bSPrashanth Sreenivasa    log_must cp $WORDS_FILE2 $TESTDIR
41*5cabbc6bSPrashanth Sreenivasaelse
42*5cabbc6bSPrashanth Sreenivasa    echo $FILE_CONTENTS  >$TESTDIR/$TESTFILE0
43*5cabbc6bSPrashanth Sreenivasa    log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ]
44*5cabbc6bSPrashanth Sreenivasafi
45*5cabbc6bSPrashanth Sreenivasa
46*5cabbc6bSPrashanth Sreenivasalog_must zpool remove $TESTPOOL mirror-1
47*5cabbc6bSPrashanth Sreenivasalog_must wait_for_removal $TESTPOOL
48*5cabbc6bSPrashanth Sreenivasalog_mustnot vdevs_in_pool $TESTPOOL mirror-1
49*5cabbc6bSPrashanth Sreenivasa
50*5cabbc6bSPrashanth Sreenivasaif [[ -f $WORDS_FILE1 ]]; then
51*5cabbc6bSPrashanth Sreenivasa    log_must diff $WORDS_FILE1 $TESTDIR/words
52*5cabbc6bSPrashanth Sreenivasaelif [[ -f $WORDS_FILE2 ]]; then
53*5cabbc6bSPrashanth Sreenivasa    log_must diff $WORDS_FILE2 $TESTDIR/words
54*5cabbc6bSPrashanth Sreenivasaelse
55*5cabbc6bSPrashanth Sreenivasa    log_must dd if=/$TESTDIR/$TESTFILE0 of=/dev/null
56*5cabbc6bSPrashanth Sreenivasa    log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ]
57*5cabbc6bSPrashanth Sreenivasafi
58*5cabbc6bSPrashanth Sreenivasa
59*5cabbc6bSPrashanth Sreenivasalog_pass "Removed top-level mirror device not in use after removal."
60