|
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!
|