[LTP] [PATCH v1] Rewrite getcontext01.c test using new LTP API
Petr Vorel
pvorel@suse.cz
Wed Feb 16 12:49:55 CET 2022
Hi Andrea,
> Removed old LTP API from getcontext01.c test and check if getcontext is
> present in the current system. The check is useful in those systems
> where libmusl is used by default.
nit: "libmusl": it's musl libc or just musl (https://musl.libc.org/about.html).
I got really confused you mean some other library on the top of musl
(e.g. there is musl-fts implementation https://github.com/void-linux/musl-fts
because musl refuses to implement fts.h).
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
> ---
> configure.ac | 1 +
> .../kernel/syscalls/getcontext/getcontext01.c | 93 +++++--------------
> 2 files changed, 24 insertions(+), 70 deletions(-)
> diff --git a/configure.ac b/configure.ac
> index 8d2c5b1c4..41a21a636 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -97,6 +97,7 @@ AC_CHECK_FUNCS_ONCE([ \
> fspick \
> fstatat \
> getauxval \
> + getcontext \
I was surprised that getcontext is still not in musl (but it's in ucontext.h header),
but it's deliberate:
https://wiki.musl-libc.org/open-issues.html#ucontext.h
Also not sure if it's in bionic
(https://android.googlesource.com/platform/bionic).
Thus ack using autotools (I'm trying to remove old unneeded check to speedup
configure runtime).
It might be worth to add .test_variants to test raw syscall,
but that'd be another effort (no need to bother with it now).
> TEST(getcontext(&ptr));
...
> + if (TST_RET < 0)
> + tst_res(TFAIL, "getcontext: %s", tst_strerrno(TST_ERR));
...
> + if (TST_RET == 0)
> + tst_res(TPASS, "getcontext passed");
> + else
> + tst_res(TFAIL, "Unexpected return value %li", TST_RET);
> }
For this code:
if (TST_RET < 0)
tst_res(TFAIL, "getcontext: %s", tst_strerrno(TST_ERR));
I'd personally add else if here below:
if (TST_RET == 0)
tst_res(TPASS, "getcontext passed");
else
tst_res(TFAIL, "Unexpected return value %li", TST_RET);
But how about instead of all this just using
TST_EXP_PASS(getcontext(&ptr));
...
> +static struct tst_test test = {
> + .test_all = run,
> +};
> #else /* systems that dont support obsolete getcontext */
I'm going to remove this useless comment before merge ^
> -int main(void)
> -{
> - tst_brkm(TCONF, NULL, "system doesn't have getcontext support");
> -}
> +TST_TEST_TCONF("system doesn't have getcontext support");
> #endif
Kind regards,
Petr
More information about the ltp
mailing list