[LTP] [PATCH v2 05/18] tst_test_macros: Add TST_TO_STR and TST_STR macro

Luke Nowakowski-Krijger luke.nowakowskikrijger@canonical.com
Thu Jul 21 22:52:15 CEST 2022


Add the TST_TO_STR macro which uses a preprocessor trick to concetenate
variables into strings.

Useful when needing to create strings from other #define variables.

Also define TST_STR as an intermediate macro that could be used when
defining string literals.

Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com>
---
v2: Change names to TST_STR and TST_TO_STR
Treat TST_STR as its own macro because it could be useful. 

 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..58b965f78 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_STR(s) #s
+#define TST_TO_STR(s) TST_STR(s)
+
 #define TST_FMT_(FMT, _1, ...) FMT, ##__VA_ARGS__
 
 #define TST_MSG_(RES, FMT, SCALL, ...) \
-- 
2.34.1



More information about the ltp mailing list