tests: add a test for pread/pwrite and preadv/pwritev offset decoding

* tests/uio.c: New file.
* tests/uio.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add uio.
(uio_CFLAGS): Define.
(TESTS): Add uio.test.
diff --git a/tests/uio.test b/tests/uio.test
new file mode 100755
index 0000000..25f82cb
--- /dev/null
+++ b/tests/uio.test
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# Check how pread/pwrite and preadv/pwritev syscalls are traced.
+
+. "${srcdir=.}/init.sh"
+
+check_prog grep
+check_prog rm
+
+./uio ||
+	fail_ 'uio failed'
+
+args="-edesc ./uio"
+$STRACE $args > $LOG 2>&1 || {
+	cat $LOG
+	fail_ "$STRACE $args failed"
+}
+
+grep_log()
+{
+	local syscall="$1"; shift
+
+	LC_ALL=C grep -E -x "$syscall$*" $LOG > /dev/null || {
+		cat $LOG
+		fail_ "$STRACE $args failed to trace \"$syscall\" properly"
+	}
+}
+
+grep_log 'pread(64)?' '\(3, "\\0\\0\\0\\0", 4, 1004211379570065135\) += 4'
+grep_log 'preadv' '\(3, \[{"\\0\\0\\0\\0", 4}\], 1, 1004211379570065135\) += 4'
+grep_log 'pwrite(64)?' '\(3, "\\0\\0\\0\\0", 4, 1004211379570065135\) += 4'
+grep_log 'pwritev' '\(3, \[{"\\0\\0\\0\\0", 4}\], 1, 1004211379570065135\) += 4'
+
+exit 0