generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 157
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 157
6 #
7 # Functional testing for xfs_admin to ensure that it parses arguments correctly
8 # with regards to data devices that are files, external logs, and realtime
9 # devices.
10 #
11 # Because this test synthesizes log and rt devices (by modifying the test run
12 # configuration), it does /not/ require the ability to mount the scratch
13 # filesystem.  This increases test coverage while isolating the weird bits to a
14 # single test.
15 #
16 # This is partially a regression test for "xfs_admin: pick up log arguments
17 # correctly", insofar as the issue fixed by that patch was discovered with an
18 # earlier revision of this test.
19
20 . ./common/preamble
21 _begin_fstest auto quick admin
22
23 # Override the default cleanup function.
24 _cleanup()
25 {
26         cd /
27         rm -f $tmp.* $fake_logfile $fake_rtfile $fake_datafile
28 }
29
30 # Import common functions.
31 . ./common/filter
32
33 # real QA test starts here
34 _supported_fs xfs
35 _require_test
36 _require_scratch_nocheck
37 _require_command "$XFS_ADMIN_PROG" "xfs_admin"
38
39 # Create some fake sparse files for testing external devices and whatnot
40 fake_datafile=$TEST_DIR/$seq.scratch.data
41 rm -f $fake_datafile
42 truncate -s 500m $fake_datafile
43
44 fake_logfile=$TEST_DIR/$seq.scratch.log
45 rm -f $fake_logfile
46 truncate -s 500m $fake_logfile
47
48 fake_rtfile=$TEST_DIR/$seq.scratch.rt
49 rm -f $fake_rtfile
50 truncate -s 500m $fake_rtfile
51
52 # Save the original variables
53 orig_ddev=$SCRATCH_DEV
54 orig_external=$USE_EXTERNAL
55 orig_logdev=$SCRATCH_LOGDEV
56 orig_rtdev=$SCRATCH_RTDEV
57
58 scenario() {
59         echo "$@" | tee -a $seqres.full
60
61         SCRATCH_DEV=$orig_ddev
62         USE_EXTERNAL=$orig_external
63         SCRATCH_LOGDEV=$orig_logdev
64         SCRATCH_RTDEV=$orig_rtdev
65 }
66
67 check_label() {
68         _scratch_mkfs -L oldlabel >> $seqres.full
69         _scratch_xfs_db -c label
70         _scratch_xfs_admin -L newlabel "$@" >> $seqres.full
71         _scratch_xfs_db -c label
72         _scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
73 }
74
75 scenario "S1: Check that label setting with file image"
76 SCRATCH_DEV=$fake_datafile
77 check_label -f
78
79 scenario "S2: Check that setting with logdev works"
80 USE_EXTERNAL=yes
81 SCRATCH_LOGDEV=$fake_logfile
82 check_label
83
84 scenario "S3: Check that setting with rtdev works"
85 USE_EXTERNAL=yes
86 SCRATCH_RTDEV=$fake_rtfile
87 check_label
88
89 scenario "S4: Check that setting with rtdev + logdev works"
90 USE_EXTERNAL=yes
91 SCRATCH_LOGDEV=$fake_logfile
92 SCRATCH_RTDEV=$fake_rtfile
93 check_label
94
95 scenario "S5: Check that setting with nortdev + nologdev works"
96 USE_EXTERNAL=
97 SCRATCH_LOGDEV=
98 SCRATCH_RTDEV=
99 check_label
100
101 scenario "S6: Check that setting with bdev incorrectly flagged as file works"
102 check_label -f
103
104 # success, all done
105 status=0
106 exit