| Message ID | 2a67385fe34905b5b631abadb6daefb6f595a924.1651176646.git.luke.nowakowskikrijger@canonical.com |
|---|---|
| State | Changes Requested |
| Headers | show |
| Series | Expand Cgroup lib and modify controller tests | expand |
Hi Luke, > Add the TST_TOSTR macro which uses a preprocessor trick to concetenate > variables into strings. > Useful when needing to create strings from other #define variables. > Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com> > --- > include/tst_test_macros.h | 3 +++ > 1 file changed, 3 insertions(+) > diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h > index 2e7b7871c..f5d86c421 100644 > --- a/include/tst_test_macros.h > +++ b/include/tst_test_macros.h include/tst_common.h would be probably a better place. Because tst_test_macros.h contains tests which call TEST() helpers. > @@ -36,6 +36,9 @@ extern void *TST_RET_PTR; > #define TST_2_(_1, _2, ...) _2 > +#define _TST_TOSTR(STR) #STR At least 3 tests have: #define str(s) #s (or STR) (testcases/network/stress/route/route-change-netlink.c testcases/kernel/controllers/freezer/vfork.c testcases/kernel/pty/pty04.c) therefore IMHO it'd be better to define: #define TST_STR(s) #s #define TST_TOSTR(s) TST_STR(s) > +#define TST_TOSTR(STR) _TST_TOSTR(STR) Kind regards, Petr
Hi! > Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com> > --- > include/tst_test_macros.h | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h > index 2e7b7871c..f5d86c421 100644 > --- a/include/tst_test_macros.h > +++ b/include/tst_test_macros.h > @@ -36,6 +36,9 @@ extern void *TST_RET_PTR; > > #define TST_2_(_1, _2, ...) _2 > > +#define _TST_TOSTR(STR) #STR > +#define TST_TOSTR(STR) _TST_TOSTR(STR) Just minor thing, anything starting with underscore is reserved for libc and kernel. So we try to add the underscore at the end instead when defining intemediate macros. This one should be TST_TO_STR_() instead. > #define TST_FMT_(FMT, _1, ...) FMT, ##__VA_ARGS__ > > #define TST_MSG_(RES, FMT, SCALL, ...) \ > -- > 2.32.0 > > > -- > Mailing list info: https://lists.linux.it/listinfo/ltp
diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h index 2e7b7871c..f5d86c421 100644 --- a/include/tst_test_macros.h +++ b/include/tst_test_macros.h @@ -36,6 +36,9 @@ extern void *TST_RET_PTR; #define TST_2_(_1, _2, ...) _2 +#define _TST_TOSTR(STR) #STR +#define TST_TOSTR(STR) _TST_TOSTR(STR) + #define TST_FMT_(FMT, _1, ...) FMT, ##__VA_ARGS__ #define TST_MSG_(RES, FMT, SCALL, ...) \
Add the TST_TOSTR macro which uses a preprocessor trick to concetenate variables into strings. Useful when needing to create strings from other #define variables. Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com> --- include/tst_test_macros.h | 3 +++ 1 file changed, 3 insertions(+)