Move the last remaining tests out of corecheck.
Also introduced VG_(showing_core_errors)() to make core error display
more consistent.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4073 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/corecheck/tests/Makefile.am b/corecheck/tests/Makefile.am
index 319c8de..d1a9ba9 100644
--- a/corecheck/tests/Makefile.am
+++ b/corecheck/tests/Makefile.am
@@ -1,24 +1 @@
-##---------------------------------------------------------------------------
-## These test core error checking, eg. "silly values" for malloc/calloc,
-## pthread errors (and suppressions), signal handling errors, invalid fds for
-## blocking syscalls, etc.
-##---------------------------------------------------------------------------
-
noinst_SCRIPTS = filter_stderr
-
-EXTRA_DIST = $(noinst_SCRIPTS) \
- erringfds.stderr.exp erringfds.stdout.exp erringfds.vgtest \
- sigkill.stderr.exp sigkill.stderr.exp2 sigkill.vgtest \
- stack_changes.vgtest
-
-check_PROGRAMS = \
- erringfds sigkill stack_changes
-
-AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g -O0
-AM_CPPFLAGS = -I$(top_srcdir)/include
-AM_CXXFLAGS = $(AM_CFLAGS)
-
-sigkill_SOURCES = sigkill.c
-
-# Stack tests
-stack_changes_SOURCES = stack_changes.c
diff --git a/corecheck/tests/erringfds.stderr.exp b/corecheck/tests/erringfds.stderr.exp
deleted file mode 100644
index b6a487d..0000000
--- a/corecheck/tests/erringfds.stderr.exp
+++ /dev/null
@@ -1,4 +0,0 @@
-
-Warning: invalid file descriptor -1 in syscall read()
-
-ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c
index cf6cfb0..364c38c 100644
--- a/coregrind/m_errormgr.c
+++ b/coregrind/m_errormgr.c
@@ -231,6 +231,13 @@
/*--- Helper fns ---*/
/*------------------------------------------------------------*/
+// Only show core errors if the tool wants to, we're not running with -q,
+// and were not outputting XML.
+Bool VG_(showing_core_errors)(void)
+{
+ return VG_(needs).core_errors && VG_(clo_verbosity) >= 1 && !VG_(clo_xml);
+}
+
/* Compare error contexts, to detect duplicates. Note that if they
are otherwise the same, the faulting addrs and associated rwoffsets
are allowed to be different. */
diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c
index fc66e23..248d298 100644
--- a/coregrind/m_signals.c
+++ b/coregrind/m_signals.c
@@ -617,8 +617,7 @@
return VG_(mk_SysRes_Success)( 0 );
bad_signo:
- if (VG_(needs).core_errors && VG_(clo_verbosity) >= 1
- && !VG_(clo_xml)) {
+ if (VG_(showing_core_errors)()) {
VG_(message)(Vg_UserMsg,
"Warning: bad signal number %d in sigaction()",
signo);
@@ -626,8 +625,7 @@
return VG_(mk_SysRes_Error)( VKI_EINVAL );
bad_signo_reserved:
- if (VG_(needs).core_errors && VG_(clo_verbosity) >= 1
- && !VG_(clo_xml)) {
+ if (VG_(showing_core_errors)()) {
VG_(message)(Vg_UserMsg,
"Warning: ignored attempt to set %s handler in sigaction();",
signame(signo));
@@ -638,8 +636,7 @@
return VG_(mk_SysRes_Error)( VKI_EINVAL );
bad_sigkill_or_sigstop:
- if (VG_(needs).core_errors && VG_(clo_verbosity) >= 1
- && !VG_(clo_xml)) {
+ if (VG_(showing_core_errors)()) {
VG_(message)(Vg_UserMsg,
"Warning: ignored attempt to set %s handler in sigaction();",
signame(signo));
diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c
index cbef16b..69a793d 100644
--- a/coregrind/m_syswrap/syswrap-generic.c
+++ b/coregrind/m_syswrap/syswrap-generic.c
@@ -33,6 +33,7 @@
#include "pub_core_debuginfo.h" // Needed for pub_core_aspacemgr :(
#include "pub_core_aspacemgr.h"
#include "pub_core_debuglog.h"
+#include "pub_core_errormgr.h"
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
#include "pub_core_libcfile.h"
@@ -857,7 +858,9 @@
/* Return true if we're allowed to use or create this fd */
Bool ML_(fd_allowed)(Int fd, const Char *syscallname, ThreadId tid, Bool soft)
{
- if (fd < 0 || fd >= VG_(fd_hard_limit) || fd == VG_(clo_log_fd)) {
+ if ((fd < 0 || fd >= VG_(fd_hard_limit) || fd == VG_(clo_log_fd)) &&
+ VG_(showing_core_errors)())
+ {
VG_(message)(Vg_UserMsg,
"Warning: invalid file descriptor %d in syscall %s()",
fd, syscallname);
diff --git a/coregrind/pub_core_errormgr.h b/coregrind/pub_core_errormgr.h
index 4483555..bcd1f3b 100644
--- a/coregrind/pub_core_errormgr.h
+++ b/coregrind/pub_core_errormgr.h
@@ -1,3 +1,4 @@
+
/*--------------------------------------------------------------------*/
/*--- ErrorMgr: management of errors and suppressions. ---*/
/*--- pub_core_errormgr.h ---*/
@@ -55,6 +56,8 @@
extern Bool VG_(is_action_requested) ( Char* action, Bool* clo );
+extern Bool VG_(showing_core_errors) ( void );
+
extern UInt VG_(get_n_errs_found) ( void );
#endif // __PUB_CORE_ERRORMGR_H
diff --git a/include/pub_tool_tooliface.h b/include/pub_tool_tooliface.h
index 92e413a..3482c01 100644
--- a/include/pub_tool_tooliface.h
+++ b/include/pub_tool_tooliface.h
@@ -130,8 +130,9 @@
extern void VG_(needs_libc_freeres) ( void );
/* Want to have errors detected by Valgrind's core reported? Includes:
- - pthread API errors (many; eg. unlocking a non-locked mutex)
- - invalid file descriptors to blocking syscalls read() and write()
+ - pthread API errors (many; eg. unlocking a non-locked mutex)
+ [currently disabled]
+ - invalid file descriptors to syscalls like read() and write()
- bad signal numbers passed to sigaction()
- attempt to install signal handler for SIGKILL or SIGSTOP */
extern void VG_(needs_core_errors) ( void );
diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am
index bb1537f..85d2eed 100644
--- a/memcheck/tests/Makefile.am
+++ b/memcheck/tests/Makefile.am
@@ -23,6 +23,7 @@
custom_alloc.stderr.exp custom_alloc.vgtest \
describe-block.stderr.exp describe-block.vgtest \
doublefree.stderr.exp doublefree.vgtest \
+ erringfds.stderr.exp erringfds.stdout.exp erringfds.vgtest \
error_counts.stderr.exp error_counts.stdout.exp error_counts.vgtest \
errs1.stderr.exp errs1.vgtest \
exitprog.stderr.exp exitprog.vgtest \
@@ -65,8 +66,10 @@
realloc2.stderr.exp realloc2.vgtest \
realloc3.stderr.exp realloc3.vgtest \
sigaltstack.stderr.exp sigaltstack.vgtest \
+ sigkill.stderr.exp sigkill.stderr.exp2 sigkill.vgtest \
signal2.stderr.exp signal2.stdout.exp signal2.vgtest \
sigprocmask.stderr.exp sigprocmask.vgtest \
+ stack_changes.stderr.exp stack_changes.stdout.exp stack_changes.vgtest \
strchr.stderr.exp strchr.vgtest \
str_tester.stderr.exp str_tester.vgtest \
supp1.stderr.exp supp1.vgtest \
@@ -88,7 +91,7 @@
badloop badpoll badrw brk brk2 buflen_check \
clientperm custom_alloc \
describe-block \
- doublefree error_counts errs1 exitprog execve execve2 \
+ doublefree error_counts errs1 exitprog execve execve2 erringfds \
fprw fwrite hello inits inline \
leak-0 leak-cycle leak-tree leak-regroot leakotron \
malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \
@@ -99,8 +102,8 @@
pointer-trace \
post-syscall \
realloc1 realloc2 realloc3 \
- sigaltstack signal2 sigprocmask \
- strchr str_tester supp1 supp2 suppfree \
+ sigaltstack signal2 sigprocmask sigkill \
+ stack_changes strchr str_tester supp1 supp2 suppfree \
trivialleak weirdioctl \
mismatches new_override metadata \
vgtest_ume xml1 \
@@ -112,18 +115,18 @@
AM_CXXFLAGS = $(AM_CFLAGS)
# C ones
-addressable_SOURCES = addressable.c
-badaddrvalue_SOURCES = badaddrvalue.c
-badfree_SOURCES = badfree.c
-badjump_SOURCES = badjump.c
-badjump2_SOURCES = badjump2.c
-badloop_SOURCES = badloop.c
-badpoll_SOURCES = badpoll.c
-badrw_SOURCES = badrw.c
-brk_SOURCES = brk.c
-brk2_SOURCES = brk2.c
-buflen_check_SOURCES = buflen_check.c
-clientperm_SOURCES = clientperm.c
+#addressable_SOURCES = addressable.c
+#badaddrvalue_SOURCES = badaddrvalue.c
+#badfree_SOURCES = badfree.c
+#badjump_SOURCES = badjump.c
+#badjump2_SOURCES = badjump2.c
+#badloop_SOURCES = badloop.c
+#badpoll_SOURCES = badpoll.c
+#badrw_SOURCES = badrw.c
+#brk_SOURCES = brk.c
+#brk2_SOURCES = brk2.c
+#buflen_check_SOURCES = buflen_check.c
+#clientperm_SOURCES = clientperm.c
custom_alloc_SOURCES = custom_alloc.c
describe_block_SOURCES = describe-block.c
doublefree_SOURCES = doublefree.c
@@ -159,13 +162,15 @@
overlap_SOURCES = overlap.c
# Don't allow GCC to inline memcpy(), because then we can't intercept it
overlap_CFLAGS = $(AM_CFLAGS) -fno-builtin-memcpy
-pointer_trace_SOURCES = pointer-trace.c
+#pointer_trace_SOURCES = pointer-trace.c
post_syscall_SOURCES = post-syscall.c
realloc1_SOURCES = realloc1.c
realloc2_SOURCES = realloc2.c
realloc3_SOURCES = realloc3.c
+sigkill_SOURCES = sigkill.c
signal2_SOURCES = signal2.c
sigprocmask_SOURCES = sigprocmask.c
+stack_changes_SOURCES = stack_changes.c
supp1_SOURCES = supp.c
supp2_SOURCES = supp.c
suppfree_SOURCES = suppfree.c
diff --git a/corecheck/tests/erringfds.c b/memcheck/tests/erringfds.c
similarity index 100%
rename from corecheck/tests/erringfds.c
rename to memcheck/tests/erringfds.c
diff --git a/memcheck/tests/erringfds.stderr.exp b/memcheck/tests/erringfds.stderr.exp
new file mode 100644
index 0000000..0516e09
--- /dev/null
+++ b/memcheck/tests/erringfds.stderr.exp
@@ -0,0 +1,8 @@
+
+Warning: invalid file descriptor -1 in syscall read()
+
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
+For a detailed leak analysis, rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v
diff --git a/corecheck/tests/erringfds.stdout.exp b/memcheck/tests/erringfds.stdout.exp
similarity index 100%
rename from corecheck/tests/erringfds.stdout.exp
rename to memcheck/tests/erringfds.stdout.exp
diff --git a/corecheck/tests/erringfds.vgtest b/memcheck/tests/erringfds.vgtest
similarity index 100%
rename from corecheck/tests/erringfds.vgtest
rename to memcheck/tests/erringfds.vgtest
diff --git a/corecheck/tests/sigkill.c b/memcheck/tests/sigkill.c
similarity index 100%
rename from corecheck/tests/sigkill.c
rename to memcheck/tests/sigkill.c
diff --git a/corecheck/tests/sigkill.stderr.exp b/memcheck/tests/sigkill.stderr.exp
similarity index 94%
rename from corecheck/tests/sigkill.stderr.exp
rename to memcheck/tests/sigkill.stderr.exp
index b71799d..7dbb0d4 100644
--- a/corecheck/tests/sigkill.stderr.exp
+++ b/memcheck/tests/sigkill.stderr.exp
@@ -196,3 +196,7 @@
ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
+For a detailed leak analysis, rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v
diff --git a/corecheck/tests/sigkill.stderr.exp2 b/memcheck/tests/sigkill.stderr.exp2
similarity index 94%
rename from corecheck/tests/sigkill.stderr.exp2
rename to memcheck/tests/sigkill.stderr.exp2
index 896213f..3cc3559 100644
--- a/corecheck/tests/sigkill.stderr.exp2
+++ b/memcheck/tests/sigkill.stderr.exp2
@@ -196,3 +196,7 @@
ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
+For a detailed leak analysis, rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v
diff --git a/corecheck/tests/sigkill.stderr.exp3 b/memcheck/tests/sigkill.stderr.exp3
similarity index 94%
rename from corecheck/tests/sigkill.stderr.exp3
rename to memcheck/tests/sigkill.stderr.exp3
index a538a53..dfe6548 100644
--- a/corecheck/tests/sigkill.stderr.exp3
+++ b/memcheck/tests/sigkill.stderr.exp3
@@ -196,3 +196,7 @@
ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
+For a detailed leak analysis, rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v
diff --git a/corecheck/tests/sigkill.vgtest b/memcheck/tests/sigkill.vgtest
similarity index 100%
rename from corecheck/tests/sigkill.vgtest
rename to memcheck/tests/sigkill.vgtest
diff --git a/corecheck/tests/stack_changes.c b/memcheck/tests/stack_changes.c
similarity index 100%
rename from corecheck/tests/stack_changes.c
rename to memcheck/tests/stack_changes.c
diff --git a/corecheck/tests/stack_changes.stderr.exp b/memcheck/tests/stack_changes.stderr.exp
similarity index 100%
rename from corecheck/tests/stack_changes.stderr.exp
rename to memcheck/tests/stack_changes.stderr.exp
diff --git a/corecheck/tests/stack_changes.stdout.exp b/memcheck/tests/stack_changes.stdout.exp
similarity index 100%
rename from corecheck/tests/stack_changes.stdout.exp
rename to memcheck/tests/stack_changes.stdout.exp
diff --git a/corecheck/tests/stack_changes.vgtest b/memcheck/tests/stack_changes.vgtest
similarity index 100%
rename from corecheck/tests/stack_changes.vgtest
rename to memcheck/tests/stack_changes.vgtest