unit_tests/efence_tests.sh
c82d362e
 #!/bin/sh
 # Run under electric-fence
3278d230
 LIBDIRS=`../libtool --config | grep sys_lib_dlsearch_path_spec | sed -e 's/.*"\(.*\)"/\1/'`
73aeb57e
 if test -z "$LIBEFENCE"; then
9814b812
 	for i in $LIBDIRS /usr/local/lib; do
9adefc19
 		if test -f "$i/libefence.so"; then
 			LIBEFENCE="$i/libefence.so"
73aeb57e
 			break;
 		fi
 	done
 fi
c82d362e
 test -f "$LIBEFENCE" || { echo "*** electric-fence not found, skipping test"; exit 77;}
 
dcf16a7f
 # use the default EF_ALIGNMENT only for x86/x86_64, and set it to 8 for other
 # platforms. ia64 needs this for example.
 (../libtool --config | grep host=x86) || { EF_ALIGNMENT=8; export EF_ALIGNMENT; }
73aeb57e
 EF_DISABLE_BANNER=1
c82d362e
 EF_FREE_WIPES=1
 LIBPRELOAD="$LIBEFENCE"
73aeb57e
 export EF_FREE_WIPES LIBPRELOAD EF_DISABLE_BANNER
c82d362e
 VALGRIND=`which ${VALGRIND-valgrind}`
eb0e3c98
 if test ! -n "$VALGRIND" || test ! -x "$VALGRIND"; then
c82d362e
 	# run check_clamav under efence only if we don't have valgrind installed
 	echo "--- Running check_clamav under electric-fence"
f45111e5
 	CK_FORK=no ../libtool --mode=execute $abs_srcdir/preload_run.sh ./check_clamav
d9282b97
 	if test $? -ne 0; then
c82d362e
 		echo "*** Electric-fence has detected errors"
 		exit 1
 	fi
 fi
 # we don't run clamd under electric-fence, it always crashes in free(),
 # probably doesn't work well with libpthread.
 echo "--- running clamscan under electric-fence to detect overruns"
f45111e5
 CLAMSCAN_WRAPPER=$abs_srcdir/preload_run.sh $abs_srcdir/check_clamscan.sh
5dddbcb7
 if test $? -ne 0; then
c82d362e
 	echo "*** Electric-fence has detected errors"
 	exit 2
 fi
 EF_PROTECT_BELOW=1
 export EF_PROTECT_BELOW
 echo "--- running clamscan under electric-fence to detect underruns"
f45111e5
 CLAMSCAN_WRAPPER=$abs_srcdir/preload_run.sh $abs_srcdir/check_clamscan.sh
5dddbcb7
 if test $? -ne 0; then
c82d362e
 	echo "*** Electric-fence has detected errors"
 	exit 3
 fi