summaryrefslogtreecommitdiff
path: root/tests/dd
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dd')
-rwxr-xr-xtests/dd/ascii.sh73
-rwxr-xr-xtests/dd/bytes.sh2
-rwxr-xr-xtests/dd/direct.sh2
-rwxr-xr-xtests/dd/misc.sh17
-rwxr-xr-xtests/dd/no-allocate.sh2
-rwxr-xr-xtests/dd/nocache.sh6
-rwxr-xr-xtests/dd/not-rewound.sh2
-rwxr-xr-xtests/dd/reblock.sh2
-rwxr-xr-xtests/dd/skip-seek-past-dev.sh2
-rwxr-xr-xtests/dd/skip-seek-past-file.sh2
-rwxr-xr-xtests/dd/skip-seek.pl2
-rwxr-xr-xtests/dd/skip-seek2.sh2
-rwxr-xr-xtests/dd/sparse.sh11
-rwxr-xr-xtests/dd/stats.sh73
-rwxr-xr-xtests/dd/stderr.sh6
-rwxr-xr-xtests/dd/unblock-sync.sh2
-rwxr-xr-xtests/dd/unblock.pl2
17 files changed, 146 insertions, 62 deletions
diff --git a/tests/dd/ascii.sh b/tests/dd/ascii.sh
index 7dc39cc9..be6494a0 100755
--- a/tests/dd/ascii.sh
+++ b/tests/dd/ascii.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# test conv=ascii
-# Copyright (C) 2014 Free Software Foundation, Inc.
+# Copyright (C) 2014-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,45 +21,46 @@ print_ver_ dd
{
# Two lines, EBCDIC " A A" and " A ", followed by all the bytes in order.
- printf '\100\301\100\301\100\301\100\100' &&
- printf $(printf '\\%03o' $(seq 0 255));
+ env printf '\100\301\100\301\100\301\100\100' &&
+ env printf $(env printf '\\%03o' $(seq 0 255));
} >in || framework_failure_
{
# The converted lines, with trailing spaces removed.
- printf ' A A\n A\n' &&
- printf '\000\001\002\003\n\234\011\206\177\n' &&
- printf '\227\215\216\013\n\014\015\016\017\n' &&
- printf '\020\021\022\023\n\235\205\010\207\n' &&
- printf '\030\031\222\217\n\034\035\036\037\n' &&
- printf '\200\201\202\203\n\204\012\027\033\n' &&
- printf '\210\211\212\213\n\214\005\006\007\n' &&
- printf '\220\221\026\223\n\224\225\226\004\n' &&
- printf '\230\231\232\233\n\024\025\236\032\n' &&
- printf '\040\240\241\242\n\243\244\245\246\n' &&
- printf '\247\250\325\056\n\074\050\053\174\n' &&
- printf '\046\251\252\253\n\254\255\256\257\n' &&
- printf '\260\261\041\044\n\052\051\073\176\n' &&
- printf '\055\057\262\263\n\264\265\266\267\n' &&
- printf '\270\271\313\054\n\045\137\076\077\n' &&
- printf '\272\273\274\275\n\276\277\300\301\n' &&
- printf '\302\140\072\043\n\100\047\075\042\n' &&
- printf '\303\141\142\143\n\144\145\146\147\n' &&
- printf '\150\151\304\305\n\306\307\310\311\n' &&
- printf '\312\152\153\154\n\155\156\157\160\n' &&
- printf '\161\162\136\314\n\315\316\317\320\n' &&
- printf '\321\345\163\164\n\165\166\167\170\n' &&
- printf '\171\172\322\323\n\324\133\326\327\n' &&
- printf '\330\331\332\333\n\334\335\336\337\n' &&
- printf '\340\341\342\343\n\344\135\346\347\n' &&
- printf '\173\101\102\103\n\104\105\106\107\n' &&
- printf '\110\111\350\351\n\352\353\354\355\n' &&
- printf '\175\112\113\114\n\115\116\117\120\n' &&
- printf '\121\122\356\357\n\360\361\362\363\n' &&
- printf '\134\237\123\124\n\125\126\127\130\n' &&
- printf '\131\132\364\365\n\366\367\370\371\n' &&
- printf '\060\061\062\063\n\064\065\066\067\n' &&
- printf '\070\071\372\373\n\374\375\376\377\n';
+env printf \
+' A A\n A\n'\
+'\000\001\002\003\n\234\011\206\177\n'\
+'\227\215\216\013\n\014\015\016\017\n'\
+'\020\021\022\023\n\235\205\010\207\n'\
+'\030\031\222\217\n\034\035\036\037\n'\
+'\200\201\202\203\n\204\012\027\033\n'\
+'\210\211\212\213\n\214\005\006\007\n'\
+'\220\221\026\223\n\224\225\226\004\n'\
+'\230\231\232\233\n\024\025\236\032\n'\
+'\040\240\241\242\n\243\244\245\246\n'\
+'\247\250\325\056\n\074\050\053\174\n'\
+'\046\251\252\253\n\254\255\256\257\n'\
+'\260\261\041\044\n\052\051\073\176\n'\
+'\055\057\262\263\n\264\265\266\267\n'\
+'\270\271\313\054\n\045\137\076\077\n'\
+'\272\273\274\275\n\276\277\300\301\n'\
+'\302\140\072\043\n\100\047\075\042\n'\
+'\303\141\142\143\n\144\145\146\147\n'\
+'\150\151\304\305\n\306\307\310\311\n'\
+'\312\152\153\154\n\155\156\157\160\n'\
+'\161\162\136\314\n\315\316\317\320\n'\
+'\321\345\163\164\n\165\166\167\170\n'\
+'\171\172\322\323\n\324\133\326\327\n'\
+'\330\331\332\333\n\334\335\336\337\n'\
+'\340\341\342\343\n\344\135\346\347\n'\
+'\173\101\102\103\n\104\105\106\107\n'\
+'\110\111\350\351\n\352\353\354\355\n'\
+'\175\112\113\114\n\115\116\117\120\n'\
+'\121\122\356\357\n\360\361\362\363\n'\
+'\134\237\123\124\n\125\126\127\130\n'\
+'\131\132\364\365\n\366\367\370\371\n'\
+'\060\061\062\063\n\064\065\066\067\n'\
+'\070\071\372\373\n\374\375\376\377\n';
} >exp || framework_failure_
dd if=in of=out conv=ascii cbs=4 || fail=1
diff --git a/tests/dd/bytes.sh b/tests/dd/bytes.sh
index 1b72cc4c..68e98f7a 100755
--- a/tests/dd/bytes.sh
+++ b/tests/dd/bytes.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-# Copyright (C) 2012-2014 Free Software Foundation, Inc.
+# Copyright (C) 2012-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/dd/direct.sh b/tests/dd/direct.sh
index f6065cae..6b741472 100755
--- a/tests/dd/direct.sh
+++ b/tests/dd/direct.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# ensure that dd's oflag=direct works
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/dd/misc.sh b/tests/dd/misc.sh
index f877fddf..bc5fb37e 100755
--- a/tests/dd/misc.sh
+++ b/tests/dd/misc.sh
@@ -2,7 +2,7 @@
# Ensure dd treats '--' properly.
# Also test some flag values.
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -35,9 +35,12 @@ dd status=none if=$tmp_in of=/dev/null 2> err || fail=1
compare /dev/null err || fail=1
dd status=none if=$tmp_in skip=2 of=/dev/null 2> err || fail=1
compare /dev/null err || fail=1
-# check status=none is cumulative with status=noxfer
-dd status=none status=noxfer if=$tmp_in of=/dev/null 2> err || fail=1
+# check later status=none overrides earlier status=noxfer
+dd status=noxfer status=none if=$tmp_in of=/dev/null 2> err || fail=1
compare /dev/null err || fail=1
+# check later status=noxfer overrides earlier status=none
+dd status=none status=noxfer if=$tmp_in of=/dev/null 2> err || fail=1
+compare /dev/null err && fail=1
dd if=$tmp_in of=$tmp_out 2> /dev/null || fail=1
compare $tmp_in $tmp_out || fail=1
@@ -58,12 +61,12 @@ case $(cat /dev/stdin <$tmp_in 2>/dev/null) in
esac
if dd iflag=nofollow if=$tmp_in count=0 2> /dev/null; then
- dd iflag=nofollow if=$tmp_sym count=0 2> /dev/null && fail=1
+ returns_ 1 dd iflag=nofollow if=$tmp_sym count=0 2> /dev/null || fail=1
fi
if dd iflag=directory if=. count=0 2> /dev/null; then
dd iflag=directory count=0 <. 2> /dev/null || fail=1
- dd iflag=directory count=0 <$tmp_in 2> /dev/null && fail=1
+ returns_ 1 dd iflag=directory count=0 <$tmp_in 2> /dev/null || fail=1
fi
old_ls=$(ls -u --full-time $tmp_in)
@@ -84,8 +87,8 @@ EOF
fi
if dd oflag=nolinks if=$tmp_in of=$tmp_out 2> /dev/null; then
- dd iflag=nolinks if=$tmp_in > /dev/null 2>&1 && fail=1
- dd iflag=nolinks < $tmp_in > /dev/null 2>&1 && fail=1
+ returns_ 1 dd iflag=nolinks if=$tmp_in > /dev/null 2>&1 || fail=1
+ returns_ 1 dd iflag=nolinks < $tmp_in > /dev/null 2>&1 || fail=1
dd oflag=nolinks < $tmp_in > $tmp_out 2>&1 || fail=1
fi
diff --git a/tests/dd/no-allocate.sh b/tests/dd/no-allocate.sh
index 62170b9b..99e0542a 100755
--- a/tests/dd/no-allocate.sh
+++ b/tests/dd/no-allocate.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# make sure that dd doesn't allocate memory unnecessarily
-# Copyright (C) 2013-2014 Free Software Foundation, Inc.
+# Copyright (C) 2013-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/dd/nocache.sh b/tests/dd/nocache.sh
index 4756663d..e7fdf4e5 100755
--- a/tests/dd/nocache.sh
+++ b/tests/dd/nocache.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure dd handles the 'nocache' flag
-# Copyright (C) 2011-2014 Free Software Foundation, Inc.
+# Copyright (C) 2011-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -23,10 +23,10 @@ print_ver_ dd
dd iflag=nocache oflag=nocache if=/dev/null of=/dev/null || fail=1
# We should get an error for trying to process a pipe
-dd count=0 | dd iflag=nocache count=0 && fail=1
+dd count=0 | returns_ 1 dd iflag=nocache count=0 || fail=1
# O_DIRECT is orthogonal to drop cache so mutually exclusive
-dd iflag=nocache,direct if=/dev/null && fail=1
+returns_ 1 dd iflag=nocache,direct if=/dev/null || fail=1
# The rest ensure that the documented uses cases
# proceed without error
diff --git a/tests/dd/not-rewound.sh b/tests/dd/not-rewound.sh
index 4b38c216..beaf6403 100755
--- a/tests/dd/not-rewound.sh
+++ b/tests/dd/not-rewound.sh
@@ -2,7 +2,7 @@
# Make sure dd does the right thing when the input file descriptor
# is not rewound.
-# Copyright (C) 2000-2014 Free Software Foundation, Inc.
+# Copyright (C) 2000-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/dd/reblock.sh b/tests/dd/reblock.sh
index ccae9459..cd9d9420 100755
--- a/tests/dd/reblock.sh
+++ b/tests/dd/reblock.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# test dd reblocking vs. bs=
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/dd/skip-seek-past-dev.sh b/tests/dd/skip-seek-past-dev.sh
index 5eb7ab5a..216898c4 100755
--- a/tests/dd/skip-seek-past-dev.sh
+++ b/tests/dd/skip-seek-past-dev.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# test diagnostics are printed immediately when seeking beyond device.
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/dd/skip-seek-past-file.sh b/tests/dd/skip-seek-past-file.sh
index 8ed1d3f6..2e15a84d 100755
--- a/tests/dd/skip-seek-past-file.sh
+++ b/tests/dd/skip-seek-past-file.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# test diagnostics are printed when seeking too far in seekable files.
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/dd/skip-seek.pl b/tests/dd/skip-seek.pl
index e2a7d022..6bacf67d 100755
--- a/tests/dd/skip-seek.pl
+++ b/tests/dd/skip-seek.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test dd's skip and seek options.
-# Copyright (C) 2000-2014 Free Software Foundation, Inc.
+# Copyright (C) 2000-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/dd/skip-seek2.sh b/tests/dd/skip-seek2.sh
index aa6d65dd..62d08f07 100755
--- a/tests/dd/skip-seek2.sh
+++ b/tests/dd/skip-seek2.sh
@@ -2,7 +2,7 @@
# show how to skip an amount that is smaller than the nominal block size.
# There's a more realistic example in the documentation.
-# Copyright (C) 2000-2014 Free Software Foundation, Inc.
+# Copyright (C) 2000-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/dd/sparse.sh b/tests/dd/sparse.sh
index a7e90d2b..626b4059 100755
--- a/tests/dd/sparse.sh
+++ b/tests/dd/sparse.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-# Copyright (C) 2012-2014 Free Software Foundation, Inc.
+# Copyright (C) 2012-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ dd
+is_local_dir_ . || very_expensive_
require_sparse_support_
# Ensure basic sparse generation works
@@ -50,6 +51,9 @@ dd if=/dev/zero of=file.in bs=1M count=1 seek=1 conv=notrunc || fail=1
kb_alloc() { du -k "$1"|cut -f1; }
+# sync out data for async allocators like NFS/BTRFS
+# sync file.in || fail=1
+
# If our just-created input file appears to be too small,
# skip the remaining tests. On at least Solaris 10 with NFS,
# file.in is reported to occupy <= 1KiB for about 50 seconds
@@ -58,7 +62,10 @@ if test $(kb_alloc file.in) -gt 3000; then
# Ensure NUL blocks smaller than the block size are not made sparse.
# Here, with a 2MiB block size, dd's conv=sparse must *not* introduce a hole.
- dd if=file.in of=file.out bs=2M conv=sparse
+ dd if=file.in of=file.out bs=2M conv=sparse || fail=1
+
+ # Intermittently BTRFS returns 0 allocation for file.out unless synced
+ sync file.out || framework_failure_
test 2500 -lt $(kb_alloc file.out) || fail=1
# Note we recreate a sparse file first to avoid
diff --git a/tests/dd/stats.sh b/tests/dd/stats.sh
new file mode 100755
index 00000000..a82c66d2
--- /dev/null
+++ b/tests/dd/stats.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+# Check stats output for SIG{INFO,USR1} and status=progress
+
+# Copyright (C) 2014-2015 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ dd
+
+env kill -l | grep '^INFO$' && SIGINFO='INFO' || SIGINFO='USR1'
+
+# This to avoid races in the USR1 case
+# as the dd process will terminate by default until
+# it has its handler enabled.
+trap '' $SIGINFO
+
+mkfifo_or_skip_ fifo
+
+# Terminate any background processes
+cleanup_()
+{
+ kill $pid 2>/dev/null
+ kill $pid2 2>/dev/null
+ wait
+}
+
+for open in '' '1'; do
+ # Run dd with the fullblock iflag to avoid short reads
+ # which can be triggered by reception of signals
+ dd iflag=fullblock if=/dev/zero of=fifo count=50 bs=5000000 2>err & pid=$!
+
+ # Note if we sleep here we give dd a chance to exec and block on open.
+ # Otherwise we're probably testing SIG_IGN in the forked shell or early dd.
+ test "$open" && sleep .1
+
+ # dd will block on open until fifo is opened for reading.
+ # Timeout in case dd goes away erroneously which we check for below.
+ timeout 20 sh -c 'wc -c < fifo > nwritten' & pid2=$!
+
+ # Send lots of signals immediately to ensure dd not killed due
+ # to race setting handler, or blocking on open of fifo.
+ # Many signals also check that short reads are handled.
+ until ! kill -s $SIGINFO $pid 2>/dev/null; do
+ sleep .01
+ done
+
+ wait
+
+ # Ensure all data processed and at least last status written
+ grep '250000000 bytes .* copied' err || { cat err; fail=1; }
+done
+
+progress_output()
+{
+ { sleep "$1"; echo 1; } | dd bs=1 status=progress of=/dev/null 2>err
+ # Progress output should be for "byte ... copied", while final is "bytes ..."
+ grep 'byte .* copied' err
+}
+retry_delay_ progress_output 1 4 || { cat err; fail=1; }
+
+Exit $fail
diff --git a/tests/dd/stderr.sh b/tests/dd/stderr.sh
index d0a304a7..82ab08f1 100755
--- a/tests/dd/stderr.sh
+++ b/tests/dd/stderr.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure dd recognizes failure to write to stderr.
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -32,12 +32,12 @@ dd --help >/dev/null 2>&- || fail=1
# This exposes a failure present in 6.11 through 7.5.
if "$p/src/test" -w /dev/stderr 2>/dev/null &&
"$p/src/test" ! -w /dev/stderr 2>&-; then
- : | dd 2>&- && fail=1
+ : | returns_ 1 dd 2>&- || fail=1
fi
# Likewise for /dev/full, if /dev/full works.
if test -w /dev/full && test -c /dev/full; then
- : | dd 2>/dev/full && fail=1
+ : | returns_ 1 dd 2>/dev/full || fail=1
fi
Exit $fail
diff --git a/tests/dd/unblock-sync.sh b/tests/dd/unblock-sync.sh
index 72fd2ab0..751cefdf 100755
--- a/tests/dd/unblock-sync.sh
+++ b/tests/dd/unblock-sync.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that dd conv=unblock,sync works.
-# Copyright (C) 2003-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/dd/unblock.pl b/tests/dd/unblock.pl
index 586b7b4d..1e6a47d1 100755
--- a/tests/dd/unblock.pl
+++ b/tests/dd/unblock.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Exercise dd's conv=unblock mode
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by