All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Li Wang <liwang@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 1/4] testcases/lib/run_tests.sh: Check expected results
Date: Tue, 10 Dec 2024 07:59:54 +0100	[thread overview]
Message-ID: <20241210065954.GB227882@pevik> (raw)
In-Reply-To: <CAEemH2dpExk4HqzGEkpC-oBwnc-fRVMnwy0_n4LbfbS9OoJ1oA@mail.gmail.com>

> On Mon, Dec 9, 2024 at 6:14 PM Petr Vorel <pvorel@suse.cz> wrote:

> > Hi Li, all,

> > ...
> > > We could add a blank line print here to make the output better readable.

> > >   echo ""

> > > +               echo "*** Running '$test' (exp: $(tst_mask2flag $exp))
> > ***"

> > +1


> > > > +               $test
> > > > +               rc=$?
> > > > +               if [ $rc = 127 ]; then
> > > > +                       echo "Test '$test' not found, maybe out-of-tree
> > > > build and unset builddir?" >&2
> > > > +                       exit 1
> > > > +               elif [ $rc = 2 -a $WHITELIST_GITHUB = 1 -a
> > > > "$GITHUB_ACTIONS" ]; then


> > > If one or more variables used in the conditional test are
> > > either unset or empty, that will lead to invalid syntax.

> > > So I would suggest using [ ... ] and &&:

> > >   elif [ $rc = 2 ] && [ $WHITELIST_GITHUB = 1 ] && [ -n "$GITHUB_ACTIONS"
> > > ]; then

> > Good point. Or maybe just quote?

> > elif [ "$rc" = 2 -a "$WHITELIST_GITHUB" = 1 -a "$GITHUB_ACTIONS" ]; then


> This can work,  but using -a can lead to ambiguous or hard-to-diagnose
> behavior. A better approach would be to replace -a with &&.

> Maybe the best way is:

> elif [ "$rc" = 2 ] && [ "$WHITELIST_GITHUB" = 1 ] && [ -n "$GITHUB_ACTIONS"
> ]; then

Thank you for pointing this, I'll use this.

I thought -a takes precedence to -o like in C, i.e. [ foo -a bar -o baz ] is the
equivalent of [ foo ] && [ bar ] || baz.

But now I see in man test(1):

	Binary -a and -o are ambiguous.  Use 'test EXPR1 && test EXPR2' or 'test EXPR1 || test EXPR2' instead.

I also wonder if any -a or -o is ambiguous. Or just combination of both. Because
we have some "-a" and "-o" usage in tst_test.sh. Should we transform them?

	if [ $TST_BROK -gt 0 -o $TST_FAIL -gt 0 -o $TST_WARN -gt 0 ]; then
		_tst_check_security_modules
	fi

	if [ "$TST_NEEDS_TMPDIR" = 1 -a -n "$TST_TMPDIR" ]; then
		rm -r "$TST_TMPDIR"
		[ "$TST_TMPDIR_RHOST" = 1 ] && tst_cleanup_rhost
	fi

	NOTE: this one I'm going to change in upcoming fix of the TBROK => TWARN evaluation
	# TBROK => TWARN on cleanup or exit
	if [ "$res" = TBROK ] && [ "$TST_DO_EXIT" = 1 -o -z "$TST_DO_CLEANUP" -a -n "$TST_CLEANUP" ]; then
		tst_res TWARN "$@"
		TST_DO_CLEANUP=
		return
	fi

Kind regards,
Petr

> > Kind regards,
> > Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2024-12-10  7:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-06  9:49 [LTP] [PATCH 0/4] ci: run shell loader tests Petr Vorel
2024-12-06  9:49 ` [LTP] [PATCH 1/4] testcases/lib/run_tests.sh: Check expected results Petr Vorel
2024-12-09  9:42   ` Li Wang
2024-12-09 10:13     ` Petr Vorel
2024-12-10  2:07       ` Li Wang
2024-12-10  6:59         ` Petr Vorel [this message]
2024-12-10  7:33           ` Li Wang
2024-12-06  9:49 ` [LTP] [PATCH 2/4] Makefile: Add target to run shell loader Petr Vorel
2024-12-06  9:49 ` [LTP] [PATCH 3/4] build.sh: Allow to run shell loader tests Petr Vorel
2024-12-06  9:49 ` [LTP] [PATCH 4/4] ci: Add " Petr Vorel

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=20241210065954.GB227882@pevik \
    --to=pvorel@suse.cz \
    --cc=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.