mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
85 lines
2.1 KiB
Bash
85 lines
2.1 KiB
Bash
|
|
#! /bin/bash
|
||
|
|
# FS QA Test No. 407
|
||
|
|
#
|
||
|
|
# Verify that mtime is updated when cloning files
|
||
|
|
#
|
||
|
|
#-----------------------------------------------------------------------
|
||
|
|
#
|
||
|
|
# Copyright (c) 2017 Christoph Hellwig. All Rights Reserved.
|
||
|
|
# This program is free software; you can redistribute it and/or
|
||
|
|
# modify it under the terms of the GNU General Public License as
|
||
|
|
# published by the Free Software Foundation.
|
||
|
|
#
|
||
|
|
# This program is distributed in the hope that it would be useful,
|
||
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
|
# GNU General Public License for more details.
|
||
|
|
#
|
||
|
|
# You should have received a copy of the GNU General Public License
|
||
|
|
# along with this program; if not, write the Free Software Foundation,
|
||
|
|
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||
|
|
#-----------------------------------------------------------------------
|
||
|
|
#
|
||
|
|
|
||
|
|
seq=`basename $0`
|
||
|
|
seqres=$RESULT_DIR/$seq
|
||
|
|
echo "QA output created by $seq"
|
||
|
|
|
||
|
|
here=`pwd`
|
||
|
|
status=0
|
||
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
||
|
|
|
||
|
|
_cleanup()
|
||
|
|
{
|
||
|
|
cd /
|
||
|
|
rm -f $sourcefile
|
||
|
|
rm -f $destfile
|
||
|
|
}
|
||
|
|
|
||
|
|
# get standard environment, filters and checks
|
||
|
|
. ./common/rc
|
||
|
|
. ./common/filter
|
||
|
|
. ./common/reflink
|
||
|
|
|
||
|
|
# real QA test starts here
|
||
|
|
_supported_fs generic
|
||
|
|
_supported_os Linux
|
||
|
|
|
||
|
|
_require_test
|
||
|
|
_require_test_reflink
|
||
|
|
|
||
|
|
echo "Silence is golden."
|
||
|
|
rm -f $seqres.full
|
||
|
|
|
||
|
|
# pattern the files.
|
||
|
|
sourcefile=$TEST_DIR/clone_mtime_sourcefile
|
||
|
|
$XFS_IO_PROG -f -c "pwrite 0 4k" -c fsync $sourcefile >> $seqres.full
|
||
|
|
|
||
|
|
destfile=$TEST_DIR/clone_mtime_destfile
|
||
|
|
touch $destfile >> $seqres.full
|
||
|
|
|
||
|
|
# sample timestamps.
|
||
|
|
mtime1=`stat -c %Y $destfile`
|
||
|
|
ctime1=`stat -c %Z $destfile`
|
||
|
|
echo "before clone: $mtime1 $ctime1" >> $seqres.full
|
||
|
|
|
||
|
|
# clone to trigger timestamp change
|
||
|
|
sleep 1
|
||
|
|
$XFS_IO_PROG -c "reflink $sourcefile " $destfile >> $seqres.full
|
||
|
|
|
||
|
|
# sample and verify that timestamps have changed.
|
||
|
|
mtime2=`stat -c %Y $destfile`
|
||
|
|
ctime2=`stat -c %Z $destfile`
|
||
|
|
echo "after clone : $mtime2 $ctime2" >> $seqres.full
|
||
|
|
|
||
|
|
if [ "$mtime1" == "$mtime2" ]; then
|
||
|
|
echo "mtime not updated"
|
||
|
|
let status=$status+1
|
||
|
|
fi
|
||
|
|
if [ "$ctime1" == "$ctime2" ]; then
|
||
|
|
echo "ctime not updated"
|
||
|
|
let status=$status+1
|
||
|
|
fi
|
||
|
|
|
||
|
|
exit
|