Hi Jerome,

On Thu, 27 Feb 2025 at 10:12, Jerome Forissier
<jerome.foriss...@linaro.org> wrote:
>
> Hi Simon,
>
> On 2/27/25 17:25, Simon Glass wrote:
> > Hi Jerome,
> >
> > On Tue, 25 Feb 2025 at 09:35, Jerome Forissier
> > <jerome.foriss...@linaro.org> wrote:
> >>
> >> Test the spawn and wait commands.
> >>
> >> Signed-off-by: Jerome Forissier <jerome.foriss...@linaro.org>
> >> ---
> >>  test/cmd/Makefile |  1 +
> >>  test/cmd/spawn.c  | 33 +++++++++++++++++++++++++++++++++
> >>  2 files changed, 34 insertions(+)
> >>  create mode 100644 test/cmd/spawn.c
> >>
> >> diff --git a/test/cmd/Makefile b/test/cmd/Makefile
> >> index d8a5e77402d..cf47f04851c 100644
> >> --- a/test/cmd/Makefile
> >> +++ b/test/cmd/Makefile
> >> @@ -39,3 +39,4 @@ obj-$(CONFIG_CMD_WGET) += wget.o
> >>  endif
> >>  obj-$(CONFIG_ARM_FFA_TRANSPORT) += armffa.o
> >>  endif
> >> +obj-$(CONFIG_CMD_SPAWN) += spawn.o
> >> diff --git a/test/cmd/spawn.c b/test/cmd/spawn.c
> >> new file mode 100644
> >> index 00000000000..5e0770858c0
> >> --- /dev/null
> >> +++ b/test/cmd/spawn.c
> >> @@ -0,0 +1,33 @@
> >> +// SPDX-License-Identifier: GPL-2.0-or-later
> >> +/*
> >> + * Tests for spawn and wait commands
> >> + *
> >> + * Copyright 2025, Linaro Ltd.
> >> + */
> >> +
> >> +#include <command.h>
> >> +#include <dm.h>
> >> +#include <dm/test.h>
> >> +#include <test/test.h>
> >> +#include <test/ut.h>
> >> +
> >> +static int dm_test_cmd_spawn(struct unit_test_state *uts)
> >> +{
> >> +       ut_assertok(run_command("wait; spawn sleep 2; setenv j ${job_id}; "
> >> +                               "spawn setenv spawned true; "
> >> +                               "setenv jj ${job_id}; wait; "
> >> +                               "echo ${j} ${jj} ${spawned}", 0));
> >> +       console_record_readline(uts->actual_str, sizeof(uts->actual_str));
> >> +       ut_asserteq_ptr(uts->actual_str,
> >> +                       strstr(uts->actual_str, "1 2 true"));
> >> +
> >> +       ut_assertok(run_command("spawn true; wait; setenv t $?; spawn 
> >> false; "
> >> +                               "wait; setenv f $?; wait; echo $t $f $?", 
> >> 0));
> >> +       console_record_readline(uts->actual_str, sizeof(uts->actual_str));
> >> +       ut_asserteq_ptr(uts->actual_str,
> >> +                       strstr(uts->actual_str, "0 1 0"));
> >> +       ut_assert_console_end();
> >> +
> >> +       return 0;
> >> +}
> >> +DM_TEST(dm_test_cmd_spawn, UTF_CONSOLE);
> >> --
> >> 2.43.0
> >>
> >
> > This doesn't look like a DM test as it doesn't use devices. Could it
> > be a CMD test?
>
> Absolutely. In fact I started from a copy of test/cmd/hash.c, which is
> not a DM test either is it?

That's right. Since DM had the first tests nearly everything started
out as a DM test, so you could clean those up if you have time.

Regards,
SImon

Reply via email to