2010-01-20 10:27:08 +11:00
|
|
|
#! /bin/bash
|
2018-06-09 11:35:42 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
|
|
|
|
|
#
|
2009-05-28 17:04:15 +02:00
|
|
|
# FS QA Test No. 014
|
|
|
|
|
#
|
|
|
|
|
# truncfile
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
|
|
|
|
seq=`basename $0`
|
2013-03-15 12:28:02 +00:00
|
|
|
seqres=$RESULT_DIR/$seq
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=0 # success is the default!
|
2004-06-15 07:32:36 +00:00
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
2004-06-15 07:32:36 +00:00
|
|
|
cd /
|
|
|
|
|
rm -f $tmp.*
|
2013-12-03 10:29:26 +11:00
|
|
|
rm -rf $TEST_DIR/truncfile.$$.*
|
2001-01-15 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
2013-03-15 12:28:04 +00:00
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2009-05-28 11:37:38 -05:00
|
|
|
_supported_fs generic
|
2017-07-20 21:22:05 -07:00
|
|
|
_supported_os Linux
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2014-08-13 11:08:41 +10:00
|
|
|
_require_test
|
2010-11-09 14:53:36 +01:00
|
|
|
_require_sparse_files
|
2004-06-15 07:32:36 +00:00
|
|
|
|
2011-01-07 23:58:50 +11:00
|
|
|
# ensure EOF preallocation doesn't massively extend the runtime of this test
|
|
|
|
|
# by limiting the amount of preallocation and therefore the amount of blocks
|
|
|
|
|
# zeroed during the truncfile test run.
|
2011-02-14 11:23:29 +11:00
|
|
|
if [ "$FSTYP" == "xfs" ]; then
|
2015-12-21 18:07:43 +11:00
|
|
|
_test_unmount
|
2011-02-14 11:23:29 +11:00
|
|
|
_test_mount -o allocsize=64k
|
|
|
|
|
fi
|
2011-01-07 23:58:50 +11:00
|
|
|
|
2004-06-15 07:32:36 +00:00
|
|
|
echo "brevity is wit..."
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
echo "------"
|
|
|
|
|
echo "test 1"
|
|
|
|
|
echo "------"
|
2015-09-22 10:45:20 +10:00
|
|
|
src/truncfile -c 10000 $TEST_DIR/truncfile.$$.0 >$tmp.out 2>&1
|
|
|
|
|
ret=$?
|
|
|
|
|
if [ "$ret" -ne 0 ]; then
|
|
|
|
|
out=`cat $tmp.out`
|
|
|
|
|
echo "truncfile returned $ret : \"$out\""
|
2001-01-15 05:01:19 +00:00
|
|
|
else
|
2015-09-22 10:45:20 +10:00
|
|
|
echo "OK"
|
2001-01-15 05:01:19 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
exit
|