generic: test for creating duplicate filenames in encrypted dir
[xfstests-dev.git] / tests / generic / 169
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2007 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 169
6 #
7 # Test for file size consistency with append followed by umount/mount
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 rm -f $seqres.full
16 status=1    # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 _show_wrote_and_stat_only()
26 {
27         # filer out xfs_io bits we are interested in
28         perl -ne '
29                 if (/^wrote/) { print } ;
30                 if (/^stat\.size/) { print } ;
31         '
32 }
33
34 # get standard environment, filters and checks
35 . ./common/rc
36 . ./common/filter
37
38 # real QA test starts here
39 _supported_fs generic
40
41 _require_scratch
42
43 _scratch_mkfs >>$seqres.full 2>&1 \
44         || _fail "mkfs scratch failed"
45
46 _scratch_mount
47
48 echo "# creating new file for io"
49 touch $SCRATCH_MNT/testfile
50
51 echo "# appending 15k to new file, sync every 5k"
52 $XFS_IO_PROG -a -c "pwrite 0 5k" -c "fsync" \
53         -c "pwrite 5k 5k" -c "fsync" \
54         -c "pwrite 10k 5k" -c "fsync" -c "stat" \
55         $SCRATCH_MNT/testfile \
56         | _show_wrote_and_stat_only
57
58 echo "# remounting scratch"
59 _scratch_cycle_mount >>$seqres.full 2>&1 \
60     || _fail "remount failed: $MOUNT_OPTIONS"
61
62 echo "# stating file to confirm correct size"
63 $XFS_IO_PROG -r -c "stat" $SCRATCH_MNT/testfile \
64         | _show_wrote_and_stat_only
65
66 echo "# appending 10 bytes to new file, sync at 5 bytes"
67 $XFS_IO_PROG -f -c "pwrite 0 5" -c s -c "pwrite 5 5" \
68         -c "stat" $SCRATCH_MNT/nextfile \
69         | _show_wrote_and_stat_only
70
71 echo "# remounting scratch"
72 _scratch_cycle_mount >>$seqres.full 2>&1 \
73     || _fail "remount failed: $MOUNT_OPTIONS"
74
75 echo "# stating file to confirm correct size"
76 $XFS_IO_PROG -r -c "stat" $SCRATCH_MNT/nextfile \
77     | _show_wrote_and_stat_only
78
79 # success, all done
80 status=0
81 exit
82