[LTP] [PATCH 1/1] tools: Fix syntax error caused by "; ; " in create_dmesg_entry awk script

Shizhao Chen shichen@redhat.com
Thu Dec 28 05:48:32 CET 2023


Thanks for the review! I will send a v2 shortly.


On Wed, Dec 27, 2023 at 10:29 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> > Hi Petr, Shizhao,
>
> > On Wed, Dec 27, 2023 at 5:10 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> > > Hi Shizhao,
>
> > > > When running runltp with both -S and -K provided, tests that are
> > > supposed to be
> > > > "skipped" and report TCONF results were failing due to an unexpected
> > > semicolon
> > > > at the end of the constructed command.
>
> > > > `-S` replace the test command with `exit 32;`
> > > > `-K` appends another semicolon to the command then we get `exit 32;;`
>
> > > > For example:
>
> > > >   >>> 780:madvise06__with_dmesg_entry BROK <<<
>
> > > >        1      <<<test_start>>>
> > > >        2      tag=madvise06__with_dmesg_entry stime=1703556061
> > > >        3      cmdline="dmesg -c 1>/dev/null 2>&1; exit 32;; dmesg >
> > > /mnt/testarea/ltp/output/DMESG_DIR_RHELKT1LITE.FILTERED-dmesg-output-53127-08:48:23PM/madvise06.dmesg.log"
> > > >        4      contacts=""
> > > >        5      analysis=exit
> > > >        6      <<<test_output>>>
> > > >        7      sh: -c: line 1: syntax error near unexpected token `;;'
> > > >        8      sh: -c: line 1: `dmesg -c 1>/dev/null 2>&1; exit 32;;
> > > dmesg >
> > > /mnt/testarea/ltp/output/DMESG_DIR_RHELKT1LITE.FILTERED-dmesg-output-53127-08:48:23PM/madvise06.dmesg.log'
> > > >        9      <<<execution_status>>>
> > > >       10      initiation_status="ok"
> > > >       11      duration=0 termination_type=exited termination_id=2
> > > corefile=no
> > > >       12      cutime=0 cstime=1
> > > >       13      <<<test_end>>>
>
> > > > Signed-off-by: Shizhao Chen <shichen@redhat.com>
> > > > ---
> > > >  tools/create_dmesg_entries_for_each_test.awk | 1 +
> > > >  1 file changed, 1 insertion(+)
>
> > > > diff --git a/tools/create_dmesg_entries_for_each_test.awk
> > > b/tools/create_dmesg_entries_for_each_test.awk
> > > > index 25d750a55..7a22bb4a6 100644
> > > > --- a/tools/create_dmesg_entries_for_each_test.awk
> > > > +++ b/tools/create_dmesg_entries_for_each_test.awk
> > > > @@ -27,6 +27,7 @@ NF && ! /^#/ {
> > > >       for (i = 2; i <= NF; i++) {
> > > >               s = s " " $i
> > > >       }
> > > > +     sub(/;$/, "", s)
>
> > > From the above context are you sure that there will not be missing
> > > semicolon?
> > > (e.g. between dmesg and exit)
>
> > > Wouldn't it be safe to make sure there is only only single semicolon at
> > > the end?
>
>
> > > sub(/[;]+$/, ";")
>
>
> > Hmm, that would not work as expected because in the next line
> > forces adding a semicolon.
>
> >     s = s "; dmesg > " DMESG_DIR "/" $1 ".dmesg.log"
>
> > Unless we make a minor adjustments to your version:
>
> >     sub(/[;]+$/, "", s)
>
> Ah, thanks Li!
>
> I'm ok to merge your suggestion, just wait little longer for Shizhao, in case we
> overlooked something.
>
> Kind regards,
> Petr
>
> > Otherwise LGTM:
> > Reviewed-by: Li Wang <liwang@redhat.com>
>



More information about the ltp mailing list