fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / generic / 349
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 349
6 #
7 # Test fallocate(ZERO_RANGE) on a block device, which should be able to
8 # WRITE SAME (or equivalent) the range.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 7 15
18
19 _cleanup()
20 {
21     cd /
22     rm -rf $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/scsi_debug
29
30 # real QA test starts here
31 _supported_os Linux
32 _require_scsi_debug
33 _require_xfs_io_command "fzero"
34
35 echo "Create and format"
36 dev=$(_get_scsi_debug_dev 512 512 0 4 "lbpws=1 lbpws10=1")
37 _pwrite_byte 0x62 0 4m $dev >> $seqres.full
38
39 echo "Zero range"
40 $XFS_IO_PROG -c "fzero -k 512k 1m" $dev
41
42 echo "Zero range without keep_size"
43 $XFS_IO_PROG -c "fzero 384k 64k" $dev
44
45 echo "Zero range past EOD"
46 $XFS_IO_PROG -c "fzero -k 3m 4m" $dev
47
48 echo "Check contents"
49 md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g"
50
51 echo "Zero range to MAX_LFS_FILESIZE"
52 # zod = MAX_LFS_FILESIZE
53 case "$(getconf LONG_BIT)" in
54 "32")
55         zod=$(( ($(getconf PAGE_SIZE) << ($(getconf LONG_BIT) - 1) ) - 1))
56         ;;
57 "64")
58         zod=9223372036854775807
59         ;;
60 *)
61         _fail "sizeof(long) == $(getconf LONG_BIT)?"
62         ;;
63 esac
64 $XFS_IO_PROG -c "fzero -k 0 $zod" $dev
65
66 echo "Check contents"
67 md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g"
68
69 echo "Destroy device"
70 _put_scsi_debug_dev
71
72 # success, all done
73 status=0
74 exit