|
From: Nicholas N. <nj...@ca...> - 2004-01-21 17:35:31
|
CVS commit by nethercote:
Change test so output doesn't depend on thread scheduling.
M +2 -2 threadederrno.c 1.3 [POSSIBLY UNSAFE: printf]
M +2 -2 threadederrno.stdout.exp 1.3
--- valgrind/memcheck/tests/threadederrno.c #1.2:1.3
@@ -9,5 +9,5 @@ void* thr2 ( void* v )
{
FILE* f = fopen("bogus2", "r");
- printf("f2 = %p, errno2 = %d (%s)\n", f, errno, strerror(errno));
+ printf("f = %p, errno = %d (%s)\n", f, errno, strerror(errno));
return NULL;
}
@@ -16,5 +16,5 @@ void* thr3 ( void* v )
{
FILE* f = fopen("bogus3", "r");
- printf("f3 = %p, errno3 = %d (%s)\n", f, errno, strerror(errno));
+ printf("f = %p, errno = %d (%s)\n", f, errno, strerror(errno));
return NULL;
}
--- valgrind/memcheck/tests/threadederrno.stdout.exp #1.2:1.3
@@ -1,3 +1,3 @@
f1 = (nil), errno1 = 2 (No such file or directory)
-f2 = (nil), errno2 = 2 (No such file or directory)
-f3 = (nil), errno3 = 2 (No such file or directory)
+f = (nil), errno = 2 (No such file or directory)
+f = (nil), errno = 2 (No such file or directory)
|
|
From: Nicholas N. <nj...@ca...> - 2004-01-21 17:40:46
|
CVS commit by nethercote:
Make output more thread-independent.
M +1 -1 threadederrno.c 1.4 [POSSIBLY UNSAFE: printf]
M +1 -1 threadederrno.stdout.exp 1.4
--- valgrind/memcheck/tests/threadederrno.c #1.3:1.4
@@ -28,5 +28,5 @@ int main ( void )
pthread_create(&tid3, NULL, &thr3, NULL);
f = fopen("bogus", "r");
- printf("f1 = %p, errno1 = %d (%s)\n", f, errno, strerror(errno));
+ printf("f = %p, errno = %d (%s)\n", f, errno, strerror(errno));
pthread_join(tid2, NULL);
pthread_join(tid3, NULL);
--- valgrind/memcheck/tests/threadederrno.stdout.exp #1.3:1.4
@@ -1,3 +1,3 @@
-f1 = (nil), errno1 = 2 (No such file or directory)
+f = (nil), errno = 2 (No such file or directory)
f = (nil), errno = 2 (No such file or directory)
f = (nil), errno = 2 (No such file or directory)
|
|
From: Nicholas N. <nj...@ca...> - 2004-10-14 08:38:10
|
CVS commit by nethercote:
Added a unit self-test -- a test program that incorporates a small part of
Valgrind itself (the files ume.c, ume_entry.c and jmp_with_stack.c). Thus,
we are using Memcheck to check these files in a unit test setting.
I hope to do unit self-testing for many more parts of Valgrind, eventually all
the bits that can be pulled out into any kind of sensible stand-alone form.
Doing so achieves two things:
a) it introduces unit testing into our framework (a serious shortcoming at the
moment)
b) it lets us use Valgrind (esp. Memcheck) on itself, to some extent
This should help reliability. This first unit self-test isn't very exhaustive,
but it's a start.
Note that this involves something like bootstrapping, in that we are checking
parts of a Valgrind build with itself. I don't think this will be a problem,
since we (at least, I do) tend to only run the regtests when we think the
Valgrind build is ok.
A hello.c 1.1 [POSSIBLY UNSAFE: printf] [no copyright]
A vgtest_ume.c 1.1 [no copyright]
A vgtest_ume.stderr.exp 1.1
A vgtest_ume.vgtest 1.1
M +2 -0 .cvsignore 1.17
M +15 -2 Makefile.am 1.44
--- valgrind/memcheck/tests/.cvsignore #1.16:1.17
@@ -22,4 +22,5 @@
fprw
fwrite
+hello
inits
inline
@@ -50,4 +51,5 @@
trivialleak
tronical
+vgtest_ume
weirdioctl
*.stdout.diff
--- valgrind/memcheck/tests/Makefile.am #1.43:1.44
@@ -76,4 +76,5 @@
threadederrno.stderr.exp threadederrno.stdout.exp \
threadederrno.vgtest \
+ vgtest_ume.stderr.exp vgtest_ume.vgtest \
writev.stderr.exp writev.vgtest \
zeropage.stderr.exp zeropage.stderr.exp2 zeropage.vgtest
@@ -84,5 +85,5 @@
clientperm custom_alloc \
doublefree error_counts errs1 exitprog execve execve2 \
- fpeflags fprw fwrite inits inline \
+ fpeflags fprw fwrite hello inits inline \
malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \
memalign_test memalign2 memcmptest mempool mmaptest \
@@ -91,5 +92,8 @@
realloc1 realloc2 realloc3 sigaltstack signal2 supp1 supp2 suppfree \
trivialleak tronical weirdioctl \
- mismatches new_override metadata threadederrno writev zeropage
+ mismatches new_override metadata threadederrno \
+ vgtest_ume \
+ writev zeropage
+
AM_CPPFLAGS = -I$(top_srcdir)/include
@@ -149,4 +153,5 @@
threadederrno_SOURCES = threadederrno.c
threadederrno_LDADD = -lpthread
+vgtest_ume_SOURCES = vgtest_ume.c
writev_SOURCES = writev.c
zeropage_SOURCES = zeropage.c
@@ -157,4 +162,12 @@
new_override_SOURCES = new_override.cpp
+# Valgrind unit self-tests
+hello_SOURCES = hello.c
+hello_LDFLAGS = -Wl,-defsym,kickstart_base=0x50000000 \
+ -Wl,-T,../../coregrind/${VG_ARCH}/stage2.lds
+vgtest_ume_LDADD = ../../coregrind/ume.o \
+ ../../coregrind/ume_entry.o \
+ ../../coregrind/jmp_with_stack.o
+
# must be built with these flags -- bug only occurred with them
fpeflags.o: CFLAGS += -march=i686
|
|
From: Nicholas N. <nj...@ca...> - 2004-10-14 08:52:51
|
CVS commit by nethercote:
Strengthened the unit self-test, by also testing foreach_map(), the other
function exported by ume.c.
M +42 -2 vgtest_ume.c 1.2 [POSSIBLY UNSAFE: printf]
M +2 -0 vgtest_ume.stderr.exp 1.2
--- valgrind/memcheck/tests/vgtest_ume.c #1.1:1.2
@@ -11,4 +11,36 @@
#define STKSZ (64*1024)
+//-------------------------------------------------------------------
+// Test foreach_map()
+//-------------------------------------------------------------------
+
+static int x;
+
+static int f(char *start, char *end, const char *perm, off_t off,
+ int maj, int min, int ino, void* dummy) {
+ // Just do some nonsense action with each of the values so that Memcheck
+ // checks that they are valid.
+ x = ( start == 0 ? 0 : 1 );
+ x = ( end == 0 ? 0 : 1 );
+ x = ( perm == 0 ? 0 : 1 );
+ x = ( off == 0 ? 0 : 1 );
+ x = ( maj == 0 ? 0 : 1 );
+ x = ( min == 0 ? 0 : 1 );
+ x = ( ino == 0 ? 0 : 1 );
+ x = ( dummy == 0 ? 0 : 1 );
+
+ return /*True*/1;
+}
+
+static void test__foreach_map(void)
+{
+ fprintf(stderr, "Calling foreach_map()\n");
+ foreach_map(f, /*dummy*/NULL);
+}
+
+//-------------------------------------------------------------------
+// Test do_exec()
+//-------------------------------------------------------------------
+
static void push_auxv(unsigned char **espp, int type, void *val)
{
@@ -27,6 +59,5 @@ static void push(unsigned char **espp, v
}
-
-int main(void)
+static void test__do_exec(void)
{
struct exeinfo info;
@@ -40,4 +71,5 @@ int main(void)
info.map_base = 0x51000000;
+ fprintf(stderr, "Calling do_exec(\"hello\")\n");
err = do_exec("hello", &info);
assert(0 == err);
@@ -72,4 +104,12 @@ int main(void)
jmp_with_stack(info.init_eip, (addr_t)esp);
+ assert(0); // UNREACHABLE
+}
+
+int main(void)
+{
+ test__foreach_map();
+ test__do_exec();
+
return 0;
}
--- valgrind/memcheck/tests/vgtest_ume.stderr.exp #1.1:1.2
@@ -1 +1,3 @@
+Calling foreach_map()
+Calling do_exec("hello")
Hello, world!
|
|
From: Nicholas N. <nj...@ca...> - 2004-10-14 09:28:19
|
CVS commit by nethercote:
Further strengthened the unit self-test, by also testing find_auxv(). Now all
functions exported by ume.c are tested.
M +2 -1 Makefile.am 1.45
M +31 -0 vgtest_ume.c 1.3 [POSSIBLY UNSAFE: printf]
M +1 -0 vgtest_ume.stderr.exp 1.3
--- valgrind/memcheck/tests/Makefile.am #1.44:1.45
@@ -153,5 +153,4 @@
threadederrno_SOURCES = threadederrno.c
threadederrno_LDADD = -lpthread
-vgtest_ume_SOURCES = vgtest_ume.c
writev_SOURCES = writev.c
zeropage_SOURCES = zeropage.c
@@ -166,4 +165,6 @@
hello_LDFLAGS = -Wl,-defsym,kickstart_base=0x50000000 \
-Wl,-T,../../coregrind/${VG_ARCH}/stage2.lds
+vgtest_ume_SOURCES = vgtest_ume.c
+vgtest_ume_LDFLAGS = -Wl,-e,_ume_entry
vgtest_ume_LDADD = ../../coregrind/ume.o \
../../coregrind/ume_entry.o \
--- valgrind/memcheck/tests/vgtest_ume.c #1.2:1.3
@@ -40,4 +40,34 @@ static void test__foreach_map(void)
//-------------------------------------------------------------------
+// Test find_auxv()
+//-------------------------------------------------------------------
+
+static void test__find_auxv(void)
+{
+ struct ume_auxv *auxv;
+
+ assert(ume_exec_esp != NULL);
+
+ fprintf(stderr, "Calling find_auxv()\n");
+ auxv = find_auxv((int*)ume_exec_esp);
+
+ // Check the auxv value looks sane
+ assert((void*)auxv > (void*)ume_exec_esp);
+ assert((unsigned int)auxv - (unsigned int)ume_exec_esp < 0x10000);
+
+ // Scan the auxv, check it looks sane
+ for (; auxv->a_type != AT_NULL; auxv++) {
+ switch(auxv->a_type) {
+ // Check a_type value looks like a plausible small constant
+ case 1 ... 64:
+ break;
+
+ default:
+ assert(0);
+ }
+ }
+}
+
+//-------------------------------------------------------------------
// Test do_exec()
//-------------------------------------------------------------------
@@ -110,4 +140,5 @@ int main(void)
{
test__foreach_map();
+ test__find_auxv();
test__do_exec();
--- valgrind/memcheck/tests/vgtest_ume.stderr.exp #1.2:1.3
@@ -1,3 +1,4 @@
Calling foreach_map()
+Calling find_auxv()
Calling do_exec("hello")
Hello, world!
|
|
From: Nicholas N. <nj...@ca...> - 2004-10-20 11:43:09
|
CVS commit by nethercote:
Arch-abstraction:
- move remaining x86-specific Memcheck tests into an x86/ subdir.
A x86/filter_pushfpopf 1.1
A x86/filter_tronical 1.1
A x86/fpeflags.c 1.1 [no copyright]
A x86/fpeflags.stderr.exp 1.1
A x86/fpeflags.vgtest 1.1
A x86/pushfpopf.stderr.exp 1.1
A x86/pushfpopf.stdout.exp 1.1
A x86/pushfpopf.vgtest 1.1
A x86/pushfpopf_c.c 1.1 [POSSIBLY UNSAFE: printf] [no copyright]
A x86/pushfpopf_s.s 1.1
A x86/tronical.S 1.1
A x86/tronical.stderr.exp 1.1
A x86/tronical.vgtest 1.1
M +0 -3 .cvsignore 1.19
M +4 -13 Makefile.am 1.49
M +3 -0 x86/.cvsignore 1.2
M +18 -2 x86/Makefile.am 1.2
R filter_pushfpopf 1.2
R filter_tronical 1.2
R fpeflags.c 1.2
R fpeflags.stderr.exp 1.1
R fpeflags.vgtest 1.1
R pushfpopf.stderr.exp 1.7
R pushfpopf.stdout.exp 1.2
R pushfpopf.vgtest 1.4
R pushfpopf_c.c 1.2
R pushfpopf_s.s 1.2
R tronical.S 1.3
R tronical.stderr.exp 1.7
R tronical.vgtest 1.4
--- valgrind/memcheck/tests/.cvsignore #1.18:1.19
@@ -19,5 +19,4 @@
filter_leak_check_size
filter_stderr
-fpeflags
fprw
fwrite
@@ -41,5 +40,4 @@
null_socket
overlap
-pushfpopf
realloc1
realloc2
@@ -50,5 +48,4 @@
suppfree
trivialleak
-tronical
vgtest_ume
weirdioctl
--- valgrind/memcheck/tests/Makefile.am #1.48:1.49
@@ -2,6 +2,5 @@
noinst_SCRIPTS = filter_allocs filter_leak_check_size \
- filter_stderr filter_stderr_backtrace filter_pushfpopf \
- filter_tronical
+ filter_stderr filter_stderr_backtrace
EXTRA_DIST = $(noinst_SCRIPTS) \
@@ -26,5 +25,4 @@
execve.stderr.exp execve.vgtest \
execve2.stderr.exp execve2.vgtest \
- fpeflags.stderr.exp fpeflags.vgtest \
fprw.stderr.exp fprw.vgtest \
fwrite.stderr.exp fwrite.stdout.exp fwrite.vgtest \
@@ -50,5 +48,4 @@
overlap.stderr.exp overlap.stdout.exp overlap.vgtest \
pth_once.stderr.exp pth_once.stdout.exp pth_once.vgtest \
- pushfpopf.stderr.exp pushfpopf.stdout.exp pushfpopf.vgtest \
realloc1.stderr.exp realloc1.vgtest \
realloc2.stderr.exp realloc2.vgtest \
@@ -63,5 +60,4 @@
toobig-allocs.stderr.exp toobig-allocs.vgtest \
trivialleak.stderr.exp trivialleak.vgtest \
- tronical.stderr.exp tronical.vgtest \
weirdioctl.stderr.exp weirdioctl.stdout.exp weirdioctl.vgtest \
metadata.stderr.exp metadata.stdout.exp metadata.vgtest \
@@ -77,11 +73,11 @@
clientperm custom_alloc \
doublefree error_counts errs1 exitprog execve execve2 \
- fpeflags fprw fwrite hello inits inline \
+ fprw fwrite hello inits inline \
malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \
memalign_test memalign2 memcmptest mempool mmaptest \
nanoleak new_nothrow \
- null_socket overlap pushfpopf \
+ null_socket overlap \
realloc1 realloc2 realloc3 sigaltstack signal2 supp1 supp2 suppfree \
- trivialleak tronical weirdioctl \
+ trivialleak weirdioctl \
mismatches new_override metadata threadederrno \
vgtest_ume \
@@ -111,5 +107,4 @@
execve2_SOURCES = execve2.c
exitprog_SOURCES = exitprog.c
-fpeflags_SOURCES = fpeflags.c
fprw_SOURCES = fprw.c
fwrite_SOURCES = fwrite.c
@@ -130,5 +125,4 @@
null_socket_SOURCES = null_socket.c
overlap_SOURCES = overlap.c
-pushfpopf_SOURCES = pushfpopf_c.c pushfpopf_s.s
realloc1_SOURCES = realloc1.c
realloc2_SOURCES = realloc2.c
@@ -140,5 +134,4 @@
sigaltstack_SOURCES = sigaltstack.c
trivialleak_SOURCES = trivialleak.c
-tronical_SOURCES = tronical.S
weirdioctl_SOURCES = weirdioctl.c
metadata_SOURCES = metadata.c
@@ -161,4 +154,2 @@
../../coregrind/jmp_with_stack.o
-# must be built with these flags -- bug only occurred with them
-fpeflags.o: CFLAGS += -march=i686
--- valgrind/memcheck/tests/x86/.cvsignore #1.1:1.2
@@ -1,4 +1,7 @@
Makefile.in
Makefile
+fpeflags
+pushfpopf
+tronical
*.stdout.diff
*.stderr.diff*
--- valgrind/memcheck/tests/x86/Makefile.am #1.1:1.2
@@ -1,8 +1,24 @@
-noinst_SCRIPTS = filter_stderr
+noinst_SCRIPTS = filter_stderr filter_pushfpopf filter_tronical
INSN_TESTS=insn_basic insn_fpu insn_cmov insn_mmx insn_mmxext insn_sse insn_sse2
EXTRA_DIST = $(noinst_SCRIPTS) \
+ fpeflags.stderr.exp fpeflags.vgtest \
$(addsuffix .stderr.exp,$(INSN_TESTS)) \
$(addsuffix .stdout.exp,$(INSN_TESTS)) \
- $(addsuffix .vgtest,$(INSN_TESTS))
+ $(addsuffix .vgtest,$(INSN_TESTS)) \
+ pushfpopf.stderr.exp pushfpopf.stdout.exp pushfpopf.vgtest \
+ tronical.stderr.exp tronical.vgtest
+
+check_PROGRAMS = \
+ fpeflags pushfpopf tronical
+
+AM_CPPFLAGS = -I$(top_srcdir)/include
+AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g
+AM_CXXFLAGS = $(AM_CFLAGS)
+
+fpeflags_SOURCES = fpeflags.c
+# must be built with these flags -- bug only occurred with them
+fpeflags_CFLAGS = $(AM_CFLAGS) -march=i686
+pushfpopf_SOURCES = pushfpopf_c.c pushfpopf_s.s
+tronical_SOURCES = tronical.S
|
|
From: Nicholas N. <nj...@ca...> - 2004-11-07 10:58:26
|
CVS commit by nethercote:
Add very thorough string functions test from glibc.
A str_tester.c 1.1 [POSSIBLY UNSAFE: printf] [UNKNOWN]
A str_tester.stderr.exp 1.1
A str_tester.vgtest 1.1
M +5 -1 Makefile.am 1.54
--- valgrind/memcheck/tests/Makefile.am #1.53:1.54
@@ -55,4 +55,5 @@
signal2.stderr.exp \
signal2.stdout.exp signal2.vgtest \
+ str_tester.stderr.exp str_tester.vgtest \
supp1.stderr.exp supp1.vgtest \
supp2.stderr.exp supp2.vgtest \
@@ -79,5 +80,6 @@
nanoleak new_nothrow \
null_socket overlap \
- realloc1 realloc2 realloc3 sigaltstack signal2 supp1 supp2 suppfree \
+ realloc1 realloc2 realloc3 sigaltstack signal2 \
+ str_tester supp1 supp2 suppfree \
trivialleak weirdioctl \
mismatches new_override metadata threadederrno \
@@ -138,4 +140,6 @@
weirdioctl_SOURCES = weirdioctl.c
metadata_SOURCES = metadata.c
+str_tester_SOURCES = str_tester.c
+str_tester_CFLAGS = $(AM_CFLAGS) -Wno-shadow
threadederrno_SOURCES = threadederrno.c
threadederrno_LDADD = -lpthread
|