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 https://opensource.org/licenses/CDDL-1.0. 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 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2012, 2020 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/include/libtest.shlib 33 34# 35# DESCRIPTION: 36# ZDB allows a large number of possible inputs 37# and combinations of those inputs. Test for non-zero 38# exit values. These input options are based on the zdb 39# man page 40# 41# STRATEGY: 42# 1. Create an array containing value zdb parameters. 43# 2. For each element, execute the sub-command. 44# 3. Verify it does not return a error. 45# 46 47verify_runnable "global" 48 49log_assert "Execute zdb using valid parameters." 50 51log_onexit cleanup 52 53function cleanup 54{ 55 default_cleanup_noexit 56} 57 58function test_imported_pool 59{ 60 typeset -a args=("-A" "-b" "-C" "-c" "-d" "-D" "-G" "-h" "-i" "-L" \ 61 "-M" "-P" "-s" "-v" "-Y" "-y") 62 for i in ${args[@]}; do 63 log_must eval "zdb $i $TESTPOOL >/dev/null" 64 done 65} 66 67function test_exported_pool 68{ 69 log_must zpool export $TESTPOOL 70 typeset -a args=("-A" "-b" "-C" "-c" "-d" "-D" "-F" "-G" "-h" "-i" "-L" "-M" \ 71 "-P" "-s" "-v" "-X" "-Y" "-y") 72 for i in ${args[@]}; do 73 log_must eval "zdb -e $i $TESTPOOL >/dev/null" 74 done 75 log_must zpool import $TESTPOOL 76} 77 78function test_vdev 79{ 80 typeset -a args=("-A" "-q" "-u" "-Aqu") 81 VDEVS=$(get_pool_devices ${TESTPOOL} ${DEV_RDSKDIR}) 82 log_note $VDEVS 83 set -A VDEV_ARRAY $VDEVS 84 for i in ${args[@]}; do 85 log_must eval "zdb -l $i ${VDEV_ARRAY[0]} >/dev/null" 86 done 87} 88 89function test_metaslab 90{ 91 typeset -a args=("-A" "-L" "-P" "-Y") 92 for i in ${args[@]}; do 93 log_must eval "zdb -m $i $TESTPOOL >/dev/null" 94 done 95} 96 97default_mirror_setup_noexit $DISKS 98 99test_imported_pool 100test_exported_pool 101test_vdev 102test_metaslab 103 104log_pass "Valid zdb parameters pass as expected." 105