diff --git a/memcheck/tests/.cvsignore b/memcheck/tests/.cvsignore index faa43f3fe..7968ef805 100644 --- a/memcheck/tests/.cvsignore +++ b/memcheck/tests/.cvsignore @@ -5,6 +5,8 @@ badfree badjump badloop buflen_check +clientperm +clientstackperm dir doublefree errs1 diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 7cf25e7a2..fb8f0f502 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -20,6 +20,10 @@ EXTRA_DIST = \ badjump.stderr.exp badjump.vgtest \ badloop.stderr.exp badloop.vgtest \ buflen_check.stderr.exp buflen_check.stderr.exp.hd buflen_check.vgtest \ + clientperm.stderr.exp clientperm.stderr.exp.hd \ + clientperm.stdout.exp clientperm.vgtest \ + clientstackperm.stderr.exp clientstackperm.stderr.exp.hd \ + clientstackperm.stdout.exp clientstackperm.vgtest \ doublefree.stderr.exp doublefree.vgtest \ errs1.stderr.exp errs1.vgtest \ exitprog.stderr.exp exitprog.vgtest \ @@ -53,7 +57,8 @@ EXTRA_DIST = \ weirdioctl.stderr.exp weirdioctl.stdout.exp weirdioctl.vgtest noinst_PROGRAMS = \ - badaddrvalue badfree badjump badloop buflen_check \ + badaddrvalue badfree badjump badloop buflen_check clientperm \ + clientstackperm \ doublefree errs1 exitprog fprw fwrite inits inline \ malloc1 malloc2 manuel1 manuel2 manuel3 \ memalign_test memcmptest mmaptest nanoleak pushfpopf \ @@ -61,8 +66,9 @@ noinst_PROGRAMS = \ trivialleak tronical weirdioctl \ mismatches new_override -CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g +CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g CXXFLAGS = $(CFLAGS) +INCLUDES = -I$(top_srcdir)/include # C ones badaddrvalue_SOURCES = badaddrvalue.c @@ -70,6 +76,8 @@ badfree_SOURCES = badfree.c badjump_SOURCES = badjump.c badloop_SOURCES = badloop.c buflen_check_SOURCES = buflen_check.c +clientperm_SOURCES = clientperm.c +clientstackperm_SOURCES = clientstackperm.c doublefree_SOURCES = doublefree.c errs1_SOURCES = errs1.c exitprog_SOURCES = exitprog.c diff --git a/tests/clientperm.c b/memcheck/tests/clientperm.c similarity index 79% rename from tests/clientperm.c rename to memcheck/tests/clientperm.c index ee7809d80..27cb11a07 100644 --- a/tests/clientperm.c +++ b/memcheck/tests/clientperm.c @@ -2,7 +2,7 @@ #include #include -#include "valgrind.h" +#include "../memcheck.h" int main1 ( void ) { @@ -26,14 +26,14 @@ int main ( void ) for (i = 0; i < 100; i++) sum += aa[i]; - printf("sum is %d\n", sum); + printf("sum is %s\n", sum > 0 ? "positive" : "non-positive"); m = VALGRIND_DISCARD(m); printf("m_rm: returned value is %d\n", m ); for (i = 0; i < 100; i++) sum += aa[i]; - printf("sum is %d\n", sum); + printf("sum is %s\n", sum > 0 ? "positive" : "non-positive"); return 0; } diff --git a/memcheck/tests/clientperm.stderr.exp b/memcheck/tests/clientperm.stderr.exp new file mode 100644 index 000000000..37a1379d5 --- /dev/null +++ b/memcheck/tests/clientperm.stderr.exp @@ -0,0 +1,16 @@ + +Conditional jump or move depends on uninitialised value(s) + at 0x........: main (clientperm.c:29) + by 0x........: __libc_start_main (...libc...) + by 0x........: calloc@@GLIBC_2.0 (in /.../tests/clientperm) + +Conditional jump or move depends on uninitialised value(s) + at 0x........: main (clientperm.c:36) + by 0x........: __libc_start_main (...libc...) + by 0x........: calloc@@GLIBC_2.0 (in /.../tests/clientperm) + +ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0) +malloc/free: in use at exit: 100 bytes in 1 blocks. +malloc/free: 1 allocs, 0 frees, 100 bytes allocated. +For a detailed leak analysis, rerun with: --leak-check=yes +For counts of detected errors, rerun with: -v diff --git a/memcheck/tests/clientperm.stderr.exp.hd b/memcheck/tests/clientperm.stderr.exp.hd new file mode 100644 index 000000000..0f6ddc054 --- /dev/null +++ b/memcheck/tests/clientperm.stderr.exp.hd @@ -0,0 +1,11 @@ + +discard 0 (0 -> 0) translations in range 0x........ .. 0x........ +discard 0 (0 -> 0) translations in range 0x........ .. 0x........ +discard 0 (0 -> 0) translations in range 0x........ .. 0x........ +discard 0 (0 -> 0) translations in range 0x........ .. 0x........ + +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/memcheck/tests/clientperm.stdout.exp b/memcheck/tests/clientperm.stdout.exp new file mode 100644 index 000000000..7ab39d358 --- /dev/null +++ b/memcheck/tests/clientperm.stdout.exp @@ -0,0 +1,4 @@ +m_na: returned value is 0 +sum is non-positive +m_rm: returned value is 0 +sum is non-positive diff --git a/memcheck/tests/clientperm.vgtest b/memcheck/tests/clientperm.vgtest new file mode 100644 index 000000000..15289f1c9 --- /dev/null +++ b/memcheck/tests/clientperm.vgtest @@ -0,0 +1 @@ +prog: clientperm diff --git a/tests/clientstackperm.c b/memcheck/tests/clientstackperm.c similarity index 62% rename from tests/clientstackperm.c rename to memcheck/tests/clientstackperm.c index 31a50101f..1e4e79dc2 100644 --- a/tests/clientstackperm.c +++ b/memcheck/tests/clientstackperm.c @@ -3,34 +3,29 @@ #include #include -#include "valgrind.h" - +#include "../memcheck.h" int baaaad ( void ) { - int i; int spacer0[10]; - int aaa[10]; + int aaa[10] __attribute__((unused)); int spacer1[10]; - int bbb[10]; + int bbb[10] __attribute__((unused)); int spacer2[10]; - int ccc[10]; + int ccc[10] __attribute__((unused)); int spacer3[10]; VALGRIND_MAKE_NOACCESS_STACK(spacer0, sizeof spacer0); VALGRIND_MAKE_NOACCESS_STACK(spacer1, sizeof spacer1); VALGRIND_MAKE_NOACCESS_STACK(spacer2, sizeof spacer2); VALGRIND_MAKE_NOACCESS_STACK(spacer3, sizeof spacer3); - printf("reading %p\n", &aaa[-3]); + printf("reading memory\n"); + if ((int*)0xDEADBEEF == &aaa[-3]) { printf("DEAD BEEF!\n"); } return aaa[-3]; - for (i = 0; i < 10; i++) { - printf("poking addr %p\n", & spacer1[i]); - spacer0[i] = spacer1[i] = spacer2[i] = spacer3[i] = 0; - } } int main ( void ) { int z = baaaad(); - return 0; + return z; } diff --git a/memcheck/tests/clientstackperm.stderr.exp b/memcheck/tests/clientstackperm.stderr.exp new file mode 100644 index 000000000..9ca69f114 --- /dev/null +++ b/memcheck/tests/clientstackperm.stderr.exp @@ -0,0 +1,17 @@ + +Invalid read of size 4 + at 0x........: baaaad (clientstackperm.c:23) + by 0x........: main (clientstackperm.c:29) + by 0x........: __libc_start_main (...libc...) + by 0x........: (within /.../tests/clientstackperm) + Address 0x........ is 36 bytes inside a 40-byte stack red-zone created + at 0x........: baaaad (clientstackperm.c:18) + by 0x........: main (clientstackperm.c:29) + by 0x........: __libc_start_main (...libc...) + by 0x........: (within /.../tests/clientstackperm) + +ERROR SUMMARY: 1 errors from 1 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/memcheck/tests/clientstackperm.stderr.exp.hd b/memcheck/tests/clientstackperm.stderr.exp.hd new file mode 100644 index 000000000..0f6ddc054 --- /dev/null +++ b/memcheck/tests/clientstackperm.stderr.exp.hd @@ -0,0 +1,11 @@ + +discard 0 (0 -> 0) translations in range 0x........ .. 0x........ +discard 0 (0 -> 0) translations in range 0x........ .. 0x........ +discard 0 (0 -> 0) translations in range 0x........ .. 0x........ +discard 0 (0 -> 0) translations in range 0x........ .. 0x........ + +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/memcheck/tests/clientstackperm.stdout.exp b/memcheck/tests/clientstackperm.stdout.exp new file mode 100644 index 000000000..df0c0ce6b --- /dev/null +++ b/memcheck/tests/clientstackperm.stdout.exp @@ -0,0 +1 @@ +reading memory diff --git a/memcheck/tests/clientstackperm.vgtest b/memcheck/tests/clientstackperm.vgtest new file mode 100644 index 000000000..3b5b20862 --- /dev/null +++ b/memcheck/tests/clientstackperm.vgtest @@ -0,0 +1 @@ +prog: clientstackperm diff --git a/none/tests/.cvsignore b/none/tests/.cvsignore index a2ae42900..5812911b8 100644 --- a/none/tests/.cvsignore +++ b/none/tests/.cvsignore @@ -7,6 +7,7 @@ coolo_sigaction coolo_strlen cpuid dastest +discard floored fork fucomip diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index e00d485bf..ed925e5e5 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -19,6 +19,8 @@ EXTRA_DIST = \ cpuid.stderr.exp cpuid.stderr.exp.hd cpuid.stdout.exp cpuid.vgtest \ dastest.stderr.exp dastest.stderr.exp.hd dastest.stdout.exp \ dastest.vgtest \ + discard.stderr.exp discard.stderr.exp.hd discard.stdout.exp \ + discard.vgtest \ floored.stderr.exp floored.stderr.exp.hd floored.stdout.exp \ floored.vgtest \ fork.stderr.exp fork.stderr.exp.hd fork.stdout.exp fork.vgtest \ @@ -41,7 +43,7 @@ EXTRA_DIST = \ noinst_PROGRAMS = \ bitfield1 bt_everything bt_literal coolo_strlen \ - cpuid dastest floored fork fucomip munmap_exe rcl_assert \ + cpuid dastest discard floored fork fucomip munmap_exe rcl_assert \ rcrl readline1 resolv seg_override sha1_test shortpush shorts smc1 \ pth_blockedsig \ coolo_sigaction gxx304 @@ -56,6 +58,7 @@ bt_literal_SOURCES = bt_literal.c cpuid_SOURCES = cpuid_c.c cpuid_s.s coolo_strlen_SOURCES = coolo_strlen.c dastest_SOURCES = dastest_c.c dastest_s.s +discard_SOURCES = discard.c fork_SOURCES = fork.c floored_SOURCES = floored.c floored_LDADD = -lm diff --git a/tests/discard.c b/none/tests/discard.c similarity index 91% rename from tests/discard.c rename to none/tests/discard.c index 0c14e9f14..aaa1b2d32 100644 --- a/tests/discard.c +++ b/none/tests/discard.c @@ -1,6 +1,6 @@ #include -#include +#include "../../include/valgrind.h" int fooble ( void ) { diff --git a/none/tests/discard.stderr.exp b/none/tests/discard.stderr.exp new file mode 100644 index 000000000..554e63970 --- /dev/null +++ b/none/tests/discard.stderr.exp @@ -0,0 +1,3 @@ + +discard ... (... -> ...) translations in range 0x........ .. 0x........ + diff --git a/none/tests/discard.stderr.exp.hd b/none/tests/discard.stderr.exp.hd new file mode 100644 index 000000000..c4aa6f04f --- /dev/null +++ b/none/tests/discard.stderr.exp.hd @@ -0,0 +1,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/none/tests/discard.stdout.exp b/none/tests/discard.stdout.exp new file mode 100644 index 000000000..22c6cbb54 --- /dev/null +++ b/none/tests/discard.stdout.exp @@ -0,0 +1,2 @@ +fooble-1() = 1749 +fooble-2() = 1749 diff --git a/none/tests/discard.vgtest b/none/tests/discard.vgtest new file mode 100644 index 000000000..9501fc3b8 --- /dev/null +++ b/none/tests/discard.vgtest @@ -0,0 +1,2 @@ +prog: discard +stderr_filter: filter_none_discards diff --git a/tests/blocked_syscall.c b/tests/unused/blocked_syscall.c similarity index 100% rename from tests/blocked_syscall.c rename to tests/unused/blocked_syscall.c