All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Dennis Brendel <dbrendel@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v7 2/4] ci: add patchwork communication script
Date: Wed, 16 Apr 2025 14:48:46 +0200	[thread overview]
Message-ID: <20250416124846.GA602689@pevik> (raw)
In-Reply-To: <9af81e6d-e0b5-4488-a589-76061f2be18b@redhat.com>

Hi Dennis,

> On 4/15/25 7:35 PM, Petr Vorel wrote:
> > Hi Andrea,
> > You may have noticed in tst_test.sh, that local variable never uses $(...).
> > It assign single value, but never call $(...). This is for a reason.
> > [...]
> > What happen? $? is assigned from result of local keyword,
> > it overwrite previous result from $(...). Note even '#!/bin/sh -e'
> > would not cause it to fail early.

> Here is the corresponding documentation:
> https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#index-local

> > The return status is zero unless local is used outside a function, an
> invalid name is supplied, or name is a readonly variable

> So:
> If you are interested in return statuses then don't *mask them* with local.

> Use this pattern instead:

> local my_var
> my_var=$(my_expr)

Thanks for much better explanation than I provided + link to the doc. I'll Cc
you on my shell related patches :).

I remember this since 87a82a62ce ("lib/tst_test.sh: fix ROD_SILENT command
return status check") [1], another related is e267a022cd ("tst_test.sh: Fix $@
usage on older dash releases") [2].

Because shell has quirks (both POSIX portable syntax or bash or whatever shell
extension) we've had many fixes for shell code, e.g. 0c0076fbaf ("tst_test.sh:
Fix ROD_SILENT() quoting") [3], although some of them are non-bash specific,
e.g. 0bb01e67b3 ("shell: Fix handling default parameters in tst_mkfs()") [4]
(just to list very few).

The biggest problem is that some things aren't easily done with plain shell,
that's why we need to use C helpers in testcases/lib (some of them are just
reusing C API to avoid reimplementing code, but e.g.  testcases/lib/tst_timeout_kill.c
was really needed after few attempts to write code in bash). Also cgroup tests
aren't reliable when written in shell. Therefore we're trying to get rid of
shell API (rewritten tests into C, or make them to use testcases/lib/tst_run_shell.c,
which makes the layer really thin).

Kind regards,
Petr

[1] https://github.com/linux-test-project/ltp/commit/87a82a62ce3fcdaf174d6e4529e0324742e13684
[2] https://github.com/linux-test-project/ltp/commit/e267a022cd2deb0d5e7280570c711420927ad817
[3] https://github.com/linux-test-project/ltp/commit/0c0076fbaf6e0059b470fadff6240fc56952c218
[4] https://github.com/linux-test-project/ltp/commit/0bb01e67b3ba079f8f069a99422d783fe6da4287

> Kind regards,
> Dennis

> > (Deliberately test with bash to demonstrate local behaves oddly not even in dash
> > or 'busybox sh' but even with bash. And yes, given how many errors we caught
> > with this script and generate_arch.sh and generate_syscalls.sh due shell strange
> > syntax and behavior makes me wonder if we really want to use shell scripts for
> > anything longer than 5 lines.)

> > Kind regards,
> > Petr

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

  reply	other threads:[~2025-04-16 12:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-15 16:39 [LTP] [PATCH v7 0/4] Support for Patchwork CI Andrea Cervesato
2025-04-15 16:39 ` [LTP] [PATCH v7 1/4] ci: install dependences for patchwork-ci script Andrea Cervesato
2025-04-15 16:39 ` [LTP] [PATCH v7 2/4] ci: add patchwork communication script Andrea Cervesato
2025-04-15 17:35   ` Petr Vorel
2025-04-15 20:42     ` Dennis Brendel via ltp
2025-04-16 12:48       ` Petr Vorel [this message]
2025-04-16  7:40     ` Andrea Cervesato via ltp
2025-04-16  7:49     ` Andrea Cervesato via ltp
2025-04-16  7:04   ` Li Wang via ltp
2025-04-16  8:23     ` Andrea Cervesato via ltp
2025-04-16  8:38       ` Petr Vorel
2025-04-16  8:55         ` Li Wang via ltp
2025-04-15 16:39 ` [LTP] [PATCH v7 3/4] ci: add ci-patchwork-trigger workflow Andrea Cervesato
2025-04-15 16:39 ` [LTP] [PATCH v7 4/4] ci: apply patchwork series in ci-docker-build workflow Andrea Cervesato
2025-04-15 16:53 ` [LTP] [PATCH v7 0/4] Support for Patchwork CI Andrea Cervesato via ltp

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=20250416124846.GA602689@pevik \
    --to=pvorel@suse.cz \
    --cc=dbrendel@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.