Skip to content

Commit e456111

Browse files
lrumancikZorro Lang
authored and
Zorro Lang
committed
selftest: add tests for debugging testing setup
Many people have developed infrastructure around xfstests. In order to test a setup, it would be helpful to have dummy tests that have consistent test outcomes. Add a new test folder with the following tests: selftest/001 pass selftest/002 fail from output mismatch selftest/003 fail via _fail selftest/004 skip selftest/005 crash selftest/006 hang Also, create two new groups: 'selftest' which includes tests 001-004 and 'dangerous_selftest' which includes tests 005-006. The selftests will not run unless explicitly specified. Signed-off-by: Leah Rumancik <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Reviewed-by: David Disseldorp <[email protected]> Reviewed-by: Zorro Lang <[email protected]> Signed-off-by: Zorro Lang <[email protected]>
1 parent d33bf05 commit e456111

File tree

15 files changed

+158
-0
lines changed

15 files changed

+158
-0
lines changed

README.selftest

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Tests with consistent results are provided in the selftest folder.
2+
Since many people develop testing infrastructure around xfstests,
3+
these tests are helpful to confirm the testing setup is working as
4+
expected.
5+
6+
The provided tests include:
7+
selftest/001 - pass
8+
selftest/002 - fail from output mismatch
9+
selftest/003 - fail via _fail
10+
selftest/004 - skip
11+
selftest/005 - crash
12+
selftest/006 - hang
13+
14+
Two groups are used for these tests: selftest and dangerous_selftest.
15+
selftest/00[1-4] are in the selftest group and selftest/00[5-6] are
16+
in the dangerous_selftest group.
17+
18+
The selftest will only be run if explicitly speficied. To run the
19+
selftest, you can specify individual tests, e.g.
20+
21+
# ./check selftest/001
22+
23+
or use the groups under selftest/, e.g.
24+
25+
# ./check -g selftest/selftest
26+
# ./check -g selftest/dangerous_selftest
27+
28+
Note, you cannot use the group names without including the folder name
29+
(ie. "-g selftest").

doc/group-names.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dangerous_fsstress_repair race fsstress and xfs_scrub online repair
3838
dangerous_fsstress_scrub race fsstress and xfs_scrub checking
3939
dangerous_repair fuzzers to evaluate xfs_repair offline repair
4040
dangerous_scrub fuzzers to evaluate xfs_scrub checking
41+
dangerous_selftest selftests that crash/hang
4142
data data loss checkers
4243
dax direct access mode for persistent memory files
4344
db xfs_db functional tests
@@ -111,6 +112,7 @@ samefs overlayfs when all layers are on the same fs
111112
scrub filesystem metadata scrubbers
112113
seed btrfs seeded filesystems
113114
seek llseek functionality
115+
selftest tests with fixed results, used to validate testing setup
114116
send btrfs send/receive
115117
shrinkfs decreasing the size of a filesystem
116118
shutdown FS_IOC_SHUTDOWN ioctl

tests/selftest/001

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#! /bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# FS QA Test No. 001
5+
#
6+
# A test that should always pass
7+
#
8+
. ./common/preamble
9+
_begin_fstest selftest
10+
11+
echo "Silence is golden"
12+
status=0
13+
exit

tests/selftest/001.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
QA output created by 001
2+
Silence is golden

tests/selftest/002

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#! /bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# FS QA Test No. 002
5+
#
6+
# A test that should always fail due to output mismatch
7+
#
8+
. ./common/preamble
9+
_begin_fstest selftest
10+
11+
echo "I am intentionally broken"
12+
status=0
13+
exit

tests/selftest/002.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
QA output created by 002
2+
Silence is golden

tests/selftest/003

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#! /bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# FS QA Test No. 003
5+
#
6+
# A test that _fail's
7+
#
8+
9+
. ./common/preamble
10+
_begin_fstest selftest
11+
12+
_fail "I have _fail'ed"
13+
14+
status=0
15+
exit

tests/selftest/003.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
QA output created by 003
2+
Silence is golden

tests/selftest/004

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#! /bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# FS QA Test No. 004
5+
#
6+
# A test that should always be skipped
7+
#
8+
. ./common/preamble
9+
_begin_fstest selftest
10+
11+
_notrun "Always skip me"
12+
13+
echo "I should be skipped"
14+
status=0
15+
exit

tests/selftest/004.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
QA output created by 004
2+
Silence is golden

tests/selftest/005

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#! /bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# FS QA Test No. 005
5+
#
6+
# A test that crashes
7+
#
8+
. ./common/preamble
9+
_begin_fstest dangerous_selftest
10+
11+
echo 1 > /proc/sys/kernel/sysrq
12+
echo c > /proc/sysrq-trigger
13+
14+
echo "I should have crashed by now"
15+
status=0
16+
exit

tests/selftest/005.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
QA output created by 005
2+
Silence is golden

tests/selftest/006

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#! /bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# FS QA Test No. 006
5+
#
6+
# A test that hangs
7+
#
8+
9+
. ./common/preamble
10+
_begin_fstest dangerous_selftest
11+
12+
while :
13+
do
14+
sleep 1d
15+
done
16+
17+
echo "I should still be sleeping"
18+
status=0
19+
exit

tests/selftest/006.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
QA output created by 006
2+
Silence is golden

tests/selftest/Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# Copyright (c) 2023 Google, Inc. All Rights Reserved.
3+
#
4+
5+
TOPDIR = ../..
6+
include $(TOPDIR)/include/builddefs
7+
include $(TOPDIR)/include/buildgrouplist
8+
9+
SELFTEST_DIR = selftest
10+
TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(SELFTEST_DIR)
11+
DIRT = group.list
12+
13+
default: $(DIRT)
14+
15+
include $(BUILDRULES)
16+
17+
install:
18+
$(INSTALL) -m 755 -d $(TARGET_DIR)
19+
$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
20+
$(INSTALL) -m 644 group.list $(TARGET_DIR)
21+
$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
22+
23+
# Nothing.
24+
install-dev install-lib:

0 commit comments

Comments
 (0)