1#!/usr/local/bin/ksh93
2#
3# Copyright (c) 2017 Spectra Logic Corporation
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions, and the following disclaimer,
11#    without modification.
12# 2. Redistributions in binary form must reproduce at minimum a disclaimer
13#    substantially similar to the "NO WARRANTY" disclaimer below
14#    ("Disclaimer") and any redistribution must be conditioned upon
15#    including a substantially similar Disclaimer requirement for further
16#    binary redistribution.
17#
18# NO WARRANTY
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
22# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23# HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
28# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29# POSSIBILITY OF SUCH DAMAGES.
30#
31# $FreeBSD$
32
33. $STF_SUITE/include/libtest.kshlib
34set_disks
35
36# "zpool import" will not show destroyed pools, even if out-of-date
37# non-destroyed label is present
38#
39# This situation can happen any time the following things happen:
40# 1) A disk gets removed with its label intact
41# 2) The pool gets destroyed
42# 3) Somebody run "zpool import" to see importable pools
43
44log_must $ZPOOL create -f $TESTPOOL mirror ${DISK0} ${DISK1}
45
46# Offline a disk so it's label won't get updated by the upcoming destroy
47log_must $ZPOOL offline $TESTPOOL ${DISK0}
48
49# Destroy the pool, so DISK1's and DISK2's labels will be in the destroyed
50# state, leaving DISK0's label as the most recent non-destroyed label
51log_must $ZPOOL destroy $TESTPOOL
52
53# Now try to import the pool.  It should fail.
54if $ZPOOL import | $GREP -q $TESTPOOL; then
55	$ZPOOL import
56	log_fail "ERROR: Destroyed pool visible"
57else
58	log_pass
59fi
60