From: Tom Hughes Date: Tue, 1 Nov 2005 17:21:03 +0000 (+0000) Subject: Fixed test to not assume that malloc(10) will return 10 nul bytes! X-Git-Tag: svn/VALGRIND_3_1_0~254 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=030b1aac1009b9562d9e1e73809cc9d2db29cf64;p=thirdparty%2Fvalgrind.git Fixed test to not assume that malloc(10) will return 10 nul bytes! git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4978 --- diff --git a/memcheck/tests/fwrite.c b/memcheck/tests/fwrite.c index 1eec4a4f8e..9334b29608 100644 --- a/memcheck/tests/fwrite.c +++ b/memcheck/tests/fwrite.c @@ -1,9 +1,17 @@ - +#include +#include #include #include 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 9286a7c17b..51999cccbc 100644 --- a/memcheck/tests/fwrite.stderr.exp +++ b/memcheck/tests/fwrite.stderr.exp @@ -4,4 +4,4 @@ Syscall param write(buf) points to uninitialised byte(s) 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 dc2027e29d..35e92f4518 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 cb43b5ce13..0000000000 Binary files a/memcheck/tests/fwrite.stdout.exp and /dev/null differ