From 274a4bff32efb2fb483d19d9884e3f1be03cf849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sun, 9 Oct 2011 23:30:02 +0100 Subject: [PATCH] tests: don't assume the existence of /dev/zero /dev/zero is not defined by POSIX and is not available on NetBSD at least. * tests/init.cfg (require_dev_zero_): Add this new function. * tests/cp/cp-a-selinux: Use require_dev_zero_. * tests/cp/cp-mv-enotsup-xattr: Likewise. * tests/cp/fiemap-2: Likewise. * tests/dd/nocache: Likewise. * tests/mkdir/writable-under-readonly: Likewise. * tests/rm/read-only: Likewise. * tests/split/l-chunk: Likewise. * tests/cp/sparse-fiemap: Likewise. Also use the more standard require_perl_. Reported by Bruno Haible. --- tests/cp/cp-a-selinux | 1 + tests/cp/cp-mv-enotsup-xattr | 1 + tests/cp/fiemap-2 | 2 ++ tests/cp/sparse-fiemap | 3 ++- tests/dd/nocache | 1 + tests/init.cfg | 8 ++++++++ tests/mkdir/writable-under-readonly | 2 +- tests/rm/read-only | 1 + tests/split/l-chunk | 1 + 9 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/cp/cp-a-selinux b/tests/cp/cp-a-selinux index 0f9c149..fb12a2a 100755 --- a/tests/cp/cp-a-selinux +++ b/tests/cp/cp-a-selinux @@ -24,6 +24,7 @@ print_ver_ cp require_root_ require_selinux_ require_mkfs_PATH_ +require_dev_zero_ cwd=`pwd` cleanup_() { cd /; umount "$cwd/mnt"; } diff --git a/tests/cp/cp-mv-enotsup-xattr b/tests/cp/cp-mv-enotsup-xattr index 32798d2..88164d9 100755 --- a/tests/cp/cp-mv-enotsup-xattr +++ b/tests/cp/cp-mv-enotsup-xattr @@ -36,6 +36,7 @@ make_fs() { fs="$where.bin" + require dev_zero_ dd if=/dev/zero of="$fs" bs=8192 count=200 > /dev/null 2>&1 \ || skip=1 mkdir "$where" || skip=1 diff --git a/tests/cp/fiemap-2 b/tests/cp/fiemap-2 index 691ead2..8f0adf7 100755 --- a/tests/cp/fiemap-2 +++ b/tests/cp/fiemap-2 @@ -19,6 +19,8 @@ . "${srcdir=.}/init.sh"; path_prepend_ ../src print_ver_ cp +require_dev_zero_ + # Require a fiemap-enabled FS. touch fiemap_chk # check a file rather than current dir for best coverage fiemap_capable_ fiemap_chk \ diff --git a/tests/cp/sparse-fiemap b/tests/cp/sparse-fiemap index 831bf0b..02604c9 100755 --- a/tests/cp/sparse-fiemap +++ b/tests/cp/sparse-fiemap @@ -18,7 +18,8 @@ . "${srcdir=.}/init.sh"; path_prepend_ ../src print_ver_ cp -$PERL -e 1 || skip_ 'you lack perl' +require_perl_ +require_dev_zero_ # The test was seen to fail on ext3 so exclude that type # (or any file system where the type can't be determined) diff --git a/tests/dd/nocache b/tests/dd/nocache index 5dcd897..b34c3aa 100755 --- a/tests/dd/nocache +++ b/tests/dd/nocache @@ -18,6 +18,7 @@ . "${srcdir=.}/init.sh"; path_prepend_ ../src print_ver_ dd +require_dev_zero_ # This should not call posix_fadvise dd iflag=nocache oflag=nocache if=/dev/null of=/dev/null || fail=1 diff --git a/tests/init.cfg b/tests/init.cfg index f6eb651..ce784f1 100644 --- a/tests/init.cfg +++ b/tests/init.cfg @@ -385,6 +385,14 @@ require_sparse_support_() fi } +# TODO: we might relax this requirement in some tests, if +# for example, truncate --alloc (posix_fallocate) is implemented. +require_dev_zero_() +{ + test -c /dev/zero || + skip_ "This test requires /dev/zero support." +} + mkfifo_or_skip_() { test $# = 1 || framework_failure_ diff --git a/tests/mkdir/writable-under-readonly b/tests/mkdir/writable-under-readonly index 3e42b1d..7e8300c 100755 --- a/tests/mkdir/writable-under-readonly +++ b/tests/mkdir/writable-under-readonly @@ -34,7 +34,7 @@ skip_ temporarily disabled # FIXME: define cleanup_ to do the umount -# FIXME: use mktemp +# FIXME: use mktemp, and don't assume /dev/zero available cd /tmp \ && dd if=/dev/zero of=1 bs=8192 count=50 \ && dd if=/dev/zero of=2 bs=8192 count=50 \ diff --git a/tests/rm/read-only b/tests/rm/read-only index 489b1bf..f6d1c4e 100755 --- a/tests/rm/read-only +++ b/tests/rm/read-only @@ -20,6 +20,7 @@ print_ver_ rm require_root_ require_mkfs_PATH_ +require_dev_zero_ cwd=`pwd` cleanup_() { cd /; umount "$cwd/mnt"; } diff --git a/tests/split/l-chunk b/tests/split/l-chunk index e1c9ec7..870c211 100755 --- a/tests/split/l-chunk +++ b/tests/split/l-chunk @@ -18,6 +18,7 @@ . "${srcdir=.}/init.sh"; path_prepend_ ../src print_ver_ split +require_dev_zero_ # invalid number of chunks echo 'split: 1o: invalid number of chunks' > exp -- 1.7.6