btrfs/012: check free size of scratch device before copying files
[xfstests-dev.git] / tests / generic / 309
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 309
6 #
7 # Test directory mtime and ctime are updated when moving a file onto an
8 # existing file in the directory
9 #
10 # Regression test for commit:
11 # 0b23076 ext3: fix update of mtime and ctime on rename
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 status=0        # success is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22     cd /
23     rm -rf $TEST_DIR/testdir_$seq
24     rm -f $TEST_DIR/testfile.$seq
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # real QA test starts here
32 _supported_fs generic
33 _require_test
34
35 echo "Silence is golden"
36
37 mkdir -p $TEST_DIR/testdir_$seq
38 touch $TEST_DIR/testdir_$seq/testfile
39 touch $TEST_DIR/testfile.$seq
40
41 mtime1=`stat -c %Y $TEST_DIR/testdir_$seq`
42 ctime1=`stat -c %Z $TEST_DIR/testdir_$seq`
43
44 sleep 1
45 mv $TEST_DIR/testfile.$seq $TEST_DIR/testdir_$seq/testfile
46
47 mtime2=`stat -c %Y $TEST_DIR/testdir_$seq`
48 ctime2=`stat -c %Z $TEST_DIR/testdir_$seq`
49
50 if [ "$mtime1" == "$mtime2" ]; then
51         echo "mtime not updated"
52         let status=$status+1
53 fi
54 if [ "$ctime1" == "$ctime2" ]; then
55         echo "ctime not updated"
56         let status=$status+1
57 fi
58
59 exit