[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4132df90-a2d6-4d2e-a5e9-5ff893a25025@gmail.com>
Date: Tue, 29 Apr 2025 19:37:24 +0530
From: "Nirjhar Roy (IBM)" <nirjhar.roy.lists@...il.com>
To: fstests@...r.kernel.org
Cc: linux-ext4@...r.kernel.org, linux-xfs@...r.kernel.org,
ritesh.list@...il.com, ojaswin@...ux.ibm.com, djwong@...nel.org,
zlang@...nel.org, david@...morbit.com
Subject: Re: [PATCH v2 1/2] common: Move exit related functions to a
common/exit
On 4/29/25 12:22, Nirjhar Roy (IBM) wrote:
> Introduce a new file common/exit that will contain all the exit
> related functions. This will remove the dependencies these functions
> have on other non-related helper files and they can be indepedently
> sourced. This was suggested by Dave Chinner[1].
Sorry, I didn't notice this earlier. A similar change[c1] was already
posted by Dave.
[c1]
https://lore.kernel.org/all/20250417031208.1852171-4-david@fromorbit.com/
--NR
>
> [1] https://lore.kernel.org/linux-xfs/Z_UJ7XcpmtkPRhTr@dread.disaster.area/
> Suggested-by: Dave Chinner <david@...morbit.com>
> Signed-off-by: Nirjhar Roy (IBM) <nirjhar.roy.lists@...il.com>
> ---
> common/config | 17 +----------------
> common/exit | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
> common/preamble | 1 +
> common/punch | 5 -----
> common/rc | 28 ---------------------------
> 5 files changed, 52 insertions(+), 49 deletions(-)
> create mode 100644 common/exit
>
> diff --git a/common/config b/common/config
> index eada3971..6a60d144 100644
> --- a/common/config
> +++ b/common/config
> @@ -38,7 +38,7 @@
> # - this script shouldn't make any assertions about filesystem
> # validity or mountedness.
> #
> -
> +. common/exit
> . common/test_names
>
> # all tests should use a common language setting to prevent golden
> @@ -96,15 +96,6 @@ export LOCAL_CONFIGURE_OPTIONS=${LOCAL_CONFIGURE_OPTIONS:=--enable-readline=yes}
>
> export RECREATE_TEST_DEV=${RECREATE_TEST_DEV:=false}
>
> -# This functions sets the exit code to status and then exits. Don't use
> -# exit directly, as it might not set the value of "$status" correctly, which is
> -# used as an exit code in the trap handler routine set up by the check script.
> -_exit()
> -{
> - test -n "$1" && status="$1"
> - exit "$status"
> -}
> -
> # Handle mkfs.$fstyp which does (or does not) require -f to overwrite
> set_mkfs_prog_path_with_opts()
> {
> @@ -121,12 +112,6 @@ set_mkfs_prog_path_with_opts()
> fi
> }
>
> -_fatal()
> -{
> - echo "$*"
> - _exit 1
> -}
> -
> export MKFS_PROG="$(type -P mkfs)"
> [ "$MKFS_PROG" = "" ] && _fatal "mkfs not found"
>
> diff --git a/common/exit b/common/exit
> new file mode 100644
> index 00000000..ad7e7498
> --- /dev/null
> +++ b/common/exit
> @@ -0,0 +1,50 @@
> +##/bin/bash
> +
> +# This functions sets the exit code to status and then exits. Don't use
> +# exit directly, as it might not set the value of "$status" correctly, which is
> +# used as an exit code in the trap handler routine set up by the check script.
> +_exit()
> +{
> + test -n "$1" && status="$1"
> + exit "$status"
> +}
> +
> +_fatal()
> +{
> + echo "$*"
> + _exit 1
> +}
> +
> +_die()
> +{
> + echo $@
> + _exit 1
> +}
> +
> +die_now()
> +{
> + _exit 1
> +}
> +
> +# just plain bail out
> +#
> +_fail()
> +{
> + echo "$*" | tee -a $seqres.full
> + echo "(see $seqres.full for details)"
> + _exit 1
> +}
> +
> +# bail out, setting up .notrun file. Need to kill the filesystem check files
> +# here, otherwise they are set incorrectly for the next test.
> +#
> +_notrun()
> +{
> + echo "$*" > $seqres.notrun
> + echo "$seq not run: $*"
> + rm -f ${RESULT_DIR}/require_test*
> + rm -f ${RESULT_DIR}/require_scratch*
> +
> + _exit 0
> +}
> +
> diff --git a/common/preamble b/common/preamble
> index ba029a34..9b6b4b26 100644
> --- a/common/preamble
> +++ b/common/preamble
> @@ -33,6 +33,7 @@ _register_cleanup()
> # explicitly as a member of the 'all' group.
> _begin_fstest()
> {
> + . common/exit
> if [ -n "$seq" ]; then
> echo "_begin_fstest can only be called once!"
> _exit 1
> diff --git a/common/punch b/common/punch
> index 64d665d8..4e8ebcd7 100644
> --- a/common/punch
> +++ b/common/punch
> @@ -222,11 +222,6 @@ _filter_bmap()
> _coalesce_extents
> }
>
> -die_now()
> -{
> - _exit 1
> -}
> -
> # test the different corner cases for zeroing a range:
> #
> # 1. into a hole
> diff --git a/common/rc b/common/rc
> index 9bed6dad..fac9b6da 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -1798,28 +1798,6 @@ _do()
> return $ret
> }
>
> -# bail out, setting up .notrun file. Need to kill the filesystem check files
> -# here, otherwise they are set incorrectly for the next test.
> -#
> -_notrun()
> -{
> - echo "$*" > $seqres.notrun
> - echo "$seq not run: $*"
> - rm -f ${RESULT_DIR}/require_test*
> - rm -f ${RESULT_DIR}/require_scratch*
> -
> - _exit 0
> -}
> -
> -# just plain bail out
> -#
> -_fail()
> -{
> - echo "$*" | tee -a $seqres.full
> - echo "(see $seqres.full for details)"
> - _exit 1
> -}
> -
> #
> # Tests whether $FSTYP should be exclude from this test.
> #
> @@ -3835,12 +3813,6 @@ _link_out_file()
> _link_out_file_named $seqfull.out "$features"
> }
>
> -_die()
> -{
> - echo $@
> - _exit 1
> -}
> -
> # convert urandom incompressible data to compressible text data
> _ddt()
> {
--
Nirjhar Roy
Linux Kernel Developer
IBM, Bangalore
Powered by blists - more mailing lists