tests: remove udf/101
[xfstests-dev.git] / tests / generic / 408
1 #! /bin/bash
2 # FS QA Test No. 408
3 #
4 # Verify that mtime is not updated when deduping files.
5 #
6 #-----------------------------------------------------------------------
7 #
8 # Copyright (c) 2017 Christoph Hellwig.  All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #-----------------------------------------------------------------------
22 #
23
24 seq=`basename $0`
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
27
28 here=`pwd`
29 status=0
30 trap "_cleanup; exit \$status" 0 1 2 3 15
31
32 _cleanup()
33 {
34         cd /
35         rm -f $sourcefile
36         rm -f $destfile
37 }
38
39 # get standard environment, filters and checks
40 . ./common/rc
41 . ./common/filter
42 . ./common/reflink
43
44 # real QA test starts here
45 _supported_fs generic
46 _supported_os Linux
47
48 _require_test
49 _require_test_dedupe
50
51 echo "Silence is golden."
52 rm -f $seqres.full
53
54 # pattern the files.
55 sourcefile=$TEST_DIR/dedup_mtime_sourcefile
56 $XFS_IO_PROG -f -c "pwrite 0 4k" -c fsync $sourcefile >> $seqres.full
57
58 destfile=$TEST_DIR/dedup_mtime_destfile
59 $XFS_IO_PROG -f -c "pwrite 0 4k" -c fsync $destfile >> $seqres.full
60
61 # sample timestamps.
62 mtime1=`stat -c %Y $destfile`
63 ctime1=`stat -c %Z $destfile`
64 echo "before dedup: $mtime1 $ctime1" >> $seqres.full
65
66 # dedup to trigger timestamp change
67 sleep 1
68 _dedupe_range $sourcefile 0 $destfile 0 "4k" >> $seqres.full
69
70 # sample and verify that timestamps have changed.
71 mtime2=`stat -c %Y $destfile`
72 ctime2=`stat -c %Z $destfile`
73 echo "after dedup : $mtime2 $ctime2" >> $seqres.full
74
75 if [ "$mtime1" != "$mtime2" ]; then
76         echo "mtime updated"
77         let status=$status+1
78 fi
79 if [ "$ctime1" != "$ctime2" ]; then
80         echo "ctime updated"
81         let status=$status+1
82 fi
83
84 exit