generic: Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations
[xfstests-dev.git] / tests / generic / 407
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. 407
6 #
7 # Verify that mtime is updated when cloning 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_reflink
35
36 echo "Silence is golden."
37 rm -f $seqres.full
38
39 # pattern the files.
40 sourcefile=$TEST_DIR/clone_mtime_sourcefile
41 $XFS_IO_PROG -f -c "pwrite 0 4k" -c fsync $sourcefile >> $seqres.full
42
43 destfile=$TEST_DIR/clone_mtime_destfile
44 touch $destfile >> $seqres.full
45
46 # sample timestamps.
47 mtime1=`stat -c %Y $destfile`
48 ctime1=`stat -c %Z $destfile`
49 echo "before clone: $mtime1 $ctime1" >> $seqres.full
50
51 # clone to trigger timestamp change
52 sleep 1
53 $XFS_IO_PROG -c "reflink $sourcefile " $destfile >> $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 clone : $mtime2 $ctime2" >> $seqres.full
59
60 if [ "$mtime1" == "$mtime2" ]; then
61         echo "mtime not updated"
62         let status=$status+1
63 fi
64 if [ "$ctime1" == "$ctime2" ]; then
65         echo "ctime not updated"
66         let status=$status+1
67 fi
68
69 exit