[LTP] [PATCH v5 1/2] ptrace05: Refactor the test using new LTP API
Petr Vorel
pvorel@suse.cz
Mon Jan 13 22:40:10 CET 2025
Hi Cyril, Wei,
> Hi!
> > +static void print_dbg_sig(int signum)
> > {
> > - fprintf(stderr, "usage: %s [start-signum] [end-signum]\n", argv0);
> > - return 1;
> > + char const *strsig = tst_strsig(signum);
> > +
> > + if (strstr(strsig, "???"))
> > + tst_res(TDEBUG, "[child] Sending kill(.., %d)", signum);
> > + else
> > + tst_res(TDEBUG, "[child] Sending kill(.., %s)", strsig);
> > }
> This works around the library defficiencies. I would rather see patch
> that changes the tst_strsig() return the number if we do not have a
> match.
Good point.
> This should work:
> diff --git a/lib/tests/tst_strsig.c b/lib/tests/tst_strsig.c
> index 9a5ca80aa..ed5be3f00 100644
> --- a/lib/tests/tst_strsig.c
> +++ b/lib/tests/tst_strsig.c
> @@ -29,6 +29,7 @@ int TST_TOTAL = 1;
> int main(void)
> {
> + fprintf(stderr, "0 = %s\n", tst_strsig(0));
> fprintf(stderr, "SIGKILL = %s\n", tst_strsig(SIGKILL));
> fprintf(stderr, "SIGALRM = %s\n", tst_strsig(SIGALRM));
> return 0;
> diff --git a/lib/tst_res.c b/lib/tst_res.c
> index 7c66d2f6c..90403bc67 100644
> --- a/lib/tst_res.c
> +++ b/lib/tst_res.c
> @@ -141,11 +141,14 @@ struct pair {
> #define PAIR(def) [def] = {.name = #def, .val = def},
> #define STRPAIR(key, value) [key] = {.name = value, .val = key},
> -#define PAIR_LOOKUP(pair_arr, idx) do { \
> - if (idx < 0 || (size_t)idx >= ARRAY_SIZE(pair_arr) || \
> - pair_arr[idx].name == NULL) \
> - return "???"; \
> - return pair_arr[idx].name; \
> +#define PAIR_LOOKUP(pair_arr, idx) do { \
> + static char par_str_buf__[16]; \
> + if (idx < 0 || (size_t)idx >= ARRAY_SIZE(pair_arr) || \
> + pair_arr[idx].name == NULL) { \
> + snprintf(par_str_buf__, sizeof(par_str_buf__), "%i", idx); \
> + return par_str_buf__; \
> + } \
> + return pair_arr[idx].name; \
> } while (0)
For this library change:
Reviewed-by: Petr Vorel <pvorel@suse.cz>
This makes sense. Could you please for speedup merge this library change,
so that Wei can base v6 on it?
Kind regards,
Petr
More information about the ltp
mailing list