forked from Imagelibrary/binutils-gdb
libctf: suppress spurious failure of malloc-counting tests under valgrind
The libctf-regression/open-error-free.c test works by interposing malloc and counting mallocs and frees across libctf operations. This only works under suitably-interposable mallocs on systems supporting dlsym (RTLD_NEXT, ...), so its operation is restricted to glibc systems for now, but also it interacts badly with valgrind, which interposes malloc itself. Detect a running valgrind and skip the test. Add new facilities allowing libctf lookup tests to declare themselves unsupported, by printing "UNSUPPORTED: " and then some meaningful message instead of their normal output. libctf/ * configure.ac: Check for <valgrind/valgrind.h>. * config.h.in: Regenerate. * configure: Likewise. * testsuite/lib/ctf-lib.exp (run_lookup_test): Add support for UNSUPPORTED tests. * testsuite/libctf-regression/open-error-free.c: When running under valgrind, this test is unsupported.
This commit is contained in:
@@ -115,6 +115,9 @@
|
|||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
#undef HAVE_UNISTD_H
|
#undef HAVE_UNISTD_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <valgrind/valgrind.h> header file. */
|
||||||
|
#undef HAVE_VALGRIND_VALGRIND_H
|
||||||
|
|
||||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||||
*/
|
*/
|
||||||
#undef LT_OBJDIR
|
#undef LT_OBJDIR
|
||||||
|
|||||||
2
libctf/configure
vendored
2
libctf/configure
vendored
@@ -16552,7 +16552,7 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
|
|||||||
presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
|
presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
for ac_header in byteswap.h endian.h
|
for ac_header in byteswap.h endian.h valgrind/valgrind.h
|
||||||
do :
|
do :
|
||||||
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||||
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
|
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ if test $ac_cv_libctf_bfd_elf = yes; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
AC_C_BIGENDIAN
|
AC_C_BIGENDIAN
|
||||||
AC_CHECK_HEADERS(byteswap.h endian.h)
|
AC_CHECK_HEADERS(byteswap.h endian.h valgrind/valgrind.h)
|
||||||
AC_CHECK_FUNCS(pread)
|
AC_CHECK_FUNCS(pread)
|
||||||
|
|
||||||
dnl Check for bswap_{16,32,64}
|
dnl Check for bswap_{16,32,64}
|
||||||
|
|||||||
@@ -270,6 +270,11 @@ proc run_lookup_test { name } {
|
|||||||
set results [run_host_cmd "$opts(wrapper) tmpdir/lookup" $lookup_output]
|
set results [run_host_cmd "$opts(wrapper) tmpdir/lookup" $lookup_output]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if { [regexp {^UNSUPPORTED: (.*)$} $results -> reason] } {
|
||||||
|
unsupported "$testname: $reason"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
set f [open "tmpdir/lookup.out" "w"]
|
set f [open "tmpdir/lookup.out" "w"]
|
||||||
puts $f $results
|
puts $f $results
|
||||||
close $f
|
close $f
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/* Make sure that, on error, an opened dict is properly freed. */
|
/* Make sure that, on error, an opened dict is properly freed. */
|
||||||
|
|
||||||
#define _GNU_SOURCE 1
|
#define _GNU_SOURCE 1
|
||||||
|
#include "config.h"
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -8,6 +9,10 @@
|
|||||||
#include <ctf-api.h>
|
#include <ctf-api.h>
|
||||||
#include <ctf.h>
|
#include <ctf.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_VALGRIND_VALGRIND_H
|
||||||
|
#include <valgrind/valgrind.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static unsigned long long malloc_count;
|
static unsigned long long malloc_count;
|
||||||
static unsigned long long free_count;
|
static unsigned long long free_count;
|
||||||
|
|
||||||
@@ -111,6 +116,14 @@ int main (void)
|
|||||||
ctf_next_t *it = NULL;
|
ctf_next_t *it = NULL;
|
||||||
unsigned long long frozen_malloc_count, frozen_free_count;
|
unsigned long long frozen_malloc_count, frozen_free_count;
|
||||||
|
|
||||||
|
#ifdef HAVE_VALGRIND_VALGRIND_H
|
||||||
|
if (RUNNING_ON_VALGRIND)
|
||||||
|
{
|
||||||
|
printf ("UNSUPPORTED: valgrind interferes with malloc counting\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((fp = ctf_create (&err)) == NULL)
|
if ((fp = ctf_create (&err)) == NULL)
|
||||||
goto open_err;
|
goto open_err;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user