| Message ID | 20260109061716.20258-3-wegao@suse.com |
|---|---|
| State | Accepted |
| Headers | show |
| Series | new cmd support option for needs_cmds | expand |
| Context | Check | Description |
|---|---|---|
| ltpci/alpine_latest_gcc | fail | failure |
| ltpci/debian_oldstable_gcc | fail | failure |
| ltpci/debian_stable_gcc | fail | failure |
| ltpci/debian_testing_gcc | fail | failure |
| ltpci/ubuntu_bionic_gcc | fail | failure |
| ltpci/fedora_latest_clang | fail | failure |
| ltpci/debian_testing_clang | fail | failure |
| ltpci/debian_stable_s390x-linux-gnu-gcc_s390x | fail | failure |
| ltpci/debian_stable_aarch64-linux-gnu-gcc_arm64 | fail | failure |
| ltpci/debian_stable_gcc | fail | failure |
| ltpci/debian_stable_powerpc64le-linux-gnu-gcc_ppc64el | fail | failure |
| ltpci/ubuntu_jammy_gcc | fail | failure |
| ltpci/quay-io-centos-centos_stream9_gcc | fail | failure |
| ltpci/debian_oldstable_clang | fail | failure |
| ltpci/opensuse-leap_latest_gcc | fail | failure |
| ltpci/opensuse-archive_42-2_gcc | fail | failure |
Hi Wei, ... > +++ b/lib/tst_test.c > @@ -1375,6 +1375,24 @@ static const char *default_fs_type(void) > return tst_dev_fs_type(); > } > +bool tst_cmd_present(const char *cmd) > +{ > + struct tst_cmd *pcmd = tst_test->needs_cmds; > + > + if (!cmd || cmd[0] == '\0') > + tst_brk(TBROK, "Invalid cmd"); I'd still prefer tst_brk_() as I described at v6, but that can be done as a separate change. I keep my RBT :). Kind regards, Petr > + > + while (pcmd->cmd) { > + if (!strcmp(pcmd->cmd, cmd)) > + return pcmd->present; > + > + pcmd++; > + } > + > + tst_brk(TBROK, "'%s' not checked", cmd); > + return false; > +} > + > static void do_setup(int argc, char *argv[]) > { > char *tdebug_env = getenv("LTP_ENABLE_DEBUG");
> ... > > +++ b/lib/tst_test.c > > @@ -1375,6 +1375,24 @@ static const char *default_fs_type(void) > > return tst_dev_fs_type(); > > } > > +bool tst_cmd_present(const char *cmd) > > +{ > > + struct tst_cmd *pcmd = tst_test->needs_cmds; > > + > > + if (!cmd || cmd[0] == '\0') > > + tst_brk(TBROK, "Invalid cmd"); > I'd still prefer tst_brk_() as I described at v6, but that can be done as a > separate change. I keep my RBT :). I see Cyril was OK with keeping tst_brk() in v6, I'm sorry to overlook it. https://lore.kernel.org/ltp/aV4ujjfb7JBB2zaQ@yuki.lan/ > Kind regards, > Petr
Hi Wei, I don't get the point why we needs seperately define the tst_cmd_present() function, from what I understand, as long as we fill "commands" in the new struct field, that would be completed the check and store the state in .present, right? Shouldn't we use that .present value in testcase directly? On Fri, Jan 9, 2026 at 2:18 PM Wei Gao via ltp <ltp@lists.linux.it> wrote: > > Signed-off-by: Wei Gao <wegao@suse.com> > Reviewed-by: Petr Vorel <pvorel@suse.cz> > --- > include/tst_test.h | 12 ++++++++++++ > lib/tst_test.c | 18 ++++++++++++++++++ > 2 files changed, 30 insertions(+) > > diff --git a/include/tst_test.h b/include/tst_test.h > index dc2e9a397..d15bf87fd 100644 > --- a/include/tst_test.h > +++ b/include/tst_test.h > @@ -726,6 +726,18 @@ int tst_creat_unlinked(const char *path, int flags, mode_t mode); > */ > const char *tst_get_tmpdir_root(void); > > +/** > + * tst_cmd_present() - Check if a command is present > + * @cmd: The name of the command to check for. > + * > + * This function iterates through the &tst_test->needs_cmds array. It compares > + * the given command name with each entry in the array and returns the > + * &tst_cmd->present flag for the matching command. > + * > + * Return: `true` if the command is present, `false` otherwise. > + */ > +bool tst_cmd_present(const char *cmd); > + > /* > * Validates exit status of child processes > */ > diff --git a/lib/tst_test.c b/lib/tst_test.c > index 09aa7fce2..0c2bbbbd6 100644 > --- a/lib/tst_test.c > +++ b/lib/tst_test.c > @@ -1375,6 +1375,24 @@ static const char *default_fs_type(void) > return tst_dev_fs_type(); > } > > +bool tst_cmd_present(const char *cmd) > +{ > + struct tst_cmd *pcmd = tst_test->needs_cmds; > + > + if (!cmd || cmd[0] == '\0') > + tst_brk(TBROK, "Invalid cmd"); > + > + while (pcmd->cmd) { > + if (!strcmp(pcmd->cmd, cmd)) > + return pcmd->present; > + > + pcmd++; > + } > + > + tst_brk(TBROK, "'%s' not checked", cmd); > + return false; > +} > + > static void do_setup(int argc, char *argv[]) > { > char *tdebug_env = getenv("LTP_ENABLE_DEBUG"); > -- > 2.52.0 > > > -- > Mailing list info: https://lists.linux.it/listinfo/ltp >
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
diff --git a/include/tst_test.h b/include/tst_test.h index dc2e9a397..d15bf87fd 100644 --- a/include/tst_test.h +++ b/include/tst_test.h @@ -726,6 +726,18 @@ int tst_creat_unlinked(const char *path, int flags, mode_t mode); */ const char *tst_get_tmpdir_root(void); +/** + * tst_cmd_present() - Check if a command is present + * @cmd: The name of the command to check for. + * + * This function iterates through the &tst_test->needs_cmds array. It compares + * the given command name with each entry in the array and returns the + * &tst_cmd->present flag for the matching command. + * + * Return: `true` if the command is present, `false` otherwise. + */ +bool tst_cmd_present(const char *cmd); + /* * Validates exit status of child processes */ diff --git a/lib/tst_test.c b/lib/tst_test.c index 09aa7fce2..0c2bbbbd6 100644 --- a/lib/tst_test.c +++ b/lib/tst_test.c @@ -1375,6 +1375,24 @@ static const char *default_fs_type(void) return tst_dev_fs_type(); } +bool tst_cmd_present(const char *cmd) +{ + struct tst_cmd *pcmd = tst_test->needs_cmds; + + if (!cmd || cmd[0] == '\0') + tst_brk(TBROK, "Invalid cmd"); + + while (pcmd->cmd) { + if (!strcmp(pcmd->cmd, cmd)) + return pcmd->present; + + pcmd++; + } + + tst_brk(TBROK, "'%s' not checked", cmd); + return false; +} + static void do_setup(int argc, char *argv[]) { char *tdebug_env = getenv("LTP_ENABLE_DEBUG");