fstests: move test group info to test files
[xfstests-dev.git] / tests / ext4 / 024
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Google, Inc.  All Rights Reserved.
4 #
5 # FS QA Test ext4/024
6 #
7 # Regression test for 0d06863f903a ("ext4: don't BUG when truncating encrypted
8 # inodes on the orphan list").
9 #
10 . ./common/preamble
11 _begin_fstest auto quick encrypt dangerous
12
13 # get standard environment and checks
14 . ./common/encrypt
15
16 # real QA test starts here
17 _supported_fs ext4
18 _require_scratch_encryption
19 _require_command "$KEYCTL_PROG" keyctl
20
21 _new_session_keyring
22
23 #
24 # Create an encrypted file whose size is not a multiple of the filesystem block
25 # size, then add it to the orphan list.
26 #
27 # We create the encrypted file normally, rather than use debugfs to force the
28 # inode flags to ENCRYPT|EXTENTS as done in the example listed in the commit
29 # message of the kernel fix, because forcing the inode flags is incompatible
30 # with some MKFS_OPTIONS such as inline_data or ^extents.
31 #
32 # This choice does, however, have the disadvantage that this test won't detect
33 # the bug in as many situations, such as in kernels configured without
34 # encryption support.
35 #
36 _scratch_mkfs_encrypted &>>$seqres.full
37 _scratch_mount
38 mkdir $SCRATCH_MNT/edir
39 keydesc=$(_generate_session_encryption_key)
40 _set_encpolicy $SCRATCH_MNT/edir $keydesc
41 echo foo > $SCRATCH_MNT/edir/file
42 inum=$(stat -c '%i' $SCRATCH_MNT/edir/file)
43 _scratch_unmount
44 debugfs -w -R "set_super_value s_last_orphan $inum" $SCRATCH_DEV &>>$seqres.full
45
46 # Try to mount the filesystem.  This would hit a BUG() in fs/ext4/inode.c.
47 _try_scratch_mount
48
49 # success, all done
50 echo "Didn't crash!"
51 status=0
52 exit