common/fuzzy: try to clear blocking flags first in _scratch_fuzz_modify
[xfstests-dev.git] / tests / generic / 125
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 125
6 #
7 # ftruncate test, modified from CXFSQA tests cxfs_ftrunc and cxfs_trunc
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "exit \$status" 0 1 2 3 15
17
18 # get standard environment, filters and checks
19 . ./common/rc
20 . ./common/filter
21
22 # real QA test starts here
23 _supported_fs generic
24 _supported_os Linux
25
26 _require_test
27 _require_user
28 _require_odirect
29
30 TESTDIR=$TEST_DIR/ftrunc
31 TESTFILE=$TESTDIR/ftrunc.tmp
32
33 [ -d $TESTDIR ] && rm -r $TESTDIR
34 mkdir $TESTDIR
35
36 # ftrunc must be run as a mortal user.
37 touch $TESTFILE
38
39 chmod a+rw $TESTDIR
40 chmod a+rw $TESTFILE
41
42 # don't use $here/src/ftrunc, as we're running it as a regular user, and $here
43 # may contain path component that a regular user doesn't have search permission
44 su $qa_user -c "./src/ftrunc -f $TESTFILE"
45
46 if [ "$?" != "0" ];  then
47     echo src/ftrunc returned non 0 status!
48 fi
49
50 $here/src/trunc -f $TESTFILE
51 if (test $? -eq 0 ) then
52     status=0
53 fi
54
55 exit