[LTP] [PATCH 05/19] tst_test_macros: Add TST_TOSTR macro
    Luke Nowakowski-Krijger 
    luke.nowakowskikrijger@canonical.com
       
    Thu Apr 28 22:39:30 CEST 2022
    
    
  
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
@@ -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, ...) \
-- 
2.32.0
    
    
More information about the ltp
mailing list