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