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.
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.
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]
24 # Copyright 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
27 .
$STF_SUITE/include
/libtest.shlib
28 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_clear
/zpool_clear.cfg
32 # Verify 'zpool clear' cannot be used on readonly pools.
36 # 2. Export the pool and import it readonly.
37 # 3. Verify 'zpool clear' on the pool (and each device) returns an error.
40 verify_runnable
"global"
44 destroy_pool
$TESTPOOL1
48 log_assert
"Verify 'zpool clear' cannot be used on readonly pools."
52 log_must truncate
-s $FILESIZE $TESTDIR/file.
{1,2,3}
53 log_must zpool create
$TESTPOOL1 raidz
$TESTDIR/file.
*
55 # 2. Export the pool and import it readonly.
56 log_must zpool
export $TESTPOOL1
57 log_must zpool import
-d $TESTDIR -o readonly=on
$TESTPOOL1
58 if [[ "$(get_pool_prop readonly $TESTPOOL1)" != 'on' ]]; then
59 log_fail
"Pool $TESTPOOL1 was not imported readonly."
62 # 3. Verify 'zpool clear' on the pool (and each device) returns an error.
63 log_mustnot zpool
clear $TESTPOOL1
65 # Device must be online
66 log_must check_state
$TESTPOOL1 $TESTDIR/file.
$i 'online'
67 # Device cannot be cleared if the pool was imported readonly
68 log_mustnot zpool
clear $TESTPOOL1 $TESTDIR/file.
$i
71 log_pass
"'zpool clear' fails on readonly pools as expected."