Skip to content
Commits on Source (4)
// ================================================================ //
// //
// File : ut_valgrinded.h //
// Purpose : wrapper to call subprocesses inside valgrind //
// //
// Coded by Ralf Westram (coder@reallysoft.de) in February 2011 //
// Institute of Microbiology (Technical University Munich) //
// http://www.arb-home.de/ //
// //
// ================================================================ //
#ifndef UT_VALGRINDED_H
#define UT_VALGRINDED_H
#ifdef UNIT_TESTS
#ifndef ARB_MSG_H
#include <arb_msg.h>
#endif
#ifndef _SYS_STAT_H
#include <sys/stat.h>
#endif
#define UTVG_CALL_SEEN "flag.valgrind.callseen"
namespace utvg {
inline const char *flag_name(const char *name) {
const char *ARBHOME = getenv("ARBHOME");
const int BUFSIZE = 200;
static char buf[BUFSIZE];
IF_ASSERTION_USED(int printed =)
snprintf(buf, BUFSIZE, "%s/UNIT_TESTER/valgrind/%s", ARBHOME, name);
arb_assert(printed<BUFSIZE);
return buf;
}
inline bool flag_exists(const char *name) {
const char *path = flag_name(name);
struct stat stt;
return stat(path, &stt) == 0 && S_ISREG(stt.st_mode);
}
inline void raise_flag(const char *name) {
const char *path = flag_name(name);
FILE *fp = fopen(path, "w");
arb_assert(fp);
fclose(fp);
}
struct valgrind_info {
bool wanted;
bool leaks;
bool reachable;
valgrind_info() {
// The following flag files are generated by ../UNIT_TESTER/Makefile.suite
// which reads the settings from ../UNIT_TESTER/Makefile.setup.local
wanted = flag_exists("flag.valgrind");
leaks = flag_exists("flag.valgrind.leaks");
reachable = flag_exists("flag.valgrind.reachable");
}
};
inline const valgrind_info& get_valgrind_info() {
static valgrind_info vinfo;
return vinfo;
}
};
inline void make_valgrinded_call(char *&command) {
using namespace utvg;
const valgrind_info& valgrind = get_valgrind_info();
if (valgrind.wanted) {
// #define VALGRIND_ONLY_SOME
#if defined(VALGRIND_ONLY_SOME)
bool perform_valgrind = false;
perform_valgrind = perform_valgrind || strstr(command, "arb_pt_server");
perform_valgrind = perform_valgrind || strstr(command, "arb_primer");
if (!perform_valgrind) return;
#endif
const char *switches = valgrind.leaks ? (valgrind.reachable ? "-l -r" : "-l") : "";
char *valgrinded_command = GBS_global_string_copy("$ARBHOME/UNIT_TESTER/valgrind/arb_valgrind_logged CALL %s -c 15 %s", switches, command);
freeset(command, valgrinded_command);
utvg::raise_flag(UTVG_CALL_SEEN);
}
}
inline bool will_valgrind_calls() { return utvg::get_valgrind_info().wanted; }
inline bool seen_valgrinded_call() { return utvg::flag_exists(UTVG_CALL_SEEN); }
#else // !UNIT_TESTS
#define make_valgrinded_call(command)
inline bool will_valgrind_calls() { return false; }
inline bool seen_valgrinded_call() { return false; }
#endif // UNIT_TESTS
#else
#error ut_valgrinded.h included twice
#endif // UT_VALGRINDED_H
......@@ -65,6 +65,7 @@ Files-Excluded: arbsrc*/AISC_COM/Makefile
arbsrc*/SOURCE_TOOLS/r*
arbsrc*/SOURCE_TOOLS/s*
arbsrc*/SOURCE_TOOLS/t*
arbsrc*/SOURCE_TOOLS/update_config_makefile.pl
arbsrc*/SOURCE_TOOLS/valgrind2grep
arbsrc*/ST*
arbsrc*/TEMPLATES/C*
......@@ -124,7 +125,7 @@ Files-Excluded: arbsrc*/AISC_COM/Makefile
arbsrc*/etc
arbsrc*/l*
arbsrc*/ptpan*
arbsrc*/u*
arbsrc*/util
Files: *
Copyright: 1994-2011
......
......@@ -336,7 +336,7 @@ Description: Strip everything from ARB Makefiles that's not contained in the
build: arb
- $(MAKE) binlink preplib compile_compatibility
+ $(MAKE) core db SL/HELIX/HELIX.dummy SL/PTCLEAN/PTCLEAN.dummy PROBE_COM/PROBE_COM.dummy
+ $(MAKE) core db SL/HELIX/HELIX.dummy SL/PTCLEAN/PTCLEAN.dummy PROBE_COM/PROBE_COM.dummy PROBE/PROBE.dummy
all:
@echo "Build time" > $(TIMELOG)
......
......@@ -38,13 +38,20 @@ config.makefile: config.makefile.template
override_dh_auto_build:
ln -s TEMPLATES INCLUDE
for header in CORE/*.h UNIT_TESTER/*.h SL/CB/*.h WINDOW/*.hxx ARBDB/*.h ; do ln -s ../$${header} INCLUDE/`basename $${header}` ; done
for header in CORE/*.h UNIT_TESTER/*.h SL/CB/*.h SL/PTCLEAN/*.h WINDOW/*.hxx ARBDB/*.h AISC_COM/C/*.h SERVERCNTRL/*.h ; \
do ln -s ../$${header} INCLUDE/`basename $${header}` ; \
done
ln -s /usr/include/valgrind/valgrind.h INCLUDE/valgrind.h
ln -s ../AISC_COM/AISC PROBE_COM/AISC
ln -s ../AISC_COM/C PROBE_COM/C
ln -s ../PROBE_COM/PT_com.h INCLUDE/PT_com.h
ln -s ../PROBE_COM/PT_server.h INCLUDE/PT_server.h
ln -s ../PROBE_COM/PT_server_prototypes.h INCLUDE/PT_server_prototypes.h
ln -s ../SL/HELIX/BI_basepos.hxx INCLUDE/BI_basepos.hxx
mkdir bin
mkdir lib
dh_auto_build -- all # --sourcedirectory=CORE
# FIXME: --no-parallel is just for debugging
dh_auto_build --no-parallel -- all # --sourcedirectory=CORE
override_dh_auto_configure: config.makefile
......@@ -62,6 +69,7 @@ override_dh_auto_clean: config.makefile
rm -rf INCLUDE
rm -rf AISC/aisc
rm -rf AISC_MKPTPS/aisc_mkpt
rm -rf PROBE_COM/DUMP PROBE_COM/GENC PROBE_COM/GENH
rm config.makefile
# ARB does not have "distclean" or "realclean". Remove some leftovers:
rm -f UNIT_TESTER/Makefile.setup.local
......