[LTP] [PATCH v3 3/4] shell lib: Add basic support for test setup
Petr Vorel
pvorel@suse.cz
Thu Jul 17 12:26:11 CEST 2025
Hi Li, Cyril, all,
> PM Petr Vorel <pvorel@suse.cz> wrote:
...
> > +if [ -n "$TST_CLEANUP" ]; then
> > + trap $TST_CLEANUP EXIT
> > +fi
> > +
> > +if [ -n "$TST_SETUP" ]; then
> > + $TST_SETUP
> > +fi
> > +
@Li first, thanks a lot for your feedback.
> Here maybe better to have a check before the tst_test:
> if ! declare -F tst_test > /dev/null; then
> tst_brk TBROK "tst_test() function is not defined"
> fi
Sure, I can add a check for function existence. 'declare' is a bashism,
I use 'command -v' which we already use for $TST_SETUP and $TST_CLEANUP
in tst_test.h.
if [ -n "$TST_SETUP" ]; then
if command -v $TST_SETUP >/dev/null 2>/dev/null; then
TST_DO_CLEANUP=1
$TST_SETUP
else
tst_brk TBROK "TST_SETUP=$TST_SETUP declared, but function not defined (or cmd not found)"
fi
fi
> > +tst_test
> > --
> > 2.49.0
> Sorry, I should have pointed this out at the first review, but
> the idea came to my mind a little bit delayed :).
No problem :).
@Cyril any more feedback before I'll send a new version (v4)?
Kind regards,
Petr
More information about the ltp
mailing list