fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 104
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FSQA Test No. 104
6 #
7 # Test that if we add hard links (in the same directory) to two files and then
8 # fsync only one of the files, after the fsync log/journal is replayed all the
9 # links exist and the filesystem metadata (directory and file inodes) is in a
10 # consistent state.
11 #
12 . ./common/preamble
13 _begin_fstest auto quick metadata log
14
15 # Override the default cleanup function.
16 _cleanup()
17 {
18         _cleanup_flakey
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_hardlinks
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 test directory and files.
38 mkdir $SCRATCH_MNT/testdir
39 touch $SCRATCH_MNT/testdir/foo
40 touch $SCRATCH_MNT/testdir/bar
41
42 # Make sure everything done so far is durably persisted.
43 sync
44
45 # Create one hard link for file foo and another one for file bar. After that
46 # fsync only the file bar.
47 ln $SCRATCH_MNT/testdir/bar $SCRATCH_MNT/testdir/bar_link
48 ln $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/foo_link
49 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/bar
50
51 _flakey_drop_and_remount
52
53 # Now verify both our files have a link count of 2.
54 echo "Link count for file foo: $(stat -c %h $SCRATCH_MNT/testdir/foo)"
55 echo "Link count for file bar: $(stat -c %h $SCRATCH_MNT/testdir/bar)"
56
57 # We should be able to remove all the links of our files in testdir, and after
58 # that the parent directory should become empty and therefore possible to
59 # remove it.
60 rm -f $SCRATCH_MNT/testdir/*
61 rmdir $SCRATCH_MNT/testdir
62
63 _unmount_flakey
64
65 # The fstests framework will call fsck against our filesystem which will verify
66 # that all metadata is in a consistent state.
67
68 status=0
69 exit