tests: add ftruncate64.test and truncate64.test
* tests/ftruncate64.c: New file.
* tests/truncate64.c: Likewise.
* tests/ftruncate64.test: New test.
* tests/truncate64.test: Likewise.
* tests/Makefile.am (check_PROGRAMS): Add ftruncate64 and truncate64.
(ftruncate64_CFLAGS, truncate64_CFLAGS): Define.
(TESTS): Add ftruncate64.test and truncate64.test.
* tests/.gitignore: Add ftruncate64 and truncate64.
diff --git a/tests/.gitignore b/tests/.gitignore
index 48aa301..eb2aeeb 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -12,6 +12,7 @@
file_handle
filter-unavailable
ftruncate
+ftruncate64
getdents
getdents64
getrandom
@@ -68,6 +69,7 @@
times
times-fail
truncate
+truncate64
uid
uid16
uid32
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3e962c8..2ad8d40 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -25,6 +25,7 @@
file_handle \
filter-unavailable \
ftruncate \
+ ftruncate64 \
getdents \
getdents64 \
getrandom \
@@ -81,6 +82,7 @@
times \
times-fail \
truncate \
+ truncate64 \
uid \
uid16 \
uid32 \
@@ -100,12 +102,14 @@
clock_xettime_LDADD = -lrt
filter_unavailable_LDADD = -lpthread
+ftruncate64_CFLAGS = $(AM_CFLAGS) -D_FILE_OFFSET_BITS=64
mmap64_CFLAGS = $(AM_CFLAGS) -D_FILE_OFFSET_BITS=64
mq_LDADD = -lrt
pc_LDADD = $(dl_LIBS)
stat_CFLAGS = $(AM_CFLAGS) -D_FILE_OFFSET_BITS=64
statfs_CFLAGS = $(AM_CFLAGS) -D_FILE_OFFSET_BITS=64
times_LDADD = -lrt
+truncate64_CFLAGS = $(AM_CFLAGS) -D_FILE_OFFSET_BITS=64
uio_CFLAGS = $(AM_CFLAGS) -D_FILE_OFFSET_BITS=64
stack_fcall_SOURCES = stack-fcall.c \
stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
@@ -129,6 +133,7 @@
file_handle.test \
filter-unavailable.test \
ftruncate.test \
+ ftruncate64.test \
getdents.test \
getdents64.test \
getrandom.test \
@@ -183,6 +188,7 @@
times.test \
times-fail.test \
truncate.test \
+ truncate64.test \
umovestr.test \
umovestr2.test \
unix-yy.test \
diff --git a/tests/ftruncate64.c b/tests/ftruncate64.c
new file mode 100644
index 0000000..7dfbf6b
--- /dev/null
+++ b/tests/ftruncate64.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <sys/syscall.h>
+
+#ifdef __NR_ftruncate64
+
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int
+main(void)
+{
+ const off_t len = 0xdefaceddeadbeef;
+ int rc = ftruncate(-1, len);
+
+ if (rc != -1 || EBADF != errno)
+ return 77;
+
+ printf("ftruncate64(-1, %Lu) = -1 EBADF (Bad file descriptor)\n",
+ (unsigned long long) len);
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+int
+main(void)
+{
+ return 77;
+}
+
+#endif
diff --git a/tests/ftruncate64.test b/tests/ftruncate64.test
new file mode 100755
index 0000000..43cd9ad
--- /dev/null
+++ b/tests/ftruncate64.test
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Check ftruncate64 syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -a36 -eftruncate64 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
+
+exit 0
diff --git a/tests/truncate64.c b/tests/truncate64.c
new file mode 100644
index 0000000..8256580
--- /dev/null
+++ b/tests/truncate64.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <sys/syscall.h>
+
+#ifdef __NR_truncate64
+
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int
+main(void)
+{
+ static const char fname[] = "truncate64\nfilename";
+ static const char qname[] = "truncate64\\nfilename";
+ const off_t len = 0xdefaceddeadbeef;
+ int rc = truncate(fname, len);
+
+ if (rc != -1 || ENOENT != errno)
+ return 77;
+
+ printf("truncate64(\"%s\", %Lu) = -1 ENOENT (No such file or directory)\n",
+ qname, (unsigned long long) len);
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+int
+main(void)
+{
+ return 77;
+}
+
+#endif
diff --git a/tests/truncate64.test b/tests/truncate64.test
new file mode 100755
index 0000000..2113e06
--- /dev/null
+++ b/tests/truncate64.test
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Check truncate64 syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -etruncate64 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
+
+exit 0