overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / generic / 408
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Christoph Hellwig.  All Rights Reserved.
4 #
5 # FS QA Test No. 408
6 #
7 # Verify that mtime is not updated when deduping files.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 status=0
15 trap "_cleanup; exit \$status" 0 1 2 3 15
16
17 _cleanup()
18 {
19         cd /
20         rm -f $sourcefile
21         rm -f $destfile
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/reflink
28
29 # real QA test starts here
30 _supported_fs generic
31 _supported_os Linux
32
33 _require_test
34 _require_test_dedupe
35
36 echo "Silence is golden."
37 rm -f $seqres.full
38
39 # pattern the files.
40 sourcefile=$TEST_DIR/dedup_mtime_sourcefile
41 $XFS_IO_PROG -f -c "pwrite 0 4k" -c fsync $sourcefile >> $seqres.full
42
43 destfile=$TEST_DIR/dedup_mtime_destfile
44 $XFS_IO_PROG -f -c "pwrite 0 4k" -c fsync $destfile >> $seqres.full
45
46 # sample timestamps.
47 mtime1=`stat -c %Y $destfile`
48 ctime1=`stat -c %Z $destfile`
49 echo "before dedup: $mtime1 $ctime1" >> $seqres.full
50
51 # dedup to trigger timestamp change
52 sleep 1
53 _dedupe_range $sourcefile 0 $destfile 0 "4k" >> $seqres.full
54
55 # sample and verify that timestamps have changed.
56 mtime2=`stat -c %Y $destfile`
57 ctime2=`stat -c %Z $destfile`
58 echo "after dedup : $mtime2 $ctime2" >> $seqres.full
59
60 if [ "$mtime1" != "$mtime2" ]; then
61         echo "mtime updated"
62         let status=$status+1
63 fi
64 if [ "$ctime1" != "$ctime2" ]; then
65         echo "ctime updated"
66         let status=$status+1
67 fi
68
69 exit