Rewrite the check argument parsing
cover Rewrite the check argument parsing
The patchset here were motivated by a previous RFC discussion regarding:
https://lore.kernel.org/fstests/afzmt7SFA4jWhi6U@zlang-mailbox/T/#t
This patchset refactors the argument parsing logic in the 'check' script. The current positional parameter handling is becoming hard to maintain as we add more options.
I've replaced the manual parsing loop with *getopt* to provide a more standard CLI experience, and ensured the functionality remains identical to the previous implementation.
Besides that, I also tried to make below 3 changes:
1) Introduced --fs <fstyp> option, to replace all those filesystem-specific options, e.g. -nfs, -overlay, -cifs and so on.
2) Updated all long-format options to strictly use the double-dash (--) prefix.
3) For backward compatibility, I tried to support legacy non-standard options to ensure existing user workflows aren't broken. A deprecation warning is now issued when these old options are used.
I hope this patchset can facilitate future additions and adjustments to arguments, making the code logic cleaner and more standardized.
Any concerns or review points, please feel free to tell me :)
Thanks,
Zorro
Zorro Lang (4):
check: refactor argument parsing with getopt
check: update usage and README to reflect new argument parsing
check: consolidate argument handling into function
check: add deprecated options warning
README | 10 +- README.overlay | 18 +- check | 435 ++++++++++++++++++++++++++++++++----------------- common/config | 8 +- common/rc | 2 +- 5 files changed, 303 insertions(+), 170 deletions(-)
Signature · 1 line
2.54.0
RFC PATCH 1/4 check: refactor argument parsing with getopt
Replace the legacy, hand-written argument parsing loop with getopt. Also compatible with old-style options (e.g. -nfs, -afs, -glusterfs, -cifs, -9p, -fuse, -virtiofs, -pvfs2, -tmpfs, -ubifs, -overlay, -udiff), pre-process them into long options before giving to getopt.
--- check | 179 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 126 insertions(+), 53 deletions(-)
check +126 -53
@@ -272,48 +272,97 @@ _prepare_test_list() rm -f $tmp.list } -# Process command arguments first. +# Backward compatible with the old options mode. Translate word-style options +# that getopt would misinterpret into long options. +compat_old_option() +{ + check_args=() + while [ $# -gt 0 ]; do + case "$1" in + -nfs) check_args+=("--fs" "nfs") ;; + -afs) check_args+=("--fs" "afs") ;; + -glusterfs) check_args+=("--fs" "glusterfs") ;; + -cifs) check_args+=("--fs" "cifs") ;; + -9p) check_args+=("--fs" "9p") ;; + -fuse) check_args+=("--fs" "fuse") ;; + -virtiofs) check_args+=("--fs" "virtiofs") ;; + -pvfs2) check_args+=("--fs" "pvfs2") ;; + -tmpfs) check_args+=("--fs" "tmpfs") ;; + -ubifs) check_args+=("--fs" "ubifs") ;; + -overlay) check_args+=("--fs" "overlay") ;; + -udiff) check_args+=("--udiff") ;; + *) check_args+=("$1") ;; + esac + shift + done +} + +short_opts="g:x:X:e:E:s:S:lnri:I:TdbR:L:h" +long_opts="fs:,exact-order,large-fs,extra-space:,udiff,help" + +compat_old_option "$@" + +# Note: The '+' prefix in getopt's option string preserves the existing +# behavior that option parsing stops at the first non-option test argument. +parsed_opts=$(getopt -n "check" -o +"${short_opts}" -l "$long_opts" -- "${check_args[@]}") +test $? -ne 0 && usage + +eval set -- "$parsed_opts" + while [ $# -gt 0 ]; do case "$1" in - -\? | -h | --help) usage ;; - - -nfs|-afs|-glusterfs|-cifs|-9p|-fuse|-virtiofs|-pvfs2|-tmpfs|-ubifs) - FSTYP="${1:1}" + --fs) + if [ "$2" == "overlay" ];then + [ "$FSTYP" == overlay ] || \ + export OVL_BASE_FSTYP="$FSTYP" + FSTYP=overlay + export OVERLAY=true + else + FSTYP="$2" + fi + shift ;; - -overlay) - [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP" - FSTYP=overlay - export OVERLAY=true + --udiff) + diff="$diff -u" ;; - - -g) group=$2 ; shift ; - GROUP_LIST="$GROUP_LIST ${group//,/ }" + -g) + GROUP_LIST="$GROUP_LIST ${2//,/ }" + shift ;; - - -x) xgroup=$2 ; shift ; - XGROUP_LIST="$XGROUP_LIST ${xgroup//,/ }" + -x) + XGROUP_LIST="$XGROUP_LIST ${2//,/ }" + shift ;; - - -X) subdir_xfile=$2; shift ; + -X) + subdir_xfile="$2" + shift ;; -e) - xfile=$2; shift ; readarray -t -O "${#exclude_tests[@]}" exclude_tests < \ - <(echo "$xfile" | tr ', ' '\n\n') + <(echo "$2" | tr ', ' '\n\n') + shift ;; - - -E) xfile=$2; shift ; - if [ -f $xfile ]; then + -E) + if [ -f "$2" ]; then readarray -t -O ${#exclude_tests[@]} exclude_tests < \ - <(sed "s/#.*$//" $xfile) + <(sed "s/#.*$//" "$2") fi + shift + ;; + -s) + RUN_SECTION="$RUN_SECTION $2" + shift + ;; + -S) + EXCLUDE_SECTION="$EXCLUDE_SECTION $2" + shift + ;; + -l) + diff="diff" + ;; + -n) + showme=true ;; - -s) RUN_SECTION="$RUN_SECTION $2"; shift ;; - -S) EXCLUDE_SECTION="$EXCLUDE_SECTION $2"; shift ;; - -l) diff="diff" ;; - -udiff) diff="$diff -u" ;; - - -n) showme=true ;; -r) if $exact_order; then _fatal "Cannot specify -r and --exact-order."
@@ -322,40 +371,64 @@ while [ $# -gt 0 ]; do ;; --exact-order) if $randomize; then - _fatal "Cannnot specify --exact-order and -r." + _fatal "Cannot specify --exact-order and -r." fi exact_order=true ;; - -i) iterations=$2; shift ;; - -I) iterations=$2; istop=true; shift ;; - -T) timestamp=true ;; - -d) DUMP_OUTPUT=true ;; - -b) brief_test_summary=true;; - -R) report_fmt=$2 ; shift ; - REPORT_LIST="$REPORT_LIST ${report_fmt//,/ }" + -i) + iterations=$2 + shift + ;; + -I) + iterations=$2 + istop=true + shift + ;; + -T) + timestamp=true + ;; + -d) + DUMP_OUTPUT=true + ;; + -b) + brief_test_summary=true + ;; + -R) + REPORT_LIST="$REPORT_LIST ${2//,/ }" do_report=true + shift ;; - --large-fs) export LARGE_SCRATCH_DEV=yes ;; - --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;; - -L) [[ $2 =~ ^[0-9]+$ ]] || usage - loop_on_fail=$2; shift + --large-fs) + export LARGE_SCRATCH_DEV=yes + ;; + --extra-space) + export SCRATCH_DEV_EMPTY_SPACE="$2" + shift + ;; + -L) + [[ $2 =~ ^[0-9]+$ ]] || usage + loop_on_fail=$2 + shift + ;; + -h|--help) + usage + ;; + --) + shift + break + ;; + *) + usage ;; - - -*) usage ;; - *) # not an argument, we've got tests now. - have_test_arg=true ;; esac - - # if we've found a test specification, the break out of the processing - # loop before we shift the arguments so that this is the first argument - # that we process in the test arg loop below. - if $have_test_arg; then - break; - fi - shift done +# Remaining arguments +if [ $# -gt 0 ]; then + have_test_arg=true +fi + # we need common/rc, that also sources common/config. We need to source it # after processing args, overlay needs FSTYP set before sourcing common/config if ! . ./common/rc; then
Signature · 1 line
2.54.0
Re: [RFC PATCH 1/4] check: refactor argument parsing with getopt
Quoted 49 lines · Zorro Lang
Replace the legacy, hand-written argument parsing loop with getopt. Also compatible with old-style options (e.g. -nfs, -afs, -glusterfs,
(quoted diff) +0
-2-cifs, -9p, -fuse, -virtiofs, -pvfs2, -tmpfs, -ubifs, -overlay, -udiff), pre-process them into long options before giving to getopt.Signed-off-by Zorro Lang <[email protected]>--- check | 179 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 126 insertions(+), 53 deletions(-)check +30
-1@@ -272,48 +272,97 @@ _prepare_test_list() rm -f $tmp.list } -# Process command arguments first. +# Backward compatible with the old options mode. Translate word-style options +# that getopt would misinterpret into long options. +compat_old_option() +{ + check_args=() + while [ $# -gt 0 ]; do + case "$1" in + -nfs) check_args+=("--fs" "nfs") ;; + -afs) check_args+=("--fs" "afs") ;; + -glusterfs) check_args+=("--fs" "glusterfs") ;; + -cifs) check_args+=("--fs" "cifs") ;; + -9p) check_args+=("--fs" "9p") ;; + -fuse) check_args+=("--fs" "fuse") ;; + -virtiofs) check_args+=("--fs" "virtiofs") ;; + -pvfs2) check_args+=("--fs" "pvfs2") ;; + -tmpfs) check_args+=("--fs" "tmpfs") ;; + -ubifs) check_args+=("--fs" "ubifs") ;; + -overlay) check_args+=("--fs" "overlay") ;; + -udiff) check_args+=("--udiff") ;; + *) check_args+=("$1") ;; + esac + shift + done +} + +short_opts="g:x:X:e:E:s:S:lnri:I:TdbR:L:h" +long_opts="fs:,exact-order,large-fs,extra-space:,udiff,help" + +compat_old_option "$@" +
check _prepare_test_list() · line 278
Quoted 10 lines
check +7
-1+# Note: The '+' prefix in getopt's option string preserves the existing +# behavior that option parsing stops at the first non-option test argument. +parsed_opts=$(getopt -n "check" -o +"${short_opts}" -l "$long_opts" -- "${check_args[@]}") +test $? -ne 0 && usage + +eval set -- "$parsed_opts" + while [ $# -gt 0 ]; do case "$1" in - -\? | -h | --help) usage ;;
Hi Zorro, mostly looks good but I think we slightly change the behavior here. Earlier ./check -\? would print help but not:
./check -\?
check: invalid option -- '?'
Warning: need to define parameters for host <host>
or set variables:
TEST_DIR TEST_DEV
Maybe we should add this to compat_old_option ( although i really doubt anyone would care about -\? :) )
Other than that, feel free to add:
Quoted 174 lines
check +89
-51- - -nfs|-afs|-glusterfs|-cifs|-9p|-fuse|-virtiofs|-pvfs2|-tmpfs|-ubifs) - FSTYP="${1:1}" + --fs) + if [ "$2" == "overlay" ];then + [ "$FSTYP" == overlay ] || \ + export OVL_BASE_FSTYP="$FSTYP" + FSTYP=overlay + export OVERLAY=true + else + FSTYP="$2" + fi + shift ;; - -overlay) - [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP" - FSTYP=overlay - export OVERLAY=true + --udiff) + diff="$diff -u" ;; - - -g) group=$2 ; shift ; - GROUP_LIST="$GROUP_LIST ${group//,/ }" + -g) + GROUP_LIST="$GROUP_LIST ${2//,/ }" + shift ;; - - -x) xgroup=$2 ; shift ; - XGROUP_LIST="$XGROUP_LIST ${xgroup//,/ }" + -x) + XGROUP_LIST="$XGROUP_LIST ${2//,/ }" + shift ;; - - -X) subdir_xfile=$2; shift ; + -X) + subdir_xfile="$2" + shift ;; -e) - xfile=$2; shift ; readarray -t -O "${#exclude_tests[@]}" exclude_tests < \ - <(echo "$xfile" | tr ', ' '\n\n') + <(echo "$2" | tr ', ' '\n\n') + shift ;; - - -E) xfile=$2; shift ; - if [ -f $xfile ]; then + -E) + if [ -f "$2" ]; then readarray -t -O ${#exclude_tests[@]} exclude_tests < \ - <(sed "s/#.*$//" $xfile) + <(sed "s/#.*$//" "$2") fi + shift + ;; + -s) + RUN_SECTION="$RUN_SECTION $2" + shift + ;; + -S) + EXCLUDE_SECTION="$EXCLUDE_SECTION $2" + shift + ;; + -l) + diff="diff" + ;; + -n) + showme=true ;; - -s) RUN_SECTION="$RUN_SECTION $2"; shift ;; - -S) EXCLUDE_SECTION="$EXCLUDE_SECTION $2"; shift ;; - -l) diff="diff" ;; - -udiff) diff="$diff -u" ;; - - -n) showme=true ;; -r) if $exact_order; then _fatal "Cannot specify -r and --exact-order."@@ -322,40 +371,64 @@ while [ $# -gt 0 ]; do ;; --exact-order) if $randomize; then - _fatal "Cannnot specify --exact-order and -r." + _fatal "Cannot specify --exact-order and -r." fi exact_order=true ;; - -i) iterations=$2; shift ;; - -I) iterations=$2; istop=true; shift ;; - -T) timestamp=true ;; - -d) DUMP_OUTPUT=true ;; - -b) brief_test_summary=true;; - -R) report_fmt=$2 ; shift ; - REPORT_LIST="$REPORT_LIST ${report_fmt//,/ }" + -i) + iterations=$2 + shift + ;; + -I) + iterations=$2 + istop=true + shift + ;; + -T) + timestamp=true + ;; + -d) + DUMP_OUTPUT=true + ;; + -b) + brief_test_summary=true + ;; + -R) + REPORT_LIST="$REPORT_LIST ${2//,/ }" do_report=true + shift ;; - --large-fs) export LARGE_SCRATCH_DEV=yes ;; - --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;; - -L) [[ $2 =~ ^[0-9]+$ ]] || usage - loop_on_fail=$2; shift + --large-fs) + export LARGE_SCRATCH_DEV=yes + ;; + --extra-space) + export SCRATCH_DEV_EMPTY_SPACE="$2" + shift + ;; + -L) + [[ $2 =~ ^[0-9]+$ ]] || usage + loop_on_fail=$2 + shift + ;; + -h|--help) + usage + ;; + --) + shift + break + ;; + *) + usage ;; - - -*) usage ;; - *) # not an argument, we've got tests now. - have_test_arg=true ;; esac - - # if we've found a test specification, the break out of the processing - # loop before we shift the arguments so that this is the first argument - # that we process in the test arg loop below. - if $have_test_arg; then - break; - fi - shift done +# Remaining arguments +if [ $# -gt 0 ]; then + have_test_arg=true +fi + # we need common/rc, that also sources common/config. We need to source it # after processing args, overlay needs FSTYP set before sourcing common/config if ! . ./common/rc; thenSignature · 1 line
2.54.0
Re: [RFC PATCH 1/4] check: refactor argument parsing with getopt
Quoted 64 lines · Ojaswin Mujoo
Quoted 49 lines · Zorro Lang
Replace the legacy, hand-written argument parsing loop with getopt. Also compatible with old-style options (e.g. -nfs, -afs, -glusterfs,
(quoted diff) +0
-2-cifs, -9p, -fuse, -virtiofs, -pvfs2, -tmpfs, -ubifs, -overlay, -udiff), pre-process them into long options before giving to getopt.Signed-off-by Zorro Lang <[email protected]>--- check | 179 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 126 insertions(+), 53 deletions(-)check +30
-1@@ -272,48 +272,97 @@ _prepare_test_list() rm -f $tmp.list } -# Process command arguments first. +# Backward compatible with the old options mode. Translate word-style options +# that getopt would misinterpret into long options. +compat_old_option() +{ + check_args=() + while [ $# -gt 0 ]; do + case "$1" in + -nfs) check_args+=("--fs" "nfs") ;; + -afs) check_args+=("--fs" "afs") ;; + -glusterfs) check_args+=("--fs" "glusterfs") ;; + -cifs) check_args+=("--fs" "cifs") ;; + -9p) check_args+=("--fs" "9p") ;; + -fuse) check_args+=("--fs" "fuse") ;; + -virtiofs) check_args+=("--fs" "virtiofs") ;; + -pvfs2) check_args+=("--fs" "pvfs2") ;; + -tmpfs) check_args+=("--fs" "tmpfs") ;; + -ubifs) check_args+=("--fs" "ubifs") ;; + -overlay) check_args+=("--fs" "overlay") ;; + -udiff) check_args+=("--udiff") ;; + *) check_args+=("$1") ;; + esac + shift + done +} + +short_opts="g:x:X:e:E:s:S:lnri:I:TdbR:L:h" +long_opts="fs:,exact-order,large-fs,extra-space:,udiff,help" + +compat_old_option "$@" +check _prepare_test_list() · line 278
Quoted 10 lines
check +7
-1+# Note: The '+' prefix in getopt's option string preserves the existing +# behavior that option parsing stops at the first non-option test argument. +parsed_opts=$(getopt -n "check" -o +"${short_opts}" -l "$long_opts" -- "${check_args[@]}") +test $? -ne 0 && usage + +eval set -- "$parsed_opts" + while [ $# -gt 0 ]; do case "$1" in - -\? | -h | --help) usage ;;Hi Zorro, mostly looks good but I think we slightly change the behavior here. Earlier ./check -\? would print help but not:
Quoted 8 lines
./check -\?check: invalid option -- '?'
Warning: need to define parameters for host <host>
or set variables:
TEST_DIRTEST_DEVMaybe we should add this to
compat_old_option( although i really doubt anyone would care about -\? :) )
Thanks for the review! Turns out -\? is indeed an option
while [ $# -gt 0 ]; do
case "$1" in
-\? | -h | --help) usage ;;I've never used it before and wasn't sure if anyone actually does. But given that it's the existing behavior, let's keep it consistent. I'll update and remove the "RFC" flag in next version.
Thanks,
Zorro
Quoted 177 lines
Other than that, feel free to add:
Reviewed-by Ojaswin Mujoo <[email protected]>Quoted 174 lines
check +89
-51- - -nfs|-afs|-glusterfs|-cifs|-9p|-fuse|-virtiofs|-pvfs2|-tmpfs|-ubifs) - FSTYP="${1:1}" + --fs) + if [ "$2" == "overlay" ];then + [ "$FSTYP" == overlay ] || \ + export OVL_BASE_FSTYP="$FSTYP" + FSTYP=overlay + export OVERLAY=true + else + FSTYP="$2" + fi + shift ;; - -overlay) - [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP" - FSTYP=overlay - export OVERLAY=true + --udiff) + diff="$diff -u" ;; - - -g) group=$2 ; shift ; - GROUP_LIST="$GROUP_LIST ${group//,/ }" + -g) + GROUP_LIST="$GROUP_LIST ${2//,/ }" + shift ;; - - -x) xgroup=$2 ; shift ; - XGROUP_LIST="$XGROUP_LIST ${xgroup//,/ }" + -x) + XGROUP_LIST="$XGROUP_LIST ${2//,/ }" + shift ;; - - -X) subdir_xfile=$2; shift ; + -X) + subdir_xfile="$2" + shift ;; -e) - xfile=$2; shift ; readarray -t -O "${#exclude_tests[@]}" exclude_tests < \ - <(echo "$xfile" | tr ', ' '\n\n') + <(echo "$2" | tr ', ' '\n\n') + shift ;; - - -E) xfile=$2; shift ; - if [ -f $xfile ]; then + -E) + if [ -f "$2" ]; then readarray -t -O ${#exclude_tests[@]} exclude_tests < \ - <(sed "s/#.*$//" $xfile) + <(sed "s/#.*$//" "$2") fi + shift + ;; + -s) + RUN_SECTION="$RUN_SECTION $2" + shift + ;; + -S) + EXCLUDE_SECTION="$EXCLUDE_SECTION $2" + shift + ;; + -l) + diff="diff" + ;; + -n) + showme=true ;; - -s) RUN_SECTION="$RUN_SECTION $2"; shift ;; - -S) EXCLUDE_SECTION="$EXCLUDE_SECTION $2"; shift ;; - -l) diff="diff" ;; - -udiff) diff="$diff -u" ;; - - -n) showme=true ;; -r) if $exact_order; then _fatal "Cannot specify -r and --exact-order."@@ -322,40 +371,64 @@ while [ $# -gt 0 ]; do ;; --exact-order) if $randomize; then - _fatal "Cannnot specify --exact-order and -r." + _fatal "Cannot specify --exact-order and -r." fi exact_order=true ;; - -i) iterations=$2; shift ;; - -I) iterations=$2; istop=true; shift ;; - -T) timestamp=true ;; - -d) DUMP_OUTPUT=true ;; - -b) brief_test_summary=true;; - -R) report_fmt=$2 ; shift ; - REPORT_LIST="$REPORT_LIST ${report_fmt//,/ }" + -i) + iterations=$2 + shift + ;; + -I) + iterations=$2 + istop=true + shift + ;; + -T) + timestamp=true + ;; + -d) + DUMP_OUTPUT=true + ;; + -b) + brief_test_summary=true + ;; + -R) + REPORT_LIST="$REPORT_LIST ${2//,/ }" do_report=true + shift ;; - --large-fs) export LARGE_SCRATCH_DEV=yes ;; - --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;; - -L) [[ $2 =~ ^[0-9]+$ ]] || usage - loop_on_fail=$2; shift + --large-fs) + export LARGE_SCRATCH_DEV=yes + ;; + --extra-space) + export SCRATCH_DEV_EMPTY_SPACE="$2" + shift + ;; + -L) + [[ $2 =~ ^[0-9]+$ ]] || usage + loop_on_fail=$2 + shift + ;; + -h|--help) + usage + ;; + --) + shift + break + ;; + *) + usage ;; - - -*) usage ;; - *) # not an argument, we've got tests now. - have_test_arg=true ;; esac - - # if we've found a test specification, the break out of the processing - # loop before we shift the arguments so that this is the first argument - # that we process in the test arg loop below. - if $have_test_arg; then - break; - fi - shift done +# Remaining arguments +if [ $# -gt 0 ]; then + have_test_arg=true +fi + # we need common/rc, that also sources common/config. We need to source it # after processing args, overlay needs FSTYP set before sourcing common/config if ! . ./common/rc; thenSignature · 1 line
2.54.0
Re: [RFC PATCH 1/4] check: refactor argument parsing with getopt
Quoted 71 lines · Zorro Lang
Quoted 70 lines · Ojaswin Mujoo
Quoted 49 lines · Zorro Lang
Replace the legacy, hand-written argument parsing loop with getopt. Also compatible with old-style options (e.g. -nfs, -afs, -glusterfs,
(quoted diff) +0
-2-cifs, -9p, -fuse, -virtiofs, -pvfs2, -tmpfs, -ubifs, -overlay, -udiff), pre-process them into long options before giving to getopt.Signed-off-by Zorro Lang <[email protected]>--- check | 179 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 126 insertions(+), 53 deletions(-)check +30
-1@@ -272,48 +272,97 @@ _prepare_test_list() rm -f $tmp.list } -# Process command arguments first. +# Backward compatible with the old options mode. Translate word-style options +# that getopt would misinterpret into long options. +compat_old_option() +{ + check_args=() + while [ $# -gt 0 ]; do + case "$1" in + -nfs) check_args+=("--fs" "nfs") ;; + -afs) check_args+=("--fs" "afs") ;; + -glusterfs) check_args+=("--fs" "glusterfs") ;; + -cifs) check_args+=("--fs" "cifs") ;; + -9p) check_args+=("--fs" "9p") ;; + -fuse) check_args+=("--fs" "fuse") ;; + -virtiofs) check_args+=("--fs" "virtiofs") ;; + -pvfs2) check_args+=("--fs" "pvfs2") ;; + -tmpfs) check_args+=("--fs" "tmpfs") ;; + -ubifs) check_args+=("--fs" "ubifs") ;; + -overlay) check_args+=("--fs" "overlay") ;; + -udiff) check_args+=("--udiff") ;; + *) check_args+=("$1") ;; + esac + shift + done +} + +short_opts="g:x:X:e:E:s:S:lnri:I:TdbR:L:h" +long_opts="fs:,exact-order,large-fs,extra-space:,udiff,help" + +compat_old_option "$@" +check _prepare_test_list() · line 278
Quoted 10 lines
check +7
-1+# Note: The '+' prefix in getopt's option string preserves the existing +# behavior that option parsing stops at the first non-option test argument. +parsed_opts=$(getopt -n "check" -o +"${short_opts}" -l "$long_opts" -- "${check_args[@]}") +test $? -ne 0 && usage + +eval set -- "$parsed_opts" + while [ $# -gt 0 ]; do case "$1" in - -\? | -h | --help) usage ;;Hi Zorro, mostly looks good but I think we slightly change the behavior here. Earlier ./check -\? would print help but not:
./check -\?check: invalid option -- '?'
Warning: need to define parameters for host <host>
or set variables:
TEST_DIRTEST_DEV
Quoted 4 lines
Quoted 2 lines
Maybe we should add this to
compat_old_option( although i really doubt anyone would care about -\? :) )Thanks for the review! Turns out
-\?is indeed an option
Hi Zorro,
Yeah haha, i doubt anyone uses it tho.
Quoted 8 lines
while [ $# -gt 0 ]; do case "$1" in -\? | -h | --help) usage ;;I've never used it before and wasn't sure if anyone actually does. But given that it's the existing behavior, let's keep it consistent. I'll update and remove the "RFC" flag in next version.
Yep sounds good.
Thanks,
ojaswin
Quoted 181 lines
Thanks,
ZorroQuoted 177 lines
Other than that, feel free to add:
Reviewed-by Ojaswin Mujoo <[email protected]>Quoted 174 lines
check +89
-51- - -nfs|-afs|-glusterfs|-cifs|-9p|-fuse|-virtiofs|-pvfs2|-tmpfs|-ubifs) - FSTYP="${1:1}" + --fs) + if [ "$2" == "overlay" ];then + [ "$FSTYP" == overlay ] || \ + export OVL_BASE_FSTYP="$FSTYP" + FSTYP=overlay + export OVERLAY=true + else + FSTYP="$2" + fi + shift ;; - -overlay) - [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP" - FSTYP=overlay - export OVERLAY=true + --udiff) + diff="$diff -u" ;; - - -g) group=$2 ; shift ; - GROUP_LIST="$GROUP_LIST ${group//,/ }" + -g) + GROUP_LIST="$GROUP_LIST ${2//,/ }" + shift ;; - - -x) xgroup=$2 ; shift ; - XGROUP_LIST="$XGROUP_LIST ${xgroup//,/ }" + -x) + XGROUP_LIST="$XGROUP_LIST ${2//,/ }" + shift ;; - - -X) subdir_xfile=$2; shift ; + -X) + subdir_xfile="$2" + shift ;; -e) - xfile=$2; shift ; readarray -t -O "${#exclude_tests[@]}" exclude_tests < \ - <(echo "$xfile" | tr ', ' '\n\n') + <(echo "$2" | tr ', ' '\n\n') + shift ;; - - -E) xfile=$2; shift ; - if [ -f $xfile ]; then + -E) + if [ -f "$2" ]; then readarray -t -O ${#exclude_tests[@]} exclude_tests < \ - <(sed "s/#.*$//" $xfile) + <(sed "s/#.*$//" "$2") fi + shift + ;; + -s) + RUN_SECTION="$RUN_SECTION $2" + shift + ;; + -S) + EXCLUDE_SECTION="$EXCLUDE_SECTION $2" + shift + ;; + -l) + diff="diff" + ;; + -n) + showme=true ;; - -s) RUN_SECTION="$RUN_SECTION $2"; shift ;; - -S) EXCLUDE_SECTION="$EXCLUDE_SECTION $2"; shift ;; - -l) diff="diff" ;; - -udiff) diff="$diff -u" ;; - - -n) showme=true ;; -r) if $exact_order; then _fatal "Cannot specify -r and --exact-order."@@ -322,40 +371,64 @@ while [ $# -gt 0 ]; do ;; --exact-order) if $randomize; then - _fatal "Cannnot specify --exact-order and -r." + _fatal "Cannot specify --exact-order and -r." fi exact_order=true ;; - -i) iterations=$2; shift ;; - -I) iterations=$2; istop=true; shift ;; - -T) timestamp=true ;; - -d) DUMP_OUTPUT=true ;; - -b) brief_test_summary=true;; - -R) report_fmt=$2 ; shift ; - REPORT_LIST="$REPORT_LIST ${report_fmt//,/ }" + -i) + iterations=$2 + shift + ;; + -I) + iterations=$2 + istop=true + shift + ;; + -T) + timestamp=true + ;; + -d) + DUMP_OUTPUT=true + ;; + -b) + brief_test_summary=true + ;; + -R) + REPORT_LIST="$REPORT_LIST ${2//,/ }" do_report=true + shift ;; - --large-fs) export LARGE_SCRATCH_DEV=yes ;; - --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;; - -L) [[ $2 =~ ^[0-9]+$ ]] || usage - loop_on_fail=$2; shift + --large-fs) + export LARGE_SCRATCH_DEV=yes + ;; + --extra-space) + export SCRATCH_DEV_EMPTY_SPACE="$2" + shift + ;; + -L) + [[ $2 =~ ^[0-9]+$ ]] || usage + loop_on_fail=$2 + shift + ;; + -h|--help) + usage + ;; + --) + shift + break + ;; + *) + usage ;; - - -*) usage ;; - *) # not an argument, we've got tests now. - have_test_arg=true ;; esac - - # if we've found a test specification, the break out of the processing - # loop before we shift the arguments so that this is the first argument - # that we process in the test arg loop below. - if $have_test_arg; then - break; - fi - shift done +# Remaining arguments +if [ $# -gt 0 ]; then + have_test_arg=true +fi + # we need common/rc, that also sources common/config. We need to source it # after processing args, overlay needs FSTYP set before sourcing common/config if ! . ./common/rc; thenSignature · 1 line
2.54.0
Re: [RFC PATCH 1/4] check: refactor argument parsing with getopt
Quoted 72 lines · Ojaswin Mujoo
Quoted 71 lines · Zorro Lang
Quoted 70 lines · Ojaswin Mujoo
Quoted 49 lines · Zorro Lang
Replace the legacy, hand-written argument parsing loop with getopt. Also compatible with old-style options (e.g. -nfs, -afs, -glusterfs,
(quoted diff) +0
-2-cifs, -9p, -fuse, -virtiofs, -pvfs2, -tmpfs, -ubifs, -overlay, -udiff), pre-process them into long options before giving to getopt.Signed-off-by Zorro Lang <[email protected]>--- check | 179 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 126 insertions(+), 53 deletions(-)check +30
-1@@ -272,48 +272,97 @@ _prepare_test_list() rm -f $tmp.list } -# Process command arguments first. +# Backward compatible with the old options mode. Translate word-style options +# that getopt would misinterpret into long options. +compat_old_option() +{ + check_args=() + while [ $# -gt 0 ]; do + case "$1" in + -nfs) check_args+=("--fs" "nfs") ;; + -afs) check_args+=("--fs" "afs") ;; + -glusterfs) check_args+=("--fs" "glusterfs") ;; + -cifs) check_args+=("--fs" "cifs") ;; + -9p) check_args+=("--fs" "9p") ;; + -fuse) check_args+=("--fs" "fuse") ;; + -virtiofs) check_args+=("--fs" "virtiofs") ;; + -pvfs2) check_args+=("--fs" "pvfs2") ;; + -tmpfs) check_args+=("--fs" "tmpfs") ;; + -ubifs) check_args+=("--fs" "ubifs") ;; + -overlay) check_args+=("--fs" "overlay") ;; + -udiff) check_args+=("--udiff") ;; + *) check_args+=("$1") ;; + esac + shift + done +} + +short_opts="g:x:X:e:E:s:S:lnri:I:TdbR:L:h" +long_opts="fs:,exact-order,large-fs,extra-space:,udiff,help" + +compat_old_option "$@" +check _prepare_test_list() · line 278
Quoted 10 lines
check +7
-1+# Note: The '+' prefix in getopt's option string preserves the existing +# behavior that option parsing stops at the first non-option test argument. +parsed_opts=$(getopt -n "check" -o +"${short_opts}" -l "$long_opts" -- "${check_args[@]}") +test $? -ne 0 && usage + +eval set -- "$parsed_opts" + while [ $# -gt 0 ]; do case "$1" in - -\? | -h | --help) usage ;;Hi Zorro, mostly looks good but I think we slightly change the behavior here. Earlier ./check -\? would print help but not:
./check -\?check: invalid option -- '?'
Warning: need to define parameters for host <host>
or set variables:
TEST_DIRTEST_DEV
Quoted 16 lines
Quoted 4 lines
Quoted 2 lines
Maybe we should add this to
compat_old_option( although i really doubt anyone would care about -\? :) )Thanks for the review! Turns out
-\?is indeed an optionHi Zorro,
Yeah haha, i doubt anyone uses it tho.
Quoted 8 lines
while [ $# -gt 0 ]; do case "$1" in -\? | -h | --help) usage ;;I've never used it before and wasn't sure if anyone actually does. But given that it's the existing behavior, let's keep it consistent. I'll update and remove the "RFC" flag in next version.
Hi,
I just found out that "?" is not supported as a valid option character by getopt, and "-?" doesn't seem to be standard usage anyway. Because of this, we can't really support "-?" natively via getopt.
However, I can handle "-?" inside compat_old_option() by mapping "-\?)" to check_args+=("-h") and treating it as a deprecated option. Is that good to you and others?
Thanks,
Zorro
Quoted 188 lines
Yep sounds good.
Thanks,
ojaswinQuoted 181 lines
Thanks,
ZorroQuoted 177 lines
Other than that, feel free to add:
Reviewed-by Ojaswin Mujoo <[email protected]>Quoted 174 lines
check +89
-51- - -nfs|-afs|-glusterfs|-cifs|-9p|-fuse|-virtiofs|-pvfs2|-tmpfs|-ubifs) - FSTYP="${1:1}" + --fs) + if [ "$2" == "overlay" ];then + [ "$FSTYP" == overlay ] || \ + export OVL_BASE_FSTYP="$FSTYP" + FSTYP=overlay + export OVERLAY=true + else + FSTYP="$2" + fi + shift ;; - -overlay) - [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP" - FSTYP=overlay - export OVERLAY=true + --udiff) + diff="$diff -u" ;; - - -g) group=$2 ; shift ; - GROUP_LIST="$GROUP_LIST ${group//,/ }" + -g) + GROUP_LIST="$GROUP_LIST ${2//,/ }" + shift ;; - - -x) xgroup=$2 ; shift ; - XGROUP_LIST="$XGROUP_LIST ${xgroup//,/ }" + -x) + XGROUP_LIST="$XGROUP_LIST ${2//,/ }" + shift ;; - - -X) subdir_xfile=$2; shift ; + -X) + subdir_xfile="$2" + shift ;; -e) - xfile=$2; shift ; readarray -t -O "${#exclude_tests[@]}" exclude_tests < \ - <(echo "$xfile" | tr ', ' '\n\n') + <(echo "$2" | tr ', ' '\n\n') + shift ;; - - -E) xfile=$2; shift ; - if [ -f $xfile ]; then + -E) + if [ -f "$2" ]; then readarray -t -O ${#exclude_tests[@]} exclude_tests < \ - <(sed "s/#.*$//" $xfile) + <(sed "s/#.*$//" "$2") fi + shift + ;; + -s) + RUN_SECTION="$RUN_SECTION $2" + shift + ;; + -S) + EXCLUDE_SECTION="$EXCLUDE_SECTION $2" + shift + ;; + -l) + diff="diff" + ;; + -n) + showme=true ;; - -s) RUN_SECTION="$RUN_SECTION $2"; shift ;; - -S) EXCLUDE_SECTION="$EXCLUDE_SECTION $2"; shift ;; - -l) diff="diff" ;; - -udiff) diff="$diff -u" ;; - - -n) showme=true ;; -r) if $exact_order; then _fatal "Cannot specify -r and --exact-order."@@ -322,40 +371,64 @@ while [ $# -gt 0 ]; do ;; --exact-order) if $randomize; then - _fatal "Cannnot specify --exact-order and -r." + _fatal "Cannot specify --exact-order and -r." fi exact_order=true ;; - -i) iterations=$2; shift ;; - -I) iterations=$2; istop=true; shift ;; - -T) timestamp=true ;; - -d) DUMP_OUTPUT=true ;; - -b) brief_test_summary=true;; - -R) report_fmt=$2 ; shift ; - REPORT_LIST="$REPORT_LIST ${report_fmt//,/ }" + -i) + iterations=$2 + shift + ;; + -I) + iterations=$2 + istop=true + shift + ;; + -T) + timestamp=true + ;; + -d) + DUMP_OUTPUT=true + ;; + -b) + brief_test_summary=true + ;; + -R) + REPORT_LIST="$REPORT_LIST ${2//,/ }" do_report=true + shift ;; - --large-fs) export LARGE_SCRATCH_DEV=yes ;; - --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;; - -L) [[ $2 =~ ^[0-9]+$ ]] || usage - loop_on_fail=$2; shift + --large-fs) + export LARGE_SCRATCH_DEV=yes + ;; + --extra-space) + export SCRATCH_DEV_EMPTY_SPACE="$2" + shift + ;; + -L) + [[ $2 =~ ^[0-9]+$ ]] || usage + loop_on_fail=$2 + shift + ;; + -h|--help) + usage + ;; + --) + shift + break + ;; + *) + usage ;; - - -*) usage ;; - *) # not an argument, we've got tests now. - have_test_arg=true ;; esac - - # if we've found a test specification, the break out of the processing - # loop before we shift the arguments so that this is the first argument - # that we process in the test arg loop below. - if $have_test_arg; then - break; - fi - shift done +# Remaining arguments +if [ $# -gt 0 ]; then + have_test_arg=true +fi + # we need common/rc, that also sources common/config. We need to source it # after processing args, overlay needs FSTYP set before sourcing common/config if ! . ./common/rc; thenSignature · 1 line
2.54.0
RFC PATCH 2/4 check: update usage and README to reflect new argument parsing
In reply to Zorro LangUpdate usage() function, README.* files and some comments to match the new argument parsing method.
--- README | 10 +++--- README.overlay | 18 +++++------ check | 85 ++++++++++++++++++++++++++------------------------ common/config | 8 ++--- common/rc | 2 +- 5 files changed, 63 insertions(+), 60 deletions(-)
README +5 -5
@@ -386,7 +386,7 @@ Misc: - Set DIFF_LENGTH to "number of diff lines to print from a failed test", by default 10, set to 0 to print the full diff - set IDMAPPED_MOUNTS=true to run all tests on top of idmapped mounts. While - this option is supported for all filesystems currently only -overlay is + this option is supported for all filesystems currently only `--fs overlay` is expected to run without issues. For other filesystems additional patches and fixes to the test suite might be needed. - Set REPORT_VARS_FILE to a file containing colon-separated name-value pairs
@@ -417,10 +417,10 @@ Running tests: - To randomize test order: ./check -r [test(s)] - You can explicitly specify NFS/AFS/CIFS/OVERLAY, otherwise the filesystem type will be autodetected from $TEST_DEV: - - for running nfs tests: ./check -nfs [test(s)] - - for running afs tests: ./check -afs [test(s)] - - for running cifs/smb3 tests: ./check -cifs [test(s)] - - for overlay tests: ./check -overlay [test(s)] + - for running nfs tests: ./check --fs nfs [test(s)] + - for running afs tests: ./check --fs afs [test(s)] + - for running cifs/smb3 tests: ./check --fs cifs [test(s)] + - for overlay tests: ./check --fs overlay [test(s)] The TEST and SCRATCH partitions should be pre-formatted with another base fs, where the overlay dirs will be created
README.overlay +9 -9
@@ -1,5 +1,5 @@ To run xfstest on overlayfs, configure the variables of TEST and SCRATCH -partitions to be used as the "base fs" and run './check -overlay'. +partitions to be used as the "base fs" and run './check --fs overlay'. For example, the following config file can be used to run tests on xfs test/scratch partitions:
@@ -10,24 +10,24 @@ xfs test/scratch partitions: SCRATCH_MNT=/mnt/scratch FSTYP=xfs -Using the same config file, but executing './check -overlay' will +Using the same config file, but executing './check --fs overlay' will use the same partitions as base fs for overlayfs directories and set TEST_DIR/SCRATCH_MNT values to overlay mount points, i.e.: /mnt/test/ovl-mnt and /mnt/scratch/ovl-mnt, for the context of individual tests. -'./check -overlay' does not support mkfs and fsck on the base fs, so -the base fs should be pre-formatted before starting the -overlay run. +'./check --fs overlay' does not support mkfs and fsck on the base fs, so +the base fs should be pre-formatted before starting the --fs overlay run. An easy way to accomplish this is by running './check <some test>' once, -before running './check -overlay'. +before running './check --fs overlay'. -'./check -overlay' support check overlay test and scratch dirs, +'./check --fs overlay' support check overlay test and scratch dirs, OVERLAY_FSCK_OPTIONS should be set instead of FSCK_OPTIONS if fsck options need to given directly. Because of the lack of mkfs support, multi-section config files are only -partly supported with './check -overlay'. Only multi-section files that -do not change FSTYP and MKFS_OPTIONS can be safely used with -overlay. +partly supported with './check --fs overlay'. Only multi-section files that +do not change FSTYP and MKFS_OPTIONS can be safely used with --fs overlay. For example, the following multi-section config file can be used to run overlay tests on the same base fs, but with different mount options, and on
@@ -66,7 +66,7 @@ To enable running unionmount testsuite, clone the git repository from: under the xfstests src directory, or set the environment variable UNIONMOUNT_TESTSUITE to the local path where the repository was cloned. -Run './check -overlay -g overlay/union' to execute all the unionmount testsuite +Run './check --fs overlay -g overlay/union' to execute all the unionmount testsuite test cases.
check +44 -41
109 lines not on this page · raw message
common/config +4 -4
@@ -692,7 +692,7 @@ _canonicalize_devices() fi } -# On check -overlay, for the non multi section config case, this +# On check --fs overlay, for the non multi section config case, this # function is called on every test, before init_rc(). # When SCRATCH/TEST_* vars are defined in config file, config file # is sourced on every test and this function overrides the vars
@@ -714,7 +714,7 @@ _overlay_config_override() [ ! -d "$TEST_DEV" ] || export OVL_BASE_TEST_DIR="$TEST_DEV" [ ! -d "$SCRATCH_DEV" ] || export OVL_BASE_SCRATCH_MNT="$SCRATCH_DEV" - # Config file may specify base fs type, but we obay -overlay flag + # Config file may specify base fs type, but we obay --fs overlay flag [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP" export FSTYP=overlay
@@ -895,7 +895,7 @@ get_next_config() { _check_device SCRATCH_LOGDEV optional $SCRATCH_LOGDEV fi - # Override FSTYP from config when running ./check -overlay + # Override FSTYP from config when running ./check --fs overlay # and maybe override base fs TEST/SCRATCH_DEV with overlay base dirs. # We need to do this *after* default mount options are set by base FSTYP # and *after* SCRATCH_DEV is deduced from SCRATCH_DEV_POOL
@@ -930,7 +930,7 @@ else export TEST_DIR=`_canonicalize_mountpoint TEST_DIR $TEST_DIR` export SCRATCH_MNT=`_canonicalize_mountpoint SCRATCH_MNT $SCRATCH_MNT` - # Override FSTYP from config when running ./check -overlay + # Override FSTYP from config when running ./check --fs overlay # and maybe override base fs TEST/SCRATCH_DEV with overlay base dirs if [ "$OVERLAY" == "true" -o "$FSTYP" == "overlay" ]; then _overlay_config_override
common/rc +1 -1
@@ -4340,7 +4340,7 @@ _has_metadata_journaling() ;; overlay) # metadata journaling check is based on base filesystem configurations - # and because -overlay option saves those configurations to OVL_BASE_*, + # and because --fs overlay option saves those configurations to OVL_BASE_*, # adding restore/override the configurations before/after the check. if [ ! -z $OVL_BASE_FSTYP -a $OVL_BASE_FSTYP != "overlay" ]; then local ret
Signature · 1 line
2.54.0
Re: [RFC PATCH 2/4] check: update usage and README to reflect new argument parsing
Quoted 4 lines · Zorro Lang
Update
usage()function, README.* files and some comments to match the new argument parsing method.Signed-off-by Zorro Lang <[email protected]>
Looks good, feel free to add:
Regards,
ojaswin
Quoted 260 lines
--- README | 10 +++--- README.overlay | 18 +++++------ check | 85 ++++++++++++++++++++++++++------------------------ common/config | 8 ++--- common/rc | 2 +- 5 files changed, 63 insertions(+), 60 deletions(-)README +5
-5@@ -386,7 +386,7 @@ Misc: - Set DIFF_LENGTH to "number of diff lines to print from a failed test", by default 10, set to 0 to print the full diff - set IDMAPPED_MOUNTS=true to run all tests on top of idmapped mounts. While - this option is supported for all filesystems currently only -overlay is + this option is supported for all filesystems currently only `--fs overlay` is expected to run without issues. For other filesystems additional patches and fixes to the test suite might be needed. - Set REPORT_VARS_FILE to a file containing colon-separated name-value pairs@@ -417,10 +417,10 @@ Running tests: - To randomize test order: ./check -r [test(s)] - You can explicitly specify NFS/AFS/CIFS/OVERLAY, otherwise the filesystem type will be autodetected from $TEST_DEV: - - for running nfs tests: ./check -nfs [test(s)] - - for running afs tests: ./check -afs [test(s)] - - for running cifs/smb3 tests: ./check -cifs [test(s)] - - for overlay tests: ./check -overlay [test(s)] + - for running nfs tests: ./check --fs nfs [test(s)] + - for running afs tests: ./check --fs afs [test(s)] + - for running cifs/smb3 tests: ./check --fs cifs [test(s)] + - for overlay tests: ./check --fs overlay [test(s)] The TEST and SCRATCH partitions should be pre-formatted with another base fs, where the overlay dirs will be createdREADME.overlay +9
-9@@ -1,5 +1,5 @@ To run xfstest on overlayfs, configure the variables of TEST and SCRATCH -partitions to be used as the "base fs" and run './check -overlay'. +partitions to be used as the "base fs" and run './check --fs overlay'. For example, the following config file can be used to run tests on xfs test/scratch partitions:@@ -10,24 +10,24 @@ xfs test/scratch partitions: SCRATCH_MNT=/mnt/scratch FSTYP=xfs -Using the same config file, but executing './check -overlay' will +Using the same config file, but executing './check --fs overlay' will use the same partitions as base fs for overlayfs directories and set TEST_DIR/SCRATCH_MNT values to overlay mount points, i.e.: /mnt/test/ovl-mnt and /mnt/scratch/ovl-mnt, for the context of individual tests. -'./check -overlay' does not support mkfs and fsck on the base fs, so -the base fs should be pre-formatted before starting the -overlay run. +'./check --fs overlay' does not support mkfs and fsck on the base fs, so +the base fs should be pre-formatted before starting the --fs overlay run. An easy way to accomplish this is by running './check <some test>' once, -before running './check -overlay'. +before running './check --fs overlay'. -'./check -overlay' support check overlay test and scratch dirs, +'./check --fs overlay' support check overlay test and scratch dirs, OVERLAY_FSCK_OPTIONS should be set instead of FSCK_OPTIONS if fsck options need to given directly. Because of the lack of mkfs support, multi-section config files are only -partly supported with './check -overlay'. Only multi-section files that -do not change FSTYP and MKFS_OPTIONS can be safely used with -overlay. +partly supported with './check --fs overlay'. Only multi-section files that +do not change FSTYP and MKFS_OPTIONS can be safely used with --fs overlay. For example, the following multi-section config file can be used to run overlay tests on the same base fs, but with different mount options, and on@@ -66,7 +66,7 @@ To enable running unionmount testsuite, clone the git repository from: under the xfstests src directory, or set the environment variable UNIONMOUNT_TESTSUITE to the local path where the repository was cloned. -Run './check -overlay -g overlay/union' to execute all the unionmount testsuite +Run './check --fs overlay -g overlay/union' to execute all the unionmount testsuite test cases.check +44
-41@@ -56,43 +56,47 @@ export SRC_DIR="tests" usage() { - echo "Usage: $0 [options] [testlist]"' - -check options - -nfs test NFS - -afs test AFS - -glusterfs test GlusterFS - -cifs test CIFS - -9p test 9p - -fuse test fuse - -virtiofs test virtiofs - -overlay test overlay - -pvfs2 test PVFS2 - -tmpfs test TMPFS - -ubifs test ubifs - -l line mode diff - -udiff show unified diff (default) - -n show me, do not run tests - -T output timestamps - -r randomize test order - --exact-order run tests in the exact order specified - -i <n> iterate the test list <n> times - -I <n> iterate the test list <n> times, but stops iterating further in case of any test failure - -d dump test output to stdout - -b brief test summary - -R fmt[,fmt] generate report in formats specified. Supported formats: xunit, xunit-quiet - --large-fs optimise scratch device for large filesystems - -s section run only specified section from config file - -S section exclude the specified section from the config file - -L <n> loop tests <n> times following a failure, measuring aggregate pass/fail metrics - -testlist options - -g group[,group...] include tests from these groups - -x group[,group...] exclude tests from these groups - -X exclude_file exclude individual tests - -e testlist exclude a specific list of tests - -E external_file exclude individual tests - [testlist] include tests matching names in testlist + echo "Usage: $0 [options] [testlist]"' + +General options: + -b brief test summary + -d dump test output to stdout + -h, --help show this help message + -i <n> iterate the test list <n> times + -I <n> iterate the test list <n> times, but stops + iterating further in case of any test failure + -l line mode diff + -L <n> loop tests <n> times following a failure, measuring + aggregate pass/fail metrics + -n show me, do not run tests + -r randomize test order + -s section run only specified section from config file + -S section exclude the specified section from the config file + -T output timestamps + -R fmt[,fmt] generate report in formats specified. Supported + formats: xunit, xunit-quiet + --exact-order run tests in the exact order specified + --extra-space <size> require minimum free space on scratch device + --fs <type> test the given FSTYP; valid types include: + nfs, afs, glusterfs, cifs, 9p, fuse, virtiofs, + overlay, pvfs2, tmpfs, ubifs + --large-fs optimise scratch device for large filesystems + --udiff show unified diff (default) + +Test selection options: + -e testlist exclude a specific list of tests + -E external_file exclude tests listed in the given file + -g group[,group...] include tests from these groups + -x group[,group...] exclude tests from these groups + -X exclude_file exclude individual tests + [testlist] include tests matching names in testlist + +Backward-compatible options: + For compatibility, old options are still accepted (but deprecated): + --fs <nfs|afs|glusterfs|...> is equivalent to: + -nfs, -afs, -glusterfs, -cifs, -9p, -fuse, -virtiofs, -overlay, + -pvfs2, -tmpfs, -ubifs + -udiff is equivalent to --udiff. testlist argument is a list of tests in the form of <test dir>/<test name>.@@ -109,7 +113,7 @@ If you want to run all the tests in the test suite, use "-g all" to specify all groups. exclude_file argument refers to a name of a file inside each test directory. -for every test dir where this file is found, the listed test names are +For every test dir where this file is found, the listed test names are excluded from the list of tests to run from that test dir. external_file argument is a path to a single file containing a list of tests@@ -117,15 +121,14 @@ to exclude in the form of <test dir>/<test name>. examples: check xfs/001 - check -g quick + check --fs overlay -g quick check -g xfs/quick check -x stress xfs/* check -X .exclude -g auto check -E ~/.xfstests.exclude ' - _fatal + _fatal } - get_sub_group_list() { local d=$1common/config +4
-4@@ -692,7 +692,7 @@ _canonicalize_devices() fi } -# On check -overlay, for the non multi section config case, this +# On check --fs overlay, for the non multi section config case, this # function is called on every test, before init_rc(). # When SCRATCH/TEST_* vars are defined in config file, config file # is sourced on every test and this function overrides the vars@@ -714,7 +714,7 @@ _overlay_config_override() [ ! -d "$TEST_DEV" ] || export OVL_BASE_TEST_DIR="$TEST_DEV" [ ! -d "$SCRATCH_DEV" ] || export OVL_BASE_SCRATCH_MNT="$SCRATCH_DEV" - # Config file may specify base fs type, but we obay -overlay flag + # Config file may specify base fs type, but we obay --fs overlay flag [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP" export FSTYP=overlay@@ -895,7 +895,7 @@ get_next_config() { _check_device SCRATCH_LOGDEV optional $SCRATCH_LOGDEV fi - # Override FSTYP from config when running ./check -overlay + # Override FSTYP from config when running ./check --fs overlay # and maybe override base fs TEST/SCRATCH_DEV with overlay base dirs. # We need to do this *after* default mount options are set by base FSTYP # and *after* SCRATCH_DEV is deduced from SCRATCH_DEV_POOL@@ -930,7 +930,7 @@ else export TEST_DIR=`_canonicalize_mountpoint TEST_DIR $TEST_DIR` export SCRATCH_MNT=`_canonicalize_mountpoint SCRATCH_MNT $SCRATCH_MNT` - # Override FSTYP from config when running ./check -overlay + # Override FSTYP from config when running ./check --fs overlay # and maybe override base fs TEST/SCRATCH_DEV with overlay base dirs if [ "$OVERLAY" == "true" -o "$FSTYP" == "overlay" ]; then _overlay_config_overridecommon/rc +1
-1@@ -4340,7 +4340,7 @@ _has_metadata_journaling() ;; overlay) # metadata journaling check is based on base filesystem configurations - # and because -overlay option saves those configurations to OVL_BASE_*, + # and because --fs overlay option saves those configurations to OVL_BASE_*, # adding restore/override the configurations before/after the check. if [ ! -z $OVL_BASE_FSTYP -a $OVL_BASE_FSTYP != "overlay" ]; then local retSignature · 1 line
2.54.0
RFC PATCH 3/4 check: consolidate argument handling into function
In reply to Zorro LangConsolidate the check script's options and any trailing arguments (e.g. test case list) into the parse_check_args() function (and sub-function of it), to clean up the scattered logic.
--- check | 333 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 172 insertions(+), 161 deletions(-)
check +172 -161
@@ -15,7 +15,7 @@ notrun=() interrupt=true diff="diff -u" showme=false -have_test_arg=false +remain_args=() randomize=false exact_order=false export here=`pwd`
@@ -228,7 +228,7 @@ _prepare_test_list() # Specified groups to include # Note that the CLI processing adds a leading space to the first group # parameter, so we have to catch that here checking for "all" - if ! $have_test_arg && [ "$GROUP_LIST" == " all" ]; then + if [ ${#remain_args[@]} -eq 0 ] && [ "$GROUP_LIST" == " all" ]; then # no test numbers, do everything get_all_tests else
@@ -300,137 +300,182 @@ compat_old_option() done } -short_opts="g:x:X:e:E:s:S:lnri:I:TdbR:L:h" -long_opts="fs:,exact-order,large-fs,extra-space:,udiff,help" - -compat_old_option "$@" +# Process tests from command line now. +process_remain_tests() +{ + local list test_dir test_name group_file -# Note: The '+' prefix in getopt's option string preserves the existing -# behavior that option parsing stops at the first non-option test argument. -parsed_opts=$(getopt -n "check" -o +"${short_opts}" -l "$long_opts" -- "${check_args[@]}") -test $? -ne 0 && usage + while [ $# -gt 0 ]; do + case "$1" in + -*) + _fatal "Arguments before tests, please!" + ;; + *) + # Expand test pattern (e.g. xfs/???, *fs/001) + list=$(cd $SRC_DIR; echo $1) + for t in $list; do + t=${t#$SRC_DIR/} + test_dir=${t%%/*} + test_name=${t##*/} + group_file=$SRC_DIR/$test_dir/group.list -eval set -- "$parsed_opts" + if grep -Eq "^$test_name" $group_file; then + # in group file ... OK + echo $SRC_DIR/$test_dir/$test_name \ + >>$tmp.arglist + else + # oops + echo "$t - unknown test, ignored" + fi + done + ;; + esac -while [ $# -gt 0 ]; do - case "$1" in - --fs) - if [ "$2" == "overlay" ];then - [ "$FSTYP" == overlay ] || \ - export OVL_BASE_FSTYP="$FSTYP" - FSTYP=overlay - export OVERLAY=true - else - FSTYP="$2" - fi - shift - ;; - --udiff) - diff="$diff -u" - ;; - -g) - GROUP_LIST="$GROUP_LIST ${2//,/ }" - shift - ;; - -x) - XGROUP_LIST="$XGROUP_LIST ${2//,/ }" - shift - ;; - -X) - subdir_xfile="$2" shift - ;; - -e) - readarray -t -O "${#exclude_tests[@]}" exclude_tests < \ - <(echo "$2" | tr ', ' '\n\n') - shift - ;; - -E) - if [ -f "$2" ]; then - readarray -t -O ${#exclude_tests[@]} exclude_tests < \ - <(sed "s/#.*$//" "$2") - fi - shift - ;; - -s) - RUN_SECTION="$RUN_SECTION $2" - shift - ;; - -S) - EXCLUDE_SECTION="$EXCLUDE_SECTION $2" - shift - ;; - -l) - diff="diff" - ;; - -n) - showme=true - ;; - -r) - if $exact_order; then - _fatal "Cannot specify -r and --exact-order." - fi - randomize=true - ;; - --exact-order) - if $randomize; then - _fatal "Cannot specify --exact-order and -r." - fi - exact_order=true - ;; - -i) - iterations=$2 - shift - ;; - -I) - iterations=$2 - istop=true - shift - ;; - -T) - timestamp=true - ;; - -d) - DUMP_OUTPUT=true - ;; - -b) - brief_test_summary=true - ;; - -R) - REPORT_LIST="$REPORT_LIST ${2//,/ }" - do_report=true - shift - ;; - --large-fs) - export LARGE_SCRATCH_DEV=yes - ;; - --extra-space) - export SCRATCH_DEV_EMPTY_SPACE="$2" - shift - ;; - -L) - [[ $2 =~ ^[0-9]+$ ]] || usage - loop_on_fail=$2 - shift - ;; - -h|--help) - usage - ;; - --) + done +} + +parse_check_args() +{ + local short_opts="g:x:X:e:E:s:S:lnri:I:TdbR:L:h" + local long_opts="fs:,exact-order,large-fs,extra-space:,udiff,help" + + compat_old_option "$@" + + # Note: The '+' prefix in getopt's option string preserves the existing + # behavior that option parsing stops at the first non-option test argument. + local parsed_opts=$(getopt -n "check" -o +"${short_opts}" -l "$long_opts" -- "${check_args[@]}") + test $? -ne 0 && usage + + eval set -- "$parsed_opts" + + while [ $# -gt 0 ]; do + case "$1" in + --fs) + if [ "$2" == "overlay" ];then + [ "$FSTYP" == overlay ] || \ + export OVL_BASE_FSTYP="$FSTYP" + FSTYP=overlay + export OVERLAY=true + else + FSTYP="$2" + fi + shift + ;; + --udiff) + diff="$diff -u" + ;; + -g) + GROUP_LIST="$GROUP_LIST ${2//,/ }" + shift + ;; + -x) + XGROUP_LIST="$XGROUP_LIST ${2//,/ }" + shift + ;; + -X) + subdir_xfile="$2" + shift + ;; + -e) + readarray -t -O "${#exclude_tests[@]}" exclude_tests < \ + <(echo "$2" | tr ', ' '\n\n') + shift + ;; + -E) + if [ -f "$2" ]; then + readarray -t -O ${#exclude_tests[@]} exclude_tests < \ + <(sed "s/#.*$//" "$2") + fi + shift + ;; + -s) + RUN_SECTION="$RUN_SECTION $2" + shift + ;; + -S) + EXCLUDE_SECTION="$EXCLUDE_SECTION $2" + shift + ;; + -l) + diff="diff" + ;; + -n) + showme=true + ;; + -r) + if $exact_order; then + _fatal "Cannot specify -r and --exact-order." + fi + randomize=true + ;; + --exact-order) + if $randomize; then + _fatal "Cannot specify --exact-order and -r." + fi + exact_order=true + ;; + -i) + iterations=$2 + shift + ;; + -I) + iterations=$2 + istop=true + shift + ;; + -T) + timestamp=true + ;; + -d) + DUMP_OUTPUT=true + ;; + -b) + brief_test_summary=true + ;; + -R) + REPORT_LIST="$REPORT_LIST ${2//,/ }" + do_report=true + shift + ;; + --large-fs) + export LARGE_SCRATCH_DEV=yes + ;; + --extra-space) + export SCRATCH_DEV_EMPTY_SPACE="$2" + shift + ;; + -L) + [[ $2 =~ ^[0-9]+$ ]] || usage + loop_on_fail=$2 + shift + ;; + -h|--help) + usage + ;; + --) + shift + break + ;; + *) + usage + ;; + esac shift - break - ;; - *) - usage - ;; - esac - shift -done + done -# Remaining arguments -if [ $# -gt 0 ]; then - have_test_arg=true -fi + # Remaining arguments (tests list) + if [ $# -gt 0 ]; then + remain_args=("$@") + process_remain_tests "${remain_args[@]}" + elif [ -z "$GROUP_LIST" ]; then + # default group list is the auto group. If any other group or + # test is specified, we use that instead. + GROUP_LIST="auto" + fi +} + +parse_check_args "$@" # we need common/rc, that also sources common/config. We need to source it # after processing args, overlay needs FSTYP set before sourcing common/config
@@ -471,40 +516,6 @@ if [ -n "$subdir_xfile" ]; then done fi -# Process tests from command line now. -if $have_test_arg; then - while [ $# -gt 0 ]; do - case "$1" in - -*) _fatal "Arguments before tests, please!" - ;; - *) # Expand test pattern (e.g. xfs/???, *fs/001) - list=$(cd $SRC_DIR; echo $1) - for t in $list; do - t=${t#$SRC_DIR/} - test_dir=${t%%/*} - test_name=${t##*/} - group_file=$SRC_DIR/$test_dir/group.list - - if grep -Eq "^$test_name" $group_file; then - # in group file ... OK - echo $SRC_DIR/$test_dir/$test_name \ - >>$tmp.arglist - else - # oops - echo "$t - unknown test, ignored" - fi - done - ;; - esac - - shift - done -elif [ -z "$GROUP_LIST" ]; then - # default group list is the auto group. If any other group or test is - # specified, we use that instead. - GROUP_LIST="auto" -fi - if [ `id -u` -ne 0 ] then _fatal "check: QA must be run as root"
Signature · 1 line
2.54.0
Re: [RFC PATCH 3/4] check: consolidate argument handling into function
Quoted 5 lines · Zorro Lang
Consolidate the check script's options and any trailing arguments (e.g. test case list) into the
parse_check_args()function (and sub-function of it), to clean up the scattered logic.Signed-off-by Zorro Lang <[email protected]>
Looks good to me Zorro.
Regards,
ojaswin
Quoted 378 lines
--- check | 333 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 172 insertions(+), 161 deletions(-)check +172
-161@@ -15,7 +15,7 @@ notrun=() interrupt=true diff="diff -u" showme=false -have_test_arg=false +remain_args=() randomize=false exact_order=false export here=`pwd`@@ -228,7 +228,7 @@ _prepare_test_list() # Specified groups to include # Note that the CLI processing adds a leading space to the first group # parameter, so we have to catch that here checking for "all" - if ! $have_test_arg && [ "$GROUP_LIST" == " all" ]; then + if [ ${#remain_args[@]} -eq 0 ] && [ "$GROUP_LIST" == " all" ]; then # no test numbers, do everything get_all_tests else@@ -300,137 +300,182 @@ compat_old_option() done } -short_opts="g:x:X:e:E:s:S:lnri:I:TdbR:L:h" -long_opts="fs:,exact-order,large-fs,extra-space:,udiff,help" - -compat_old_option "$@" +# Process tests from command line now. +process_remain_tests() +{ + local list test_dir test_name group_file -# Note: The '+' prefix in getopt's option string preserves the existing -# behavior that option parsing stops at the first non-option test argument. -parsed_opts=$(getopt -n "check" -o +"${short_opts}" -l "$long_opts" -- "${check_args[@]}") -test $? -ne 0 && usage + while [ $# -gt 0 ]; do + case "$1" in + -*) + _fatal "Arguments before tests, please!" + ;; + *) + # Expand test pattern (e.g. xfs/???, *fs/001) + list=$(cd $SRC_DIR; echo $1) + for t in $list; do + t=${t#$SRC_DIR/} + test_dir=${t%%/*} + test_name=${t##*/} + group_file=$SRC_DIR/$test_dir/group.list -eval set -- "$parsed_opts" + if grep -Eq "^$test_name" $group_file; then + # in group file ... OK + echo $SRC_DIR/$test_dir/$test_name \ + >>$tmp.arglist + else + # oops + echo "$t - unknown test, ignored" + fi + done + ;; + esac -while [ $# -gt 0 ]; do - case "$1" in - --fs) - if [ "$2" == "overlay" ];then - [ "$FSTYP" == overlay ] || \ - export OVL_BASE_FSTYP="$FSTYP" - FSTYP=overlay - export OVERLAY=true - else - FSTYP="$2" - fi - shift - ;; - --udiff) - diff="$diff -u" - ;; - -g) - GROUP_LIST="$GROUP_LIST ${2//,/ }" - shift - ;; - -x) - XGROUP_LIST="$XGROUP_LIST ${2//,/ }" - shift - ;; - -X) - subdir_xfile="$2" shift - ;; - -e) - readarray -t -O "${#exclude_tests[@]}" exclude_tests < \ - <(echo "$2" | tr ', ' '\n\n') - shift - ;; - -E) - if [ -f "$2" ]; then - readarray -t -O ${#exclude_tests[@]} exclude_tests < \ - <(sed "s/#.*$//" "$2") - fi - shift - ;; - -s) - RUN_SECTION="$RUN_SECTION $2" - shift - ;; - -S) - EXCLUDE_SECTION="$EXCLUDE_SECTION $2" - shift - ;; - -l) - diff="diff" - ;; - -n) - showme=true - ;; - -r) - if $exact_order; then - _fatal "Cannot specify -r and --exact-order." - fi - randomize=true - ;; - --exact-order) - if $randomize; then - _fatal "Cannot specify --exact-order and -r." - fi - exact_order=true - ;; - -i) - iterations=$2 - shift - ;; - -I) - iterations=$2 - istop=true - shift - ;; - -T) - timestamp=true - ;; - -d) - DUMP_OUTPUT=true - ;; - -b) - brief_test_summary=true - ;; - -R) - REPORT_LIST="$REPORT_LIST ${2//,/ }" - do_report=true - shift - ;; - --large-fs) - export LARGE_SCRATCH_DEV=yes - ;; - --extra-space) - export SCRATCH_DEV_EMPTY_SPACE="$2" - shift - ;; - -L) - [[ $2 =~ ^[0-9]+$ ]] || usage - loop_on_fail=$2 - shift - ;; - -h|--help) - usage - ;; - --) + done +} + +parse_check_args() +{ + local short_opts="g:x:X:e:E:s:S:lnri:I:TdbR:L:h" + local long_opts="fs:,exact-order,large-fs,extra-space:,udiff,help" + + compat_old_option "$@" + + # Note: The '+' prefix in getopt's option string preserves the existing + # behavior that option parsing stops at the first non-option test argument. + local parsed_opts=$(getopt -n "check" -o +"${short_opts}" -l "$long_opts" -- "${check_args[@]}") + test $? -ne 0 && usage + + eval set -- "$parsed_opts" + + while [ $# -gt 0 ]; do + case "$1" in + --fs) + if [ "$2" == "overlay" ];then + [ "$FSTYP" == overlay ] || \ + export OVL_BASE_FSTYP="$FSTYP" + FSTYP=overlay + export OVERLAY=true + else + FSTYP="$2" + fi + shift + ;; + --udiff) + diff="$diff -u" + ;; + -g) + GROUP_LIST="$GROUP_LIST ${2//,/ }" + shift + ;; + -x) + XGROUP_LIST="$XGROUP_LIST ${2//,/ }" + shift + ;; + -X) + subdir_xfile="$2" + shift + ;; + -e) + readarray -t -O "${#exclude_tests[@]}" exclude_tests < \ + <(echo "$2" | tr ', ' '\n\n') + shift + ;; + -E) + if [ -f "$2" ]; then + readarray -t -O ${#exclude_tests[@]} exclude_tests < \ + <(sed "s/#.*$//" "$2") + fi + shift + ;; + -s) + RUN_SECTION="$RUN_SECTION $2" + shift + ;; + -S) + EXCLUDE_SECTION="$EXCLUDE_SECTION $2" + shift + ;; + -l) + diff="diff" + ;; + -n) + showme=true + ;; + -r) + if $exact_order; then + _fatal "Cannot specify -r and --exact-order." + fi + randomize=true + ;; + --exact-order) + if $randomize; then + _fatal "Cannot specify --exact-order and -r." + fi + exact_order=true + ;; + -i) + iterations=$2 + shift + ;; + -I) + iterations=$2 + istop=true + shift + ;; + -T) + timestamp=true + ;; + -d) + DUMP_OUTPUT=true + ;; + -b) + brief_test_summary=true + ;; + -R) + REPORT_LIST="$REPORT_LIST ${2//,/ }" + do_report=true + shift + ;; + --large-fs) + export LARGE_SCRATCH_DEV=yes + ;; + --extra-space) + export SCRATCH_DEV_EMPTY_SPACE="$2" + shift + ;; + -L) + [[ $2 =~ ^[0-9]+$ ]] || usage + loop_on_fail=$2 + shift + ;; + -h|--help) + usage + ;; + --) + shift + break + ;; + *) + usage + ;; + esac shift - break - ;; - *) - usage - ;; - esac - shift -done + done -# Remaining arguments -if [ $# -gt 0 ]; then - have_test_arg=true -fi + # Remaining arguments (tests list) + if [ $# -gt 0 ]; then + remain_args=("$@") + process_remain_tests "${remain_args[@]}" + elif [ -z "$GROUP_LIST" ]; then + # default group list is the auto group. If any other group or + # test is specified, we use that instead. + GROUP_LIST="auto" + fi +} + +parse_check_args "$@" # we need common/rc, that also sources common/config. We need to source it # after processing args, overlay needs FSTYP set before sourcing common/config@@ -471,40 +516,6 @@ if [ -n "$subdir_xfile" ]; then done fi -# Process tests from command line now. -if $have_test_arg; then - while [ $# -gt 0 ]; do - case "$1" in - -*) _fatal "Arguments before tests, please!" - ;; - *) # Expand test pattern (e.g. xfs/???, *fs/001) - list=$(cd $SRC_DIR; echo $1) - for t in $list; do - t=${t#$SRC_DIR/} - test_dir=${t%%/*} - test_name=${t##*/} - group_file=$SRC_DIR/$test_dir/group.list - - if grep -Eq "^$test_name" $group_file; then - # in group file ... OK - echo $SRC_DIR/$test_dir/$test_name \ - >>$tmp.arglist - else - # oops - echo "$t - unknown test, ignored" - fi - done - ;; - esac - - shift - done -elif [ -z "$GROUP_LIST" ]; then - # default group list is the auto group. If any other group or test is - # specified, we use that instead. - GROUP_LIST="auto" -fi - if [ `id -u` -ne 0 ] then _fatal "check: QA must be run as root"Signature · 1 line
2.54.0
RFC PATCH 4/4 check: add deprecated options warning
In reply to Zorro LangTo notify xfstests users of deprecated options, add a warning which does not interfere with test results or golden output.
--- check | 72 ++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 13 deletions(-)
check +59 -13
@@ -275,6 +275,14 @@ _prepare_test_list() rm -f $tmp.list } +deprecated_opt_warn() +{ + local old=$1 + shift + + echo "[WARN] $old is deprecated, replace it with $*" +} + # Backward compatible with the old options mode. Translate word-style options # that getopt would misinterpret into long options. compat_old_option()
@@ -282,19 +290,57 @@ compat_old_option() check_args=() while [ $# -gt 0 ]; do case "$1" in - -nfs) check_args+=("--fs" "nfs") ;; - -afs) check_args+=("--fs" "afs") ;; - -glusterfs) check_args+=("--fs" "glusterfs") ;; - -cifs) check_args+=("--fs" "cifs") ;; - -9p) check_args+=("--fs" "9p") ;; - -fuse) check_args+=("--fs" "fuse") ;; - -virtiofs) check_args+=("--fs" "virtiofs") ;; - -pvfs2) check_args+=("--fs" "pvfs2") ;; - -tmpfs) check_args+=("--fs" "tmpfs") ;; - -ubifs) check_args+=("--fs" "ubifs") ;; - -overlay) check_args+=("--fs" "overlay") ;; - -udiff) check_args+=("--udiff") ;; - *) check_args+=("$1") ;; + -nfs) + check_args+=("--fs" "nfs") + deprecated_opt_warn "-nfs" "--fs nfs" + ;; + -afs) + check_args+=("--fs" "afs") + deprecated_opt_warn "-afs" "--fs afs" + ;; + -glusterfs) + check_args+=("--fs" "glusterfs") + deprecated_opt_warn "-glusterfs" "--fs glusterfs" + ;; + -cifs) + check_args+=("--fs" "cifs") + deprecated_opt_warn "-cifs" "--fs cifs" + ;; + -9p) + check_args+=("--fs" "9p") + deprecated_opt_warn "-9p" "--fs 9p" + ;; + -fuse) + check_args+=("--fs" "fuse") + deprecated_opt_warn "-fuse" "--fs fuse" + ;; + -virtiofs) + check_args+=("--fs" "virtiofs") + deprecated_opt_warn "-virtiofs" "--fs virtiofs" + ;; + -pvfs2) + check_args+=("--fs" "pvfs2") + deprecated_opt_warn "-pvfs2" "--fs pvfs2" + ;; + -tmpfs) + check_args+=("--fs" "tmpfs") + deprecated_opt_warn "-tmpfs" "--fs tmpfs" + ;; + -ubifs) + check_args+=("--fs" "ubifs") + deprecated_opt_warn "-ubifs" "--fs ubifs" + ;; + -overlay) + check_args+=("--fs" "overlay") + deprecated_opt_warn "-overlay" "--fs overlay" + ;; + -udiff) + check_args+=("--udiff") + deprecated_opt_warn "-udiff" "--udiff" + ;; + *) + check_args+=("$1") + ;; esac shift done
Signature · 1 line
2.54.0
Re: [RFC PATCH 4/4] check: add deprecated options warning
Quoted 5 lines · Zorro Lang
To notify xfstests users of deprecated options, add a warning which does not interfere with test results or golden output.
Signed-off-by Zorro Lang <[email protected]>---
Looks good, feel free to add:
Regards,
ojaswin
Quoted 96 lines
check | 72 ++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 13 deletions(-)check +59
-13@@ -275,6 +275,14 @@ _prepare_test_list() rm -f $tmp.list } +deprecated_opt_warn() +{ + local old=$1 + shift + + echo "[WARN] $old is deprecated, replace it with $*" +} + # Backward compatible with the old options mode. Translate word-style options # that getopt would misinterpret into long options. compat_old_option()@@ -282,19 +290,57 @@ compat_old_option() check_args=() while [ $# -gt 0 ]; do case "$1" in - -nfs) check_args+=("--fs" "nfs") ;; - -afs) check_args+=("--fs" "afs") ;; - -glusterfs) check_args+=("--fs" "glusterfs") ;; - -cifs) check_args+=("--fs" "cifs") ;; - -9p) check_args+=("--fs" "9p") ;; - -fuse) check_args+=("--fs" "fuse") ;; - -virtiofs) check_args+=("--fs" "virtiofs") ;; - -pvfs2) check_args+=("--fs" "pvfs2") ;; - -tmpfs) check_args+=("--fs" "tmpfs") ;; - -ubifs) check_args+=("--fs" "ubifs") ;; - -overlay) check_args+=("--fs" "overlay") ;; - -udiff) check_args+=("--udiff") ;; - *) check_args+=("$1") ;; + -nfs) + check_args+=("--fs" "nfs") + deprecated_opt_warn "-nfs" "--fs nfs" + ;; + -afs) + check_args+=("--fs" "afs") + deprecated_opt_warn "-afs" "--fs afs" + ;; + -glusterfs) + check_args+=("--fs" "glusterfs") + deprecated_opt_warn "-glusterfs" "--fs glusterfs" + ;; + -cifs) + check_args+=("--fs" "cifs") + deprecated_opt_warn "-cifs" "--fs cifs" + ;; + -9p) + check_args+=("--fs" "9p") + deprecated_opt_warn "-9p" "--fs 9p" + ;; + -fuse) + check_args+=("--fs" "fuse") + deprecated_opt_warn "-fuse" "--fs fuse" + ;; + -virtiofs) + check_args+=("--fs" "virtiofs") + deprecated_opt_warn "-virtiofs" "--fs virtiofs" + ;; + -pvfs2) + check_args+=("--fs" "pvfs2") + deprecated_opt_warn "-pvfs2" "--fs pvfs2" + ;; + -tmpfs) + check_args+=("--fs" "tmpfs") + deprecated_opt_warn "-tmpfs" "--fs tmpfs" + ;; + -ubifs) + check_args+=("--fs" "ubifs") + deprecated_opt_warn "-ubifs" "--fs ubifs" + ;; + -overlay) + check_args+=("--fs" "overlay") + deprecated_opt_warn "-overlay" "--fs overlay" + ;; + -udiff) + check_args+=("--udiff") + deprecated_opt_warn "-udiff" "--udiff" + ;; + *) + check_args+=("$1") + ;; esac shift doneSignature · 1 line
2.54.0
Friendly ping ...
Any review points about this patchset :)
Thanks,
Zorro
Quoted 44 lines · Zorro Lang
The patchset here were motivated by a previous RFC discussion regarding:
https://lore.kernel.org/fstests/afzmt7SFA4jWhi6U@zlang-mailbox/T/#tThis patchset refactors the argument parsing logic in the 'check' script. The current positional parameter handling is becoming hard to maintain as we add more options.
I've replaced the manual parsing loop with *getopt* to provide a more standard CLI experience, and ensured the functionality remains identical to the previous implementation.
Besides that, I also tried to make below 3 changes:
1) Introduced --fs <fstyp> option, to replace all those filesystem-specific options, e.g. -nfs, -overlay, -cifs and so on.
2) Updated all long-format options to strictly use the double-dash (--) prefix.
3) For backward compatibility, I tried to support legacy non-standard options to ensure existing user workflows aren't broken. A deprecation warning is now issued when these old options are used.I hope this patchset can facilitate future additions and adjustments to arguments, making the code logic cleaner and more standardized.
Any concerns or review points, please feel free to tell me :)
Thanks,
ZorroZorro Lang (4):
check: refactor argument parsing with getopt
check: update usage and README to reflect new argument parsing
check: consolidate argument handling into function
check: add deprecated options warningREADME | 10 +- README.overlay | 18 +- check | 435 ++++++++++++++++++++++++++++++++----------------- common/config | 8 +- common/rc | 2 +- 5 files changed, 303 insertions(+), 170 deletions(-)Signature · 1 line
2.54.0