From: Dmitry V. Levin Date: Sun, 14 Feb 2016 00:04:20 +0000 (+0000) Subject: tests: extend coverage of struct iovec arrays X-Git-Tag: v4.12~547 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4774f8239b1b89a8d5f0373448088bf56a8b35f0;p=strace tests: extend coverage of struct iovec arrays * tests/readv.c (main): Check decoding of empty, inaccessible, and partially inaccessible iovec arrays. * tests/readv.test: Update. --- diff --git a/tests/readv.c b/tests/readv.c index ec35c8ae..ce765ec0 100644 --- a/tests/readv.c +++ b/tests/readv.c @@ -49,6 +49,8 @@ main(void) const char *w0_d = hexdump_strdup(w0_c); void *w0 = tail_memdup(w0_c, LENGTH_OF(w0_c)); + const void *efault = w0 + LENGTH_OF(w0_c); + static const char w1_c[] = "34567"; const char *w1_d = hexdump_strdup(w1_c); void *w1 = tail_memdup(w1_c, LENGTH_OF(w1_c)); @@ -57,6 +59,12 @@ main(void) const char *w2_d = hexdump_strdup(w2_c); void *w2 = tail_memdup(w2_c, LENGTH_OF(w2_c)); + assert(writev(1, efault, 42) == -1); + tprintf("writev(1, [%p], 42) = -1 EFAULT (%m)\n", efault); + + assert(readv(0, efault, 42) == -1); + tprintf("readv(0, %p, 42) = -1 EFAULT (%m)\n", efault); + static const char r0_c[] = "01234567"; const char *r0_d = hexdump_strdup(r0_c); static const char r1_c[] = "89abcde"; @@ -75,6 +83,14 @@ main(void) } }; const struct iovec *w_iov = tail_memdup(w_iov_, sizeof(w_iov_)); + + assert(writev(1, w_iov, 0) == 0); + tprintf("writev(1, [], 0) = 0\n"); + + assert(writev(1, w_iov + ARRAY_SIZE(w_iov_) - 1, 2) == -1); + tprintf("writev(1, [{\"%s\", %u}, %p], 2) = -1 EFAULT (%m)\n", + w2_c, LENGTH_OF(w2_c), w_iov + ARRAY_SIZE(w_iov_)); + const unsigned int w_len = LENGTH_OF(w0_c) + LENGTH_OF(w1_c) + LENGTH_OF(w2_c); diff --git a/tests/readv.test b/tests/readv.test index 6a071e38..48ae6766 100755 --- a/tests/readv.test +++ b/tests/readv.test @@ -6,7 +6,7 @@ run_prog > /dev/null OUT="$LOG.out" -run_strace -a30 -eread=0 -ewrite=1 -ereadv,writev $args > "$OUT" +run_strace -a16 -eread=0 -ewrite=1 -ereadv,writev $args > "$OUT" match_diff "$LOG" "$OUT" rm -f "$OUT"