generic: test adding filesystem-level fscrypt key via key_id
[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 _supported_os Linux
34 _require_test
35
36 echo "Silence is golden"
37
38 mkdir -p $TEST_DIR/testdir_$seq
39 touch $TEST_DIR/testdir_$seq/testfile
40 touch $TEST_DIR/testfile.$seq
41
42 mtime1=`stat -c %Y $TEST_DIR/testdir_$seq`
43 ctime1=`stat -c %Z $TEST_DIR/testdir_$seq`
44
45 sleep 1
46 mv $TEST_DIR/testfile.$seq $TEST_DIR/testdir_$seq/testfile
47
48 mtime2=`stat -c %Y $TEST_DIR/testdir_$seq`
49 ctime2=`stat -c %Z $TEST_DIR/testdir_$seq`
50
51 if [ "$mtime1" == "$mtime2" ]; then
52         echo "mtime not updated"
53         let status=$status+1
54 fi
55 if [ "$ctime1" == "$ctime2" ]; then
56         echo "ctime not updated"
57         let status=$status+1
58 fi
59
60 exit