diff options
author | Sara Hartse <[email protected]> | 2020-04-28 09:56:31 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-28 09:56:31 -0700 |
commit | 89a6610ed053359d2299715e519d06d2ca5c053f (patch) | |
tree | cecf3eba8865cdab9520903e94964ff321c3efbe /tests | |
parent | fa254605385ca8db5ce8594018b044e7e3091b5f (diff) |
Add more sanity testing for zdb input args
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: John Kennedy <[email protected]>
Signed-off-by: sara hartse <[email protected]>
Closes #10243
Diffstat (limited to 'tests')
-rw-r--r-- | tests/runfiles/common.run | 4 | ||||
-rw-r--r-- | tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am | 3 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_neg.ksh (renamed from tests/zfs-tests/tests/functional/cli_root/zdb/zdb_001_neg.ksh) | 28 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_pos.ksh | 104 |
4 files changed, 127 insertions, 12 deletions
diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run index 6f83dcd8b..a475db297 100644 --- a/tests/runfiles/common.run +++ b/tests/runfiles/common.run @@ -103,8 +103,8 @@ tests = [ 'clean_mirror_001_pos', 'clean_mirror_002_pos', tags = ['functional', 'clean_mirror'] [tests/functional/cli_root/zdb] -tests = ['zdb_001_neg', 'zdb_002_pos', 'zdb_003_pos', 'zdb_004_pos', - 'zdb_005_pos', 'zdb_006_pos', 'zdb_checksum', 'zdb_decompress', +tests = ['zdb_002_pos', 'zdb_003_pos', 'zdb_004_pos', 'zdb_005_pos', + 'zdb_006_pos', 'zdb_args_neg', 'zdb_args_pos', 'zdb_checksum', 'zdb_decompress', 'zdb_object_range_neg', 'zdb_object_range_pos', 'zdb_display_block', 'zdb_objset_id'] pre = diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am index 71fe68436..e332a91a8 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am @@ -1,11 +1,12 @@ pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zdb dist_pkgdata_SCRIPTS = \ - zdb_001_neg.ksh \ zdb_002_pos.ksh \ zdb_003_pos.ksh \ zdb_004_pos.ksh \ zdb_005_pos.ksh \ zdb_006_pos.ksh \ + zdb_args_neg.ksh \ + zdb_args_pos.ksh \ zdb_checksum.ksh \ zdb_decompress.ksh \ zdb_object_range_neg.ksh \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_neg.ksh index e69779bd4..508f20adb 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_neg.ksh @@ -56,18 +56,28 @@ set -A args "create" "add" "destroy" "import fakepool" \ "add mirror fakepool" "add raidz fakepool" \ "add raidz1 fakepool" "add raidz2 fakepool" \ "setvprop" "blah blah" "-%" "--?" "-*" "-=" \ - "-a" "-f" "-g" "-h" "-j" "-m" "-n" "-o" "-p" \ - "-p /tmp" "-r" "-t" "-w" "-x" "-y" "-z" \ - "-D" "-E" "-G" "-H" "-I" "-J" "-K" "-M" \ - "-N" "-Q" "-R" "-S" "-T" "-W" "-Z" + "-a" "-f" "-g" "-j" "-n" "-o" "-p" "-p /tmp" "-r" \ + "-t" "-w" "-y" "-z" "-E" "-H" "-I" "-J" "-K" \ + "-N" "-Q" "-R" "-T" "-W" "-Z" log_assert "Execute zdb using invalid parameters." -typeset -i i=0 -while [[ $i -lt ${#args[*]} ]]; do - log_mustnot zdb ${args[i]} +log_onexit cleanup - ((i = i + 1)) -done +function cleanup +{ + default_cleanup_noexit +} + +function test_imported_pool +{ + for i in ${args[@]}; do + log_mustnot zdb $i $TESTPOOL + done +} + +default_mirror_setup_noexit $DISKS + +test_imported_pool log_pass "Badly formed zdb parameters fail as expected." diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_pos.ksh new file mode 100755 index 000000000..4bb5c3c4a --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_pos.ksh @@ -0,0 +1,104 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2012, 2020 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# ZDB allows a large number of possible inputs +# and combinations of those inputs. Test for non-zero +# exit values. These input options are based on the zdb +# man page +# +# STRATEGY: +# 1. Create an array containing value zdb parameters. +# 2. For each element, execute the sub-command. +# 3. Verify it does not return a error. +# + +verify_runnable "global" + +log_assert "Execute zdb using valid parameters." + +log_onexit cleanup + +function cleanup +{ + default_cleanup_noexit +} + +function test_imported_pool +{ + typeset -a args=("-A" "-b" "-C" "-c" "-d" "-D" "-G" "-h" "-i" "-L" \ + "-M" "-P" "-s" "-v" "-Y") + for i in ${args[@]}; do + log_must eval "zdb $i $TESTPOOL >/dev/null" + done +} + +function test_exported_pool +{ + log_must zpool export $TESTPOOL + typeset -a args=("-A" "-b" "-C" "-c" "-d" "-D" "-F" "-G" "-h" "-i" "-L" "-M" \ + "-P" "-s" "-v" "-X" "-Y") + for i in ${args[@]}; do + log_must eval "zdb -e $i $TESTPOOL >/dev/null" + done + log_must zpool import $TESTPOOL +} + +function test_vdev +{ + typeset -a args=("-A" "-q" "-u" "-Aqu") + VDEVS=$(get_pool_devices ${TESTPOOL} ${DEV_RDSKDIR}) + log_note $VDEVS + set -A VDEV_ARRAY $VDEVS + for i in ${args[@]}; do + log_must eval "zdb -l $i ${VDEV_ARRAY[0]} >/dev/null" + done +} + +function test_metaslab +{ + typeset -a args=("-A" "-L" "-P" "-Y") + for i in ${args[@]}; do + log_must eval "zdb -m $i $TESTPOOL >/dev/null" + done +} + +default_mirror_setup_noexit $DISKS + +test_imported_pool +test_exported_pool +test_vdev +test_metaslab + +log_pass "Valid zdb parameters pass as expected." |