Skip to content

Commit

Permalink
tests: validate getsubopt(3) expulsion
Browse files Browse the repository at this point in the history
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes openzfs#12996
  • Loading branch information
nabijaczleweli authored and andrewc12 committed Sep 23, 2022
1 parent 5169e72 commit 73f86e1
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 7 deletions.
5 changes: 3 additions & 2 deletions tests/runfiles/common.run
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ tests = ['zfs_upgrade_001_pos', 'zfs_upgrade_002_pos', 'zfs_upgrade_003_pos',
tags = ['functional', 'cli_root', 'zfs_upgrade']

[tests/functional/cli_root/zfs_wait]
tests = ['zfs_wait_deleteq']
tests = ['zfs_wait_deleteq', 'zfs_wait_getsubopt']
tags = ['functional', 'cli_root', 'zfs_wait']

[tests/functional/cli_root/zhack]
Expand Down Expand Up @@ -551,7 +551,8 @@ tags = ['functional', 'cli_user', 'misc']

[tests/functional/cli_user/zfs_list]
tests = ['zfs_list_001_pos', 'zfs_list_002_pos', 'zfs_list_003_pos',
'zfs_list_004_neg', 'zfs_list_007_pos', 'zfs_list_008_neg']
'zfs_list_004_neg', 'zfs_list_005_neg', 'zfs_list_007_pos',
'zfs_list_008_neg']
user =
tags = ['functional', 'cli_user', 'zfs_list']

Expand Down
2 changes: 1 addition & 1 deletion tests/runfiles/sanity.run
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ tests = ['zfs_upgrade_001_pos', 'zfs_upgrade_002_pos', 'zfs_upgrade_006_neg',
tags = ['functional', 'cli_root', 'zfs_upgrade']

[tests/functional/cli_root/zfs_wait]
tests = ['zfs_wait_deleteq']
tests = ['zfs_wait_deleteq', 'zfs_wait_getsubopt']
tags = ['functional', 'cli_root', 'zfs_wait']

[tests/functional/cli_root/zpool]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ log_assert "Verify 'zfs get all' fails with invalid combination scenarios."

set -f # Force ksh ignore '?' and '*'
set -A bad_combine "ALL" "\-R all" "-P all" "-h all" "-rph all" "-RpH all" "-PrH all" \
"-o all" "-s all" "-? all" "-* all" "-?* all" "all -r" "all -p" \
"-o all" "-s all" "-s none=getsubopt" "-t filesystem=getsubopt" \
"-? all" "-* all" "-?* all" "all -r" "all -p" \
"all -H" "all -rp" "all -rH" "all -ph" "all -rpH" "all -r $TESTPOOL" \
"all -H $TESTPOOL" "all -p $TESTPOOL" "all -r -p -H $TESTPOOL" \
"all -rph $TESTPOOL" "all,available,reservation $TESTPOOL" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ set -A badargs "o name,property,value,resource" "o name" \
"-o" "-o ,,,,," "-o -o -o -o" "-o NAME,PROPERTY,VALUE,SOURCE" \
"-o name,properTy,value,source" "-o name, property, value,source" \
"-o name:property:value:source" "-o name,property:value,source" \
"-o name;property;value;source"
"-o name;property;value;source" "-o name=getsubopt"

typeset -i i=0
while (( i < ${#badargs[*]} ))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_wait
dist_pkgdata_SCRIPTS = \
setup.ksh \
cleanup.ksh \
zfs_wait_deleteq.ksh
zfs_wait_deleteq.ksh \
zfs_wait_getsubopt.ksh

dist_pkgdata_DATA = \
zfs_wait.kshlib
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/ksh -p
# SPDX-License-Identifier: 0BSD

. $STF_SUITE/include/libtest.shlib

#
# DESCRIPTION:
# zfs wait -t used to accept getsubopt(3)-style deleteq=whatever;
# it doesn't anymore
#

log_mustnot zfs wait -t deleteq=getsubopt $TESTPOOL

log_pass "'zfs wait -t' doesn't accept =getsubopt suffixes."
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ set -A arguments "$TESTPOOL $TESTPOOL" "$TESTPOOL rubbish" "-v $TESTPOOL" \
"nosuchproperty $TESTPOOL" "--$TESTPOOL" "all all" \
"type $TESTPOOL" "usage: $TESTPOOL" "bootfs $TESTPOOL@" \
"bootfs,bootfs $TESTPOOL" "name $TESTPOOL" "t%d%s" \
"bootfs,delegation $TESTPOOL" "delegation $TESTPOOL@"
"bootfs,delegation $TESTPOOL" "delegation $TESTPOOL@" \
"-o name=getsubopt allocated $TESTPOOL"

for arg in $arguments
do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ zpool wait -t scrub fakepool 2>&1 | grep -i 'no such pool' || \
log_fail "Error message did not contain phrase 'no such pool'."
zpool wait -t foo $TESTPOOL 2>&1 | grep -i 'invalid activity' || \
log_fail "Error message did not contain phrase 'invalid activity'."
zpool wait -t scrub=getsubopt $TESTPOOL 2>&1 | grep -i 'invalid activity' || \
log_fail "getsubopt(3) error message did not contain phrase 'invalid activity'."

log_pass "'zpool wait' behaves sensibly when invoked incorrectly."
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dist_pkgdata_SCRIPTS = \
zfs_list_002_pos.ksh \
zfs_list_003_pos.ksh \
zfs_list_004_neg.ksh \
zfs_list_005_neg.ksh \
zfs_list_007_pos.ksh \
zfs_list_008_neg.ksh

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/ksh -p
# SPDX-License-Identifier: 0BSD

. $STF_SUITE/include/libtest.shlib

#
# DESCRIPTION:
# zfs list -t used to accept getsubopt(3)-style filesystem=whatever;
# it doesn't anymore
#

log_mustnot zfs list -t filesystem=getsubopt

log_pass "'zfs list -t' doesn't accept =getsubopt suffixes."

0 comments on commit 73f86e1

Please sign in to comment.