From: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
To: "Nirjhar Roy (IBM)" <nirjhar.roy.lists@gmail.com>,
fstests@vger.kernel.org
Cc: linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org,
ojaswin@linux.ibm.com, djwong@kernel.org, zlang@kernel.org,
david@fromorbit.com, nirjhar.roy.lists@gmail.com
Subject: Re: [PATCH v2 4/5] common/config: Introduce _exit wrapper around exit command
Date: Fri, 04 Apr 2025 10:33:46 +0530 [thread overview]
Message-ID: <87o6xcv7pp.fsf@gmail.com> (raw)
In-Reply-To: <80bb7e56ff00101c6bad6c882da631a20b09b6ad.1743487913.git.nirjhar.roy.lists@gmail.com>
"Nirjhar Roy (IBM)" <nirjhar.roy.lists@gmail.com> writes:
> We should always set the value of status correctly when we are exiting.
> Else, "$?" might not give us the correct value.
> If we see the following trap
> handler registration in the check script:
>
> if $OPTIONS_HAVE_SECTIONS; then
> trap "_kill_seq; _summary; exit \$status" 0 1 2 3 15
> else
> trap "_kill_seq; _wrapup; exit \$status" 0 1 2 3 15
> fi
>
> So, "exit 1" will exit the check script without setting the correct
> return value. I ran with the following local.config file:
>
> [xfs_4k_valid]
> FSTYP=xfs
> TEST_DEV=/dev/loop0
> TEST_DIR=/mnt1/test
> SCRATCH_DEV=/dev/loop1
> SCRATCH_MNT=/mnt1/scratch
>
> [xfs_4k_invalid]
> FSTYP=xfs
> TEST_DEV=/dev/loop0
> TEST_DIR=/mnt1/invalid_dir
> SCRATCH_DEV=/dev/loop1
> SCRATCH_MNT=/mnt1/scratch
>
> This caused the init_rc() to catch the case of invalid _test_mount
> options. Although the check script correctly failed during the execution
> of the "xfs_4k_invalid" section, the return value was 0, i.e "echo $?"
> returned 0. This is because init_rc exits with "exit 1" without
> correctly setting the value of "status". IMO, the correct behavior
> should have been that "$?" should have been non-zero.
Nice catch. Feel free to add:
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
>
> The next patch will replace exit with _exit.
>
> Signed-off-by: Nirjhar Roy (IBM) <nirjhar.roy.lists@gmail.com>
> ---
> common/config | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/common/config b/common/config
> index 79bec87f..eb6af35a 100644
> --- a/common/config
> +++ b/common/config
> @@ -96,6 +96,14 @@ 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.
> +_exit()
> +{
> + status="$1"
> + exit "$status"
> +}
> +
> # Handle mkfs.$fstyp which does (or does not) require -f to overwrite
> set_mkfs_prog_path_with_opts()
> {
> --
> 2.34.1
next prev parent reply other threads:[~2025-04-04 5:04 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 6:43 [PATCH v2 0/5] Minor cleanups in common/ Nirjhar Roy (IBM)
2025-04-01 6:43 ` [PATCH v2 1/5] generic/749: Remove redundant sourcing of common/rc Nirjhar Roy (IBM)
2025-04-04 3:31 ` Ritesh Harjani
2025-04-01 6:43 ` [PATCH v2 2/5] check: Remove redundant _test_mount in check Nirjhar Roy (IBM)
2025-04-04 3:36 ` Ritesh Harjani
2025-04-08 5:41 ` Nirjhar Roy (IBM)
2025-04-08 5:45 ` Nirjhar Roy (IBM)
2025-04-01 6:43 ` [PATCH v2 3/5] check,common{rc,preamble}: Decouple init_rc() call from sourcing common/rc Nirjhar Roy (IBM)
2025-04-04 4:00 ` Ritesh Harjani
2025-04-04 4:52 ` Nirjhar Roy (IBM)
2025-04-08 5:42 ` Nirjhar Roy (IBM)
2025-04-01 6:43 ` [PATCH v2 4/5] common/config: Introduce _exit wrapper around exit command Nirjhar Roy (IBM)
2025-04-04 5:03 ` Ritesh Harjani [this message]
2025-04-01 6:44 ` [PATCH v2 5/5] common: exit --> _exit Nirjhar Roy (IBM)
2025-04-04 5:04 ` Ritesh Harjani
2025-04-07 16:19 ` Zorro Lang
2025-04-07 18:46 ` Ritesh Harjani
2025-04-07 19:12 ` Darrick J. Wong
2025-04-07 19:19 ` Nirjhar Roy (IBM)
2025-04-07 19:13 ` Nirjhar Roy (IBM)
2025-04-08 14:27 ` Zorro Lang
2025-04-08 14:33 ` Darrick J. Wong
2025-04-08 16:25 ` Nirjhar Roy (IBM)
2025-04-07 18:59 ` Nirjhar Roy (IBM)
2025-04-01 21:37 ` [PATCH v2 0/5] Minor cleanups in common/ Dave Chinner
2025-04-04 14:31 ` Nirjhar Roy (IBM)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o6xcv7pp.fsf@gmail.com \
--to=ritesh.list@gmail.com \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=nirjhar.roy.lists@gmail.com \
--cc=ojaswin@linux.ibm.com \
--cc=zlang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox