Fixed test to not assume that malloc(10) will return 10 nul bytes!


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4978 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/memcheck/tests/fwrite.c b/memcheck/tests/fwrite.c
index 1eec4a4..9334b29 100644
--- a/memcheck/tests/fwrite.c
+++ b/memcheck/tests/fwrite.c
@@ -1,9 +1,17 @@
-
+#include <fcntl.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 int main ( void )
 {
    char* arr = malloc(10);
-   (void) write( 1 /* stdout */, arr, 10 );
+   int fd = open("/dev/null", O_WRONLY);
+   if (fd < 0) {
+      fprintf(stderr, "open failed\n");
+   } else {
+      (void)write(fd, arr, 10);
+      (void)close(fd);
+   }
+
    return 0;
 }
diff --git a/memcheck/tests/fwrite.stderr.exp b/memcheck/tests/fwrite.stderr.exp
index 9286a7c..51999cc 100644
--- a/memcheck/tests/fwrite.stderr.exp
+++ b/memcheck/tests/fwrite.stderr.exp
@@ -4,4 +4,4 @@
    by 0x........: ...
  Address 0x........ is 0 bytes inside a block of size 10 alloc'd
    at 0x........: malloc (vg_replace_malloc.c:...)
-   by 0x........: main (fwrite.c:6)
+   by 0x........: main (fwrite.c:7)
diff --git a/memcheck/tests/fwrite.stderr.exp2 b/memcheck/tests/fwrite.stderr.exp2
index dc2027e..35e92f4 100644
--- a/memcheck/tests/fwrite.stderr.exp2
+++ b/memcheck/tests/fwrite.stderr.exp2
@@ -1,6 +1,6 @@
 Syscall param write(buf) points to uninitialised byte(s)
    at 0x........: write (in /...libc...)
-   by 0x........: main (fwrite.c:7)
+   by 0x........: main (fwrite.c:12)
  Address 0x........ is 0 bytes inside a block of size 10 alloc'd
    at 0x........: malloc (vg_replace_malloc.c:...)
-   by 0x........: main (fwrite.c:6)
+   by 0x........: main (fwrite.c:7)
diff --git a/memcheck/tests/fwrite.stdout.exp b/memcheck/tests/fwrite.stdout.exp
deleted file mode 100644
index cb43b5c..0000000
--- a/memcheck/tests/fwrite.stdout.exp
+++ /dev/null
Binary files differ