summaryrefslogtreecommitdiffstats
path: root/bin/dd/tests
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-07-18 17:36:25 +0000
committerngie <ngie@FreeBSD.org>2017-07-18 17:36:25 +0000
commit039033bf45e08c90b08dcf29bfc610f446a2e8b5 (patch)
treed9a3e45b2a58c516ae65187be4f6de7ab4759893 /bin/dd/tests
parentf134eaf3786906ed5a74397cad68fbea9acd6edd (diff)
downloadFreeBSD-src-039033bf45e08c90b08dcf29bfc610f446a2e8b5.zip
FreeBSD-src-039033bf45e08c90b08dcf29bfc610f446a2e8b5.tar.gz
MFC r302500,r319339,r319543,r319544,r319551,r321138:
r302500 (by cem): dd(1): Enable access to SIZE_T_MAX character devices On machines where SIZE_T_MAX exceeds OFF_MAX (signed 64-bit), permit seeking character devices to negative off_t values. This enables dd(1) to interact with kernel KVA in /dev/kmem on amd64, for example. r319339 (by asomers): Fix integer overflow detection in dd dd(1) tried to detect whether the seek offset would overflow, but it failed to account for the case where the provided argument was negative and the file was a regular file (negative seeks are allowed for character devices). I fixed it, and added a regression test. CID: 1368659 r319543: Stylistic tweaks Move opening braces of functions from the last column to column 0. MFC with: r319339 r319544: Mark :seek_overflow as an expected failure MFC with: r319339 PR: 219757 r319551 (by asomers): Fix bin/dd/dd2_tests:seek_overflow on UFS and TMPFS Split the postive and negative parts into separate test cases. The positive test case can only run on ZFS, because only ZFS supports files that large. PR: 219757 r321138: Remove unnecessary make logic added in r319339 This makes the change cleaner and easier to backport to ^/stable/10.
Diffstat (limited to 'bin/dd/tests')
-rw-r--r--bin/dd/tests/Makefile6
-rwxr-xr-xbin/dd/tests/dd2_test.sh69
2 files changed, 70 insertions, 5 deletions
diff --git a/bin/dd/tests/Makefile b/bin/dd/tests/Makefile
index f87af65..029808e 100644
--- a/bin/dd/tests/Makefile
+++ b/bin/dd/tests/Makefile
@@ -1,10 +1,6 @@
# $FreeBSD$
-OBJTOP= ${.OBJDIR:H:H:H}
-SRCTOP= ${.CURDIR:H:H:H}
-TESTSRC= ${SRCTOP}/contrib/netbsd-tests/bin/dd
-TESTSDIR= ${TESTSBASE}/bin/dd
-
+ATF_TESTS_SH= dd2_test
NETBSD_ATF_TESTS_SH= dd_test
.include <netbsd-tests.test.mk>
diff --git a/bin/dd/tests/dd2_test.sh b/bin/dd/tests/dd2_test.sh
new file mode 100755
index 0000000..c0b33fc
--- /dev/null
+++ b/bin/dd/tests/dd2_test.sh
@@ -0,0 +1,69 @@
+#
+# Copyright (c) 2017 Spectra Logic Corporation
+# 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``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 FOUNDATION OR CONTRIBUTORS
+# 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.
+#
+# $FreeBSD$
+
+
+atf_test_case max_seek
+max_seek_head()
+{
+ atf_set "descr" "dd(1) can seek by the maximum amount"
+}
+max_seek_body()
+{
+ case `df -T . | tail -n 1 | cut -wf 2` in
+ "ufs")
+ atf_skip "UFS's maximum file size is too small";;
+ "zfs") ;; # ZFS is fine
+ "tmpfs")
+ atf_skip "tmpfs can't create arbitrarily large spare files";;
+ *) atf_skip "Unknown file system";;
+ esac
+
+ touch f.in
+ seek=`echo "2^63 / 4096 - 1" | bc`
+ atf_check -s exit:0 -e ignore dd if=f.in of=f.out bs=4096 seek=$seek
+}
+
+atf_test_case seek_overflow
+seek_overflow_head()
+{
+ atf_set "descr" "dd(1) should reject too-large seek values"
+}
+seek_overflow_body()
+{
+ touch f.in
+ seek=`echo "2^63 / 4096" | bc`
+ atf_check -s not-exit:0 -e match:"seek offsets cannot be larger than" \
+ dd if=f.in of=f.out bs=4096 seek=$seek
+ atf_check -s not-exit:0 -e match:"seek offsets cannot be larger than" \
+ dd if=f.in of=f.out bs=4096 seek=-1
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case max_seek
+ atf_add_test_case seek_overflow
+}
OpenPOWER on IntegriCloud