]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Further strengthened the unit self-test, by also testing find_auxv(). Now all
authorNicholas Nethercote <n.nethercote@gmail.com>
Thu, 14 Oct 2004 09:28:11 +0000 (09:28 +0000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Thu, 14 Oct 2004 09:28:11 +0000 (09:28 +0000)
functions exported by ume.c are tested.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2762

memcheck/tests/Makefile.am
memcheck/tests/vgtest_ume.c
memcheck/tests/vgtest_ume.stderr.exp

index 9ec6929d7ee0b7ae131d0ad2225695281fca3094..18809253c661b1f33dcbf5565dd9461b371e3f36 100644 (file)
@@ -152,7 +152,6 @@ weirdioctl_SOURCES  = weirdioctl.c
 metadata_SOURCES       = metadata.c
 threadederrno_SOURCES  = threadederrno.c
 threadederrno_LDADD    = -lpthread
-vgtest_ume_SOURCES     = vgtest_ume.c
 writev_SOURCES         = writev.c
 zeropage_SOURCES       = zeropage.c
 
@@ -165,6 +164,8 @@ new_override_SOURCES        = new_override.cpp
 hello_SOURCES          = hello.c
 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 \
                          ../../coregrind/jmp_with_stack.o
index 3b8b2e352ed35f9307e1a935ff135624515fc15d..458f6f0b9fc0df4b0f9eaffa1df8d45a912ab5df 100644 (file)
@@ -38,6 +38,36 @@ static void test__foreach_map(void)
    foreach_map(f, /*dummy*/NULL);
 }
 
+//-------------------------------------------------------------------
+// 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()
 //-------------------------------------------------------------------
@@ -109,6 +139,7 @@ static void test__do_exec(void)
 int main(void)
 {
    test__foreach_map();
+   test__find_auxv();
    test__do_exec();
    
    return 0;
index d92d00ac433ea44cb49244102e0cee7cb3345058..777f9d110ef4bcd5a518f537f34d6374b0b1173e 100644 (file)
@@ -1,3 +1,4 @@
 Calling foreach_map()
+Calling find_auxv()
 Calling do_exec("hello")
 Hello, world!