]> granicus.if.org Git - strace/commitdiff
tests: add ftruncate64.test and truncate64.test
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 1 Dec 2015 00:32:40 +0000 (00:32 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 1 Dec 2015 08:28:45 +0000 (08:28 +0000)
* 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.

tests/.gitignore
tests/Makefile.am
tests/ftruncate64.c [new file with mode: 0644]
tests/ftruncate64.test [new file with mode: 0755]
tests/truncate64.c [new file with mode: 0644]
tests/truncate64.test [new file with mode: 0755]

index 48aa30184157bfccde9a98083890466db03cf77d..eb2aeeb9d65e4ad3a6548772f74fcdcec5b5cc19 100644 (file)
@@ -12,6 +12,7 @@ fanotify_mark
 file_handle
 filter-unavailable
 ftruncate
+ftruncate64
 getdents
 getdents64
 getrandom
@@ -68,6 +69,7 @@ timerfd_xettime
 times
 times-fail
 truncate
+truncate64
 uid
 uid16
 uid32
index 3e962c844d29581df417b6550666735d3e07bd2c..2ad8d400ee7e8b0075b3b2ae235f2d976f7158bc 100644 (file)
@@ -25,6 +25,7 @@ check_PROGRAMS = \
        file_handle \
        filter-unavailable \
        ftruncate \
+       ftruncate64 \
        getdents \
        getdents64 \
        getrandom \
@@ -81,6 +82,7 @@ check_PROGRAMS = \
        times \
        times-fail \
        truncate \
+       truncate64 \
        uid \
        uid16 \
        uid32 \
@@ -100,12 +102,14 @@ check_PROGRAMS = \
 
 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 @@ TESTS = \
        file_handle.test \
        filter-unavailable.test \
        ftruncate.test \
+       ftruncate64.test \
        getdents.test \
        getdents64.test \
        getrandom.test \
@@ -183,6 +188,7 @@ TESTS = \
        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 (file)
index 0000000..7dfbf6b
--- /dev/null
@@ -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 (executable)
index 0000000..43cd9ad
--- /dev/null
@@ -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 (file)
index 0000000..8256580
--- /dev/null
@@ -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 (executable)
index 0000000..2113e06
--- /dev/null
@@ -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