1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2019 Joyent, Inc. 14 */ 15 16 #ifndef _DEMANGLE_TEST_H 17 #define _DEMANGLE_TEST_H 18 19 #include <demangle-sys.h> 20 #include <sys/linker_set.h> 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 typedef struct demtest_case { 27 const char *dtc_mangled; 28 const char *dtc_demangled; 29 } demtest_case_t; 30 31 typedef struct demtest_group { 32 sysdem_lang_t dtg_lang; 33 const char *dtg_name; 34 demtest_case_t dtg_tests[]; 35 } demtest_group_t; 36 37 #define T(_m, _d) { .dtc_mangled = _m, .dtc_demangled = _d } 38 #define T_ERR(_m) { .dtc_mangled = _m } 39 40 #define GROUP(_name, _lang, ...) \ 41 static demtest_group_t _name = { \ 42 .dtg_name = #_name, \ 43 .dtg_lang = _lang, \ 44 .dtg_tests = { \ 45 __VA_ARGS__, \ 46 { NULL, NULL } \ 47 } \ 48 }; \ 49 DATA_SET(demangle_tests, _name) 50 51 /* 52 * Some things (e.g. the C++ mangled names with floating point constants) 53 * can produce multiple acceptable outputs. 54 */ 55 typedef struct demtest_mcase { 56 const char *dtmc_mangled; 57 const char **dtmc_demangled; 58 } demtest_mcase_t; 59 60 typedef struct demtest_mgroup { 61 sysdem_lang_t dtmg_lang; 62 const char *dtmg_name; 63 demtest_mcase_t *dtmg_tests[]; 64 } demtest_mgroup_t; 65 66 #define TM(_m, ...) &(demtest_mcase_t){ \ 67 .dtmc_mangled = _m, \ 68 .dtmc_demangled = (const char *[]){ \ 69 __VA_ARGS__, \ 70 NULL \ 71 } \ 72 } 73 74 #define MGROUP(_name, _lang, ...) \ 75 static demtest_mgroup_t _name = { \ 76 .dtmg_name = #_name, \ 77 .dtmg_lang = _lang, \ 78 .dtmg_tests = { \ 79 __VA_ARGS__, \ 80 NULL \ 81 } \ 82 }; \ 83 DATA_SET(demangle_mtests, _name) 84 85 #ifdef __cplusplus 86 } 87 #endif 88 89 #endif /* _DEMANGLE_TEST_H */