12 #ifndef UT_VALGRINDED_H
13 #define UT_VALGRINDED_H
16 const char *found = strchr(str,
'|');
17 while (found && found>str && found[-1] ==
'\\') {
18 found = strchr(found+1,
'|');
36 #define UTVG_CALL_SEEN "flag.valgrind.callseen"
40 inline const char *flag_name(
const char *name) {
41 const char *ARBHOME = getenv(
"ARBHOME");
46 snprintf(buf, BUFSIZE, "%
s/UNIT_TESTER/valgrind/%
s", ARBHOME, name);
51 inline
bool flag_exists(const
char *name) {
52 const char *path = flag_name(name);
55 return stat(path, &stt) == 0 && S_ISREG(stt.st_mode);
57 inline void raise_flag(
const char *name) {
58 const char *path = flag_name(name);
59 FILE *fp = fopen(path,
"w");
64 struct valgrind_info {
72 wanted = flag_exists(
"flag.valgrind");
73 leaks = flag_exists(
"flag.valgrind.leaks");
74 reachable = flag_exists(
"flag.valgrind.reachable");
78 inline const valgrind_info& get_valgrind_info() {
79 static valgrind_info vinfo;
89 const valgrind_info& valgrind = get_valgrind_info();
90 if (valgrind.wanted) {
91 const char *switches = valgrind.leaks ? (valgrind.reachable ?
"-l -r" :
"-l") :
"";
92 char *valgrinded_command =
GBS_global_string_copy(
"$ARBHOME/UNIT_TESTER/valgrind/arb_valgrind_logged CALL %s -c 15 %s", switches, command);
93 freeset(command, valgrinded_command);
95 utvg::raise_flag(UTVG_CALL_SEEN);
104 #define make_valgrinded_call(command) arb_assert(!find_pipe_symbol(command))
112 #error ut_valgrinded.h included twice
113 #endif // UT_VALGRINDED_H
const char * find_pipe_symbol(const char *str)
bool seen_valgrinded_call()
#define make_valgrinded_call(command)
#define IF_ASSERTION_USED(x)
bool will_valgrind_calls()
char * GBS_global_string_copy(const char *templat,...)
GB_write_int const char s