* [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup
@ 2025-11-07 10:29 Petr Vorel
2025-11-07 10:29 ` [LTP] [PATCH 1/8] tst_test.c: Fix tst_check_cmd() use Petr Vorel
` (8 more replies)
0 siblings, 9 replies; 18+ messages in thread
From: Petr Vorel @ 2025-11-07 10:29 UTC (permalink / raw)
To: ltp
Hi,
the only important change is the first commit.
Kind regards,
Petr
Petr Vorel (7):
tst_test.c: Fix tst_check_cmd() use
tst_test.c: Change check_kver() return type to bool
tst_test.c: Change results_equal() return type to bool
tst_test.c: Change needs_tmpdir() return type to bool
tst_test.c: Change run_tcases_per_fs() return type to void
tst_test.c: Change run_tcase_on_fs() return type to void
tst_test.c: Change fork_testrun() return type to void
Wei Gao (1):
tst_cmd.c: Check brk_nosupp when tst_get_path failed
include/tst_private.h | 5 ++++
lib/tst_cmd.c | 10 +++++--
lib/tst_test.c | 61 +++++++++++++++++++++++--------------------
3 files changed, 45 insertions(+), 31 deletions(-)
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* [LTP] [PATCH 1/8] tst_test.c: Fix tst_check_cmd() use
2025-11-07 10:29 [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup Petr Vorel
@ 2025-11-07 10:29 ` Petr Vorel
2025-11-08 7:16 ` Wei Gao via ltp
2025-11-14 8:49 ` Avinesh Kumar
2025-11-07 10:29 ` [LTP] [PATCH 2/8] tst_cmd.c: Check brk_nosupp when tst_get_path failed Petr Vorel
` (7 subsequent siblings)
8 siblings, 2 replies; 18+ messages in thread
From: Petr Vorel @ 2025-11-07 10:29 UTC (permalink / raw)
To: ltp
9bb94efa39 changed tst_check_cmd() from int to bool. But it reverted the
values (0 became true), which logical (false means not supported) than
the original return codes from 257394e4e3. But then the only use of
tst_check_cmd() needs to update to expect false instead of true.
Also document the return code in tst_private.h.
Fixes: 9bb94efa39 ("tst_cmd: Change tst_check_cmd() return type to int")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Fixing my own error.
include/tst_private.h | 5 +++++
lib/tst_test.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/tst_private.h b/include/tst_private.h
index 87ec8829a1..482b68fba2 100644
--- a/include/tst_private.h
+++ b/include/tst_private.h
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
+ * Copyright (c) Linux Test Project, 2020-2025
* Copyright (c) 2017-2019 Petr Vorel <pvorel@suse.cz>
*
* Internal helper functions for the shell library. Do not use directly
@@ -41,9 +42,13 @@ char tst_kconfig_get(const char *confname);
/*
* If cmd argument is a single command, this function just checks command
* whether exists. If not, case breaks if brk_nosupp is defined.
+ *
* If cmd argument is a complex string ie 'mkfs.ext4 >= 1.43.0', this
* function checks command version whether meets this requirement.
* If not, case breaks if brk_nosupp is defined.
+ *
+ * return: true if command presented, optionally with high enough version, false
+ * otherwise.
*/
bool tst_check_cmd(const char *cmd, const int brk_nosupp);
diff --git a/lib/tst_test.c b/lib/tst_test.c
index da5314c502..bda66c4672 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1960,7 +1960,7 @@ static int run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
tst_res(TINFO, "=== Testing on %s ===", fs_type);
tdev.fs_type = fs_type;
- if (fs->mkfs_ver && tst_check_cmd(fs->mkfs_ver, 0))
+ if (fs->mkfs_ver && !tst_check_cmd(fs->mkfs_ver, 0))
return TCONF;
if (fs->min_kver && check_kver(fs->min_kver, 0))
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [LTP] [PATCH 2/8] tst_cmd.c: Check brk_nosupp when tst_get_path failed
2025-11-07 10:29 [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup Petr Vorel
2025-11-07 10:29 ` [LTP] [PATCH 1/8] tst_test.c: Fix tst_check_cmd() use Petr Vorel
@ 2025-11-07 10:29 ` Petr Vorel
2025-11-08 7:20 ` Wei Gao via ltp
2025-11-07 10:29 ` [LTP] [PATCH 3/8] tst_test.c: Change check_kver() return type to bool Petr Vorel
` (6 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2025-11-07 10:29 UTC (permalink / raw)
To: ltp
From: Wei Gao <wegao@suse.com>
Fixes: 257394e4e3 ("Filter mkfs version in tst_fs")
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Wei Gao <wegao@suse.com>
[ pvorel: fix return value: 1 => false ]
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
NOTE: this replaces Wei's patch
https://patchwork.ozlabs.org/project/ltp/patch/20251107003041.28929-2-wegao@suse.com/
https://lore.kernel.org/ltp/20251107003041.28929-2-wegao@suse.com/
lib/tst_cmd.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/tst_cmd.c b/lib/tst_cmd.c
index 2faf7c7430..79f547ab5d 100644
--- a/lib/tst_cmd.c
+++ b/lib/tst_cmd.c
@@ -265,8 +265,14 @@ bool tst_check_cmd(const char *cmd, const int brk_nosupp)
version_token = strtok_r(NULL, " ", &next);
str = strtok_r(NULL, " ", &next);
- if (tst_get_path(cmd_token, path, sizeof(path)))
- tst_brkm(TCONF, NULL, "Couldn't find '%s' in $PATH", cmd_token);
+ if (tst_get_path(cmd_token, path, sizeof(path))) {
+ if (brk_nosupp) {
+ tst_brkm(TCONF, NULL, "Couldn't find '%s' in $PATH", cmd_token);
+ } else {
+ tst_resm(TCONF, "Couldn't find '%s' in $PATH", cmd_token);
+ return false;
+ }
+ }
if (!op_token)
return true;
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [LTP] [PATCH 3/8] tst_test.c: Change check_kver() return type to bool
2025-11-07 10:29 [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup Petr Vorel
2025-11-07 10:29 ` [LTP] [PATCH 1/8] tst_test.c: Fix tst_check_cmd() use Petr Vorel
2025-11-07 10:29 ` [LTP] [PATCH 2/8] tst_cmd.c: Check brk_nosupp when tst_get_path failed Petr Vorel
@ 2025-11-07 10:29 ` Petr Vorel
2025-11-14 8:53 ` Avinesh Kumar
2025-11-07 10:29 ` [LTP] [PATCH 4/8] tst_test.c: Change results_equal() " Petr Vorel
` (5 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2025-11-07 10:29 UTC (permalink / raw)
To: ltp
Also change the value (0 becomes true), add docs (don't use kerneldoc as
this is a internal function which does not need to be in LTP online doc).
While at it, add missing static.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
lib/tst_test.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index bda66c4672..1725844b54 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1056,7 +1056,12 @@ static void do_exit(int ret)
exit(ret);
}
-int check_kver(const char *min_kver, const int brk_nosupp)
+/*
+ * Check for the required kernel version.
+ *
+ * return: true if the kernel version is high enough, false otherwise.
+ */
+static bool check_kver(const char *min_kver, const int brk_nosupp)
{
char *msg;
int v1, v2, v3;
@@ -1075,10 +1080,10 @@ int check_kver(const char *min_kver, const int brk_nosupp)
else
tst_res(TCONF, msg, min_kver);
- return 1;
+ return false;
}
- return 0;
+ return true;
}
static int results_equal(struct results *a, struct results *b)
@@ -1963,7 +1968,7 @@ static int run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
if (fs->mkfs_ver && !tst_check_cmd(fs->mkfs_ver, 0))
return TCONF;
- if (fs->min_kver && check_kver(fs->min_kver, 0))
+ if (fs->min_kver && !check_kver(fs->min_kver, 0))
return TCONF;
prepare_device(fs);
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [LTP] [PATCH 4/8] tst_test.c: Change results_equal() return type to bool
2025-11-07 10:29 [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup Petr Vorel
` (2 preceding siblings ...)
2025-11-07 10:29 ` [LTP] [PATCH 3/8] tst_test.c: Change check_kver() return type to bool Petr Vorel
@ 2025-11-07 10:29 ` Petr Vorel
2025-11-07 10:29 ` [LTP] [PATCH 5/8] tst_test.c: Change needs_tmpdir() " Petr Vorel
` (4 subsequent siblings)
8 siblings, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2025-11-07 10:29 UTC (permalink / raw)
To: ltp
Also add doc (don't use kerneldoc as this is a internal function which
does not need to be in LTP online doc).
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
lib/tst_test.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 1725844b54..449ddb6ba5 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1086,21 +1086,26 @@ static bool check_kver(const char *min_kver, const int brk_nosupp)
return true;
}
-static int results_equal(struct results *a, struct results *b)
+/*
+ * Checks if the struct results values are equal.
+ *
+ * return: true if results are equal, false otherwise.
+ */
+static bool results_equal(struct results *a, struct results *b)
{
if (a->passed != b->passed)
- return 0;
+ return false;
if (a->failed != b->failed)
- return 0;
+ return false;
if (a->skipped != b->skipped)
- return 0;
+ return false;
if (a->broken != b->broken)
- return 0;
+ return false;
- return 1;
+ return true;
}
static int needs_tmpdir(void)
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [LTP] [PATCH 5/8] tst_test.c: Change needs_tmpdir() return type to bool
2025-11-07 10:29 [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup Petr Vorel
` (3 preceding siblings ...)
2025-11-07 10:29 ` [LTP] [PATCH 4/8] tst_test.c: Change results_equal() " Petr Vorel
@ 2025-11-07 10:29 ` Petr Vorel
2025-11-07 10:29 ` [LTP] [PATCH 6/8] tst_test.c: Change run_tcases_per_fs() return type to void Petr Vorel
` (3 subsequent siblings)
8 siblings, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2025-11-07 10:29 UTC (permalink / raw)
To: ltp
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
lib/tst_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 449ddb6ba5..05d8e59894 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1108,7 +1108,7 @@ static bool results_equal(struct results *a, struct results *b)
return true;
}
-static int needs_tmpdir(void)
+static bool needs_tmpdir(void)
{
return tst_test->needs_tmpdir ||
tst_test->needs_device ||
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [LTP] [PATCH 6/8] tst_test.c: Change run_tcases_per_fs() return type to void
2025-11-07 10:29 [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup Petr Vorel
` (4 preceding siblings ...)
2025-11-07 10:29 ` [LTP] [PATCH 5/8] tst_test.c: Change needs_tmpdir() " Petr Vorel
@ 2025-11-07 10:29 ` Petr Vorel
2025-11-07 10:29 ` [LTP] [PATCH 7/8] tst_test.c: Change run_tcase_on_fs() " Petr Vorel
` (2 subsequent siblings)
8 siblings, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2025-11-07 10:29 UTC (permalink / raw)
To: ltp
Return code is not used any more.
Fixes: a1f82704c2 ("lib/tst_test.c: Fix tst_brk() handling")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
lib/tst_test.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 05d8e59894..c1a1abf7fb 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1988,9 +1988,8 @@ static int run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
return ret;
}
-static int run_tcases_per_fs(void)
+static void run_tcases_per_fs(void)
{
- int ret = 0;
unsigned int i;
bool found_valid_fs = false;
const char *const *filesystems = tst_get_supported_fs_types(tst_test->skip_filesystems);
@@ -2013,8 +2012,6 @@ static int run_tcases_per_fs(void)
if (!found_valid_fs)
tst_brk(TCONF, "No required filesystems are available");
-
- return ret;
}
unsigned int tst_variant;
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [LTP] [PATCH 7/8] tst_test.c: Change run_tcase_on_fs() return type to void
2025-11-07 10:29 [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup Petr Vorel
` (5 preceding siblings ...)
2025-11-07 10:29 ` [LTP] [PATCH 6/8] tst_test.c: Change run_tcases_per_fs() return type to void Petr Vorel
@ 2025-11-07 10:29 ` Petr Vorel
2025-11-07 10:29 ` [LTP] [PATCH 8/8] tst_test.c: Change fork_testrun() " Petr Vorel
2025-11-10 7:18 ` [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup Li Wang via ltp
8 siblings, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2025-11-07 10:29 UTC (permalink / raw)
To: ltp
Return code is not used any more.
Fixes: a1f82704c2 ("lib/tst_test.c: Fix tst_brk() handling")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
lib/tst_test.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index c1a1abf7fb..8098b3a010 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1963,29 +1963,27 @@ ret:
return &tst_test->filesystems[0];
}
-static int run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
+static void run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
{
- int ret;
-
tst_res(TINFO, "=== Testing on %s ===", fs_type);
tdev.fs_type = fs_type;
if (fs->mkfs_ver && !tst_check_cmd(fs->mkfs_ver, 0))
- return TCONF;
+ return;
if (fs->min_kver && !check_kver(fs->min_kver, 0))
- return TCONF;
+ return;
prepare_device(fs);
- ret = fork_testrun();
+ fork_testrun();
if (context->mntpoint_mounted) {
tst_umount(tst_test->mntpoint);
context->mntpoint_mounted = 0;
}
- return ret;
+ return;
}
static void run_tcases_per_fs(void)
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [LTP] [PATCH 8/8] tst_test.c: Change fork_testrun() return type to void
2025-11-07 10:29 [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup Petr Vorel
` (6 preceding siblings ...)
2025-11-07 10:29 ` [LTP] [PATCH 7/8] tst_test.c: Change run_tcase_on_fs() " Petr Vorel
@ 2025-11-07 10:29 ` Petr Vorel
2025-11-14 8:55 ` Avinesh Kumar
2025-11-10 7:18 ` [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup Li Wang via ltp
8 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2025-11-07 10:29 UTC (permalink / raw)
To: ltp
Return code is not used any more.
Fixes: a1f82704c2 ("lib/tst_test.c: Fix tst_brk() handling")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
lib/tst_test.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 8098b3a010..e115ce689d 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1880,7 +1880,7 @@ void tst_set_runtime(int runtime)
heartbeat();
}
-static int fork_testrun(void)
+static void fork_testrun(void)
{
int status;
@@ -1911,8 +1911,8 @@ static int fork_testrun(void)
SAFE_SIGNAL(SIGINT, SIG_DFL);
if (tst_test->taint_check && tst_taint_check()) {
- tst_res(TFAIL, "Kernel is now tainted.");
- return TFAIL;
+ tst_res(TFAIL, "Kernel is now tainted");
+ return;
}
if (tst_test->forks_child && kill(-test_pid, SIGKILL) == 0)
@@ -1922,7 +1922,7 @@ static int fork_testrun(void)
tst_brk(TBROK, "Child returned with %i", WEXITSTATUS(status));
if (context->abort_flag)
- return 0;
+ return;
if (WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL) {
tst_res(TINFO, "If you are running on slow machine, "
@@ -1932,8 +1932,6 @@ static int fork_testrun(void)
if (WIFSIGNALED(status))
tst_brk(TBROK, "Test killed by %s!", tst_strsig(WTERMSIG(status)));
-
- return 0;
}
static struct tst_fs *lookup_fs_desc(const char *fs_type, int all_filesystems)
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH 1/8] tst_test.c: Fix tst_check_cmd() use
2025-11-07 10:29 ` [LTP] [PATCH 1/8] tst_test.c: Fix tst_check_cmd() use Petr Vorel
@ 2025-11-08 7:16 ` Wei Gao via ltp
2025-11-14 8:49 ` Avinesh Kumar
1 sibling, 0 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2025-11-08 7:16 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Fri, Nov 07, 2025 at 11:29:32AM +0100, Petr Vorel wrote:
> 9bb94efa39 changed tst_check_cmd() from int to bool. But it reverted the
> values (0 became true), which logical (false means not supported) than
> the original return codes from 257394e4e3. But then the only use of
> tst_check_cmd() needs to update to expect false instead of true.
>
> Also document the return code in tst_private.h.
>
> Fixes: 9bb94efa39 ("tst_cmd: Change tst_check_cmd() return type to int")
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Fixing my own error.
>
> include/tst_private.h | 5 +++++
> lib/tst_test.c | 2 +-
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/include/tst_private.h b/include/tst_private.h
> index 87ec8829a1..482b68fba2 100644
> --- a/include/tst_private.h
> +++ b/include/tst_private.h
> @@ -1,5 +1,6 @@
> // SPDX-License-Identifier: GPL-2.0-or-later
> /*
> + * Copyright (c) Linux Test Project, 2020-2025
> * Copyright (c) 2017-2019 Petr Vorel <pvorel@suse.cz>
> *
> * Internal helper functions for the shell library. Do not use directly
> @@ -41,9 +42,13 @@ char tst_kconfig_get(const char *confname);
> /*
> * If cmd argument is a single command, this function just checks command
> * whether exists. If not, case breaks if brk_nosupp is defined.
> + *
> * If cmd argument is a complex string ie 'mkfs.ext4 >= 1.43.0', this
> * function checks command version whether meets this requirement.
> * If not, case breaks if brk_nosupp is defined.
> + *
> + * return: true if command presented, optionally with high enough version, false
> + * otherwise.
> */
> bool tst_check_cmd(const char *cmd, const int brk_nosupp);
>
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index da5314c502..bda66c4672 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -1960,7 +1960,7 @@ static int run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
> tst_res(TINFO, "=== Testing on %s ===", fs_type);
> tdev.fs_type = fs_type;
>
> - if (fs->mkfs_ver && tst_check_cmd(fs->mkfs_ver, 0))
> + if (fs->mkfs_ver && !tst_check_cmd(fs->mkfs_ver, 0))
> return TCONF;
>
> if (fs->min_kver && check_kver(fs->min_kver, 0))
Reviewed-by: Wei Gao <wegao@suse.com>
> --
> 2.51.0
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH 2/8] tst_cmd.c: Check brk_nosupp when tst_get_path failed
2025-11-07 10:29 ` [LTP] [PATCH 2/8] tst_cmd.c: Check brk_nosupp when tst_get_path failed Petr Vorel
@ 2025-11-08 7:20 ` Wei Gao via ltp
0 siblings, 0 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2025-11-08 7:20 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Fri, Nov 07, 2025 at 11:29:33AM +0100, Petr Vorel wrote:
> From: Wei Gao <wegao@suse.com>
>
> Fixes: 257394e4e3 ("Filter mkfs version in tst_fs")
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> Signed-off-by: Wei Gao <wegao@suse.com>
> [ pvorel: fix return value: 1 => false ]
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> NOTE: this replaces Wei's patch
> https://patchwork.ozlabs.org/project/ltp/patch/20251107003041.28929-2-wegao@suse.com/
> https://lore.kernel.org/ltp/20251107003041.28929-2-wegao@suse.com/
>
> lib/tst_cmd.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/lib/tst_cmd.c b/lib/tst_cmd.c
> index 2faf7c7430..79f547ab5d 100644
> --- a/lib/tst_cmd.c
> +++ b/lib/tst_cmd.c
> @@ -265,8 +265,14 @@ bool tst_check_cmd(const char *cmd, const int brk_nosupp)
> version_token = strtok_r(NULL, " ", &next);
> str = strtok_r(NULL, " ", &next);
>
> - if (tst_get_path(cmd_token, path, sizeof(path)))
> - tst_brkm(TCONF, NULL, "Couldn't find '%s' in $PATH", cmd_token);
> + if (tst_get_path(cmd_token, path, sizeof(path))) {
> + if (brk_nosupp) {
> + tst_brkm(TCONF, NULL, "Couldn't find '%s' in $PATH", cmd_token);
> + } else {
> + tst_resm(TCONF, "Couldn't find '%s' in $PATH", cmd_token);
> + return false;
> + }
> + }
>
> if (!op_token)
> return true;
Reviewed-by: Wei Gao <wegao@suse.com>
> --
> 2.51.0
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup
2025-11-07 10:29 [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup Petr Vorel
` (7 preceding siblings ...)
2025-11-07 10:29 ` [LTP] [PATCH 8/8] tst_test.c: Change fork_testrun() " Petr Vorel
@ 2025-11-10 7:18 ` Li Wang via ltp
8 siblings, 0 replies; 18+ messages in thread
From: Li Wang via ltp @ 2025-11-10 7:18 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi Petr,
Nice cleanup work!
Reviewed-by: Li Wang <liwang@redhat.com>
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH 1/8] tst_test.c: Fix tst_check_cmd() use
2025-11-07 10:29 ` [LTP] [PATCH 1/8] tst_test.c: Fix tst_check_cmd() use Petr Vorel
2025-11-08 7:16 ` Wei Gao via ltp
@ 2025-11-14 8:49 ` Avinesh Kumar
1 sibling, 0 replies; 18+ messages in thread
From: Avinesh Kumar @ 2025-11-14 8:49 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Friday, November 7, 2025 11:29:32 AM CET Petr Vorel wrote:
> 9bb94efa39 changed tst_check_cmd() from int to bool. But it reverted the
> values (0 became true), which logical (false means not supported) than
nit:
I feel it should say:
which is more logical
> the original return codes from 257394e4e3. But then the only use of
> tst_check_cmd() needs to update to expect false instead of true.
>
> Also document the return code in tst_private.h.
>
> Fixes: 9bb94efa39 ("tst_cmd: Change tst_check_cmd() return type to int")
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Fixing my own error.
>
> include/tst_private.h | 5 +++++
> lib/tst_test.c | 2 +-
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/include/tst_private.h b/include/tst_private.h
> index 87ec8829a1..482b68fba2 100644
> --- a/include/tst_private.h
> +++ b/include/tst_private.h
> @@ -1,5 +1,6 @@
> // SPDX-License-Identifier: GPL-2.0-or-later
> /*
> + * Copyright (c) Linux Test Project, 2020-2025
> * Copyright (c) 2017-2019 Petr Vorel <pvorel@suse.cz>
> *
> * Internal helper functions for the shell library. Do not use directly
> @@ -41,9 +42,13 @@ char tst_kconfig_get(const char *confname);
> /*
> * If cmd argument is a single command, this function just checks command
> * whether exists. If not, case breaks if brk_nosupp is defined.
> + *
> * If cmd argument is a complex string ie 'mkfs.ext4 >= 1.43.0', this
> * function checks command version whether meets this requirement.
> * If not, case breaks if brk_nosupp is defined.
> + *
> + * return: true if command presented, optionally with high enough version, false
s/command presented/command is present
> + * otherwise.
> */
> bool tst_check_cmd(const char *cmd, const int brk_nosupp);
>
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index da5314c502..bda66c4672 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -1960,7 +1960,7 @@ static int run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
> tst_res(TINFO, "=== Testing on %s ===", fs_type);
> tdev.fs_type = fs_type;
>
> - if (fs->mkfs_ver && tst_check_cmd(fs->mkfs_ver, 0))
> + if (fs->mkfs_ver && !tst_check_cmd(fs->mkfs_ver, 0))
> return TCONF;
>
> if (fs->min_kver && check_kver(fs->min_kver, 0))
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH 3/8] tst_test.c: Change check_kver() return type to bool
2025-11-07 10:29 ` [LTP] [PATCH 3/8] tst_test.c: Change check_kver() return type to bool Petr Vorel
@ 2025-11-14 8:53 ` Avinesh Kumar
0 siblings, 0 replies; 18+ messages in thread
From: Avinesh Kumar @ 2025-11-14 8:53 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Friday, November 7, 2025 11:29:34 AM CET Petr Vorel wrote:
> Also change the value (0 becomes true), add docs (don't use kerneldoc as
> this is a internal function which does not need to be in LTP online doc).
nit:
s/a internal/an internal
(also applies in Patch 4)
>
> While at it, add missing static.
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> lib/tst_test.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index bda66c4672..1725844b54 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -1056,7 +1056,12 @@ static void do_exit(int ret)
> exit(ret);
> }
>
> -int check_kver(const char *min_kver, const int brk_nosupp)
> +/*
> + * Check for the required kernel version.
> + *
> + * return: true if the kernel version is high enough, false otherwise.
> + */
> +static bool check_kver(const char *min_kver, const int brk_nosupp)
> {
> char *msg;
> int v1, v2, v3;
> @@ -1075,10 +1080,10 @@ int check_kver(const char *min_kver, const int brk_nosupp)
> else
> tst_res(TCONF, msg, min_kver);
>
> - return 1;
> + return false;
> }
>
> - return 0;
> + return true;
> }
>
> static int results_equal(struct results *a, struct results *b)
> @@ -1963,7 +1968,7 @@ static int run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
> if (fs->mkfs_ver && !tst_check_cmd(fs->mkfs_ver, 0))
> return TCONF;
>
> - if (fs->min_kver && check_kver(fs->min_kver, 0))
> + if (fs->min_kver && !check_kver(fs->min_kver, 0))
> return TCONF;
>
> prepare_device(fs);
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH 8/8] tst_test.c: Change fork_testrun() return type to void
2025-11-07 10:29 ` [LTP] [PATCH 8/8] tst_test.c: Change fork_testrun() " Petr Vorel
@ 2025-11-14 8:55 ` Avinesh Kumar
2025-11-14 10:06 ` Petr Vorel
0 siblings, 1 reply; 18+ messages in thread
From: Avinesh Kumar @ 2025-11-14 8:55 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi Petr,
On Friday, November 7, 2025 11:29:39 AM CET Petr Vorel wrote:
> Return code is not used any more.
very nit:
s/any more/anymore
(also applies in patch 6 and 7)
Reviewed-by: Avinesh Kumar <akumar@suse.de>
for all patches in the series.
Regards,
Avinesh
>
> Fixes: a1f82704c2 ("lib/tst_test.c: Fix tst_brk() handling")
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> lib/tst_test.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 8098b3a010..e115ce689d 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -1880,7 +1880,7 @@ void tst_set_runtime(int runtime)
> heartbeat();
> }
>
> -static int fork_testrun(void)
> +static void fork_testrun(void)
> {
> int status;
>
> @@ -1911,8 +1911,8 @@ static int fork_testrun(void)
> SAFE_SIGNAL(SIGINT, SIG_DFL);
>
> if (tst_test->taint_check && tst_taint_check()) {
> - tst_res(TFAIL, "Kernel is now tainted.");
> - return TFAIL;
> + tst_res(TFAIL, "Kernel is now tainted");
> + return;
> }
>
> if (tst_test->forks_child && kill(-test_pid, SIGKILL) == 0)
> @@ -1922,7 +1922,7 @@ static int fork_testrun(void)
> tst_brk(TBROK, "Child returned with %i", WEXITSTATUS(status));
>
> if (context->abort_flag)
> - return 0;
> + return;
>
> if (WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL) {
> tst_res(TINFO, "If you are running on slow machine, "
> @@ -1932,8 +1932,6 @@ static int fork_testrun(void)
>
> if (WIFSIGNALED(status))
> tst_brk(TBROK, "Test killed by %s!", tst_strsig(WTERMSIG(status)));
> -
> - return 0;
> }
>
> static struct tst_fs *lookup_fs_desc(const char *fs_type, int all_filesystems)
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH 8/8] tst_test.c: Change fork_testrun() return type to void
2025-11-14 8:55 ` Avinesh Kumar
@ 2025-11-14 10:06 ` Petr Vorel
2025-12-18 11:53 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2025-11-14 10:06 UTC (permalink / raw)
To: Avinesh Kumar; +Cc: ltp
Hi Avinesh,
thanks for fixing all the typos.
I'll wait little longer and merge with the fixes.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH 8/8] tst_test.c: Change fork_testrun() return type to void
2025-11-14 10:06 ` Petr Vorel
@ 2025-12-18 11:53 ` Andrea Cervesato via ltp
2025-12-22 8:15 ` Petr Vorel
0 siblings, 1 reply; 18+ messages in thread
From: Andrea Cervesato via ltp @ 2025-12-18 11:53 UTC (permalink / raw)
To: Petr Vorel, Avinesh Kumar; +Cc: ltp
Hi Petr,
On Fri Nov 14, 2025 at 11:06 AM CET, Petr Vorel wrote:
> Hi Avinesh,
>
> thanks for fixing all the typos.
> I'll wait little longer and merge with the fixes.
>
> Kind regards,
> Petr
I guess you can merge it now, there are enough reiewers who reviewed
this patch series.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH 8/8] tst_test.c: Change fork_testrun() return type to void
2025-12-18 11:53 ` Andrea Cervesato via ltp
@ 2025-12-22 8:15 ` Petr Vorel
0 siblings, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2025-12-22 8:15 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi all,
FYI merged with fixes suggested by Avinesh.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2025-12-22 8:15 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-07 10:29 [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup Petr Vorel
2025-11-07 10:29 ` [LTP] [PATCH 1/8] tst_test.c: Fix tst_check_cmd() use Petr Vorel
2025-11-08 7:16 ` Wei Gao via ltp
2025-11-14 8:49 ` Avinesh Kumar
2025-11-07 10:29 ` [LTP] [PATCH 2/8] tst_cmd.c: Check brk_nosupp when tst_get_path failed Petr Vorel
2025-11-08 7:20 ` Wei Gao via ltp
2025-11-07 10:29 ` [LTP] [PATCH 3/8] tst_test.c: Change check_kver() return type to bool Petr Vorel
2025-11-14 8:53 ` Avinesh Kumar
2025-11-07 10:29 ` [LTP] [PATCH 4/8] tst_test.c: Change results_equal() " Petr Vorel
2025-11-07 10:29 ` [LTP] [PATCH 5/8] tst_test.c: Change needs_tmpdir() " Petr Vorel
2025-11-07 10:29 ` [LTP] [PATCH 6/8] tst_test.c: Change run_tcases_per_fs() return type to void Petr Vorel
2025-11-07 10:29 ` [LTP] [PATCH 7/8] tst_test.c: Change run_tcase_on_fs() " Petr Vorel
2025-11-07 10:29 ` [LTP] [PATCH 8/8] tst_test.c: Change fork_testrun() " Petr Vorel
2025-11-14 8:55 ` Avinesh Kumar
2025-11-14 10:06 ` Petr Vorel
2025-12-18 11:53 ` Andrea Cervesato via ltp
2025-12-22 8:15 ` Petr Vorel
2025-11-10 7:18 ` [LTP] [PATCH 0/8] tst_test.c: Minor return code cleanup Li Wang via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox