fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 509
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 509
6 #
7 # Test that if we fsync a tmpfile, without adding a hard link to it, and then
8 # power fail, we will be able to mount the filesystem without triggering any
9 # crashes, warnings or corruptions.
10 #
11 . ./common/preamble
12 _begin_fstest auto quick log
13
14 # Override the default cleanup function.
15 _cleanup()
16 {
17         _cleanup_flakey
18         cd /
19         rm -f $tmp.*
20 }
21
22 # Import common functions.
23 . ./common/filter
24 . ./common/dmflakey
25
26 # real QA test starts here
27 _supported_fs generic
28 _require_scratch
29 _require_xfs_io_command "-T"
30 _require_dm_target flakey
31
32 _scratch_mkfs >>$seqres.full 2>&1
33 _require_metadata_journaling $SCRATCH_DEV
34 _init_flakey
35 _mount_flakey
36
37 # Create our tmpfile, write some data to it and fsync it. We want a power
38 # failure to happen after the fsync, so that we have an inode with a link
39 # count of 0 in our log/journal.
40 $XFS_IO_PROG -T \
41         -c "pwrite -S 0xab 0 64K" \
42         -c "fsync" \
43         $SCRATCH_MNT | _filter_xfs_io
44
45 # Simulate a power failure and mount the filesystem to check that it succeeds.
46 _flakey_drop_and_remount
47
48 _unmount_flakey
49
50 status=0
51 exit