Skip to content

Commit a747acc

Browse files
committed
Merge tag 'linux-kselftest-next-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kselftest fixes from Shuah Khan: - kselftest runner script to propagate SIGTERM to runner child to avoid kselftest hang - install symlinks required for test execution to avoid test failures - kselftest dependency checker script argument parsing * tag 'linux-kselftest-next-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: selftests: Keep symlinks, when possible selftests: fix dependency checker script kselftest/runner.sh: Propagate SIGTERM to runner child selftests/ftrace: Correctly enable event in instance-event.tc
2 parents fb52c87 + 3f3f384 commit a747acc

File tree

4 files changed

+70
-16
lines changed

4 files changed

+70
-16
lines changed

tools/testing/selftests/ftrace/test.d/instances/instance-event.tc

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ instance_read() {
3939

4040
instance_set() {
4141
while :; do
42-
echo 1 > foo/events/sched/sched_switch
42+
echo 1 > foo/events/sched/sched_switch/enable
4343
done 2> /dev/null
4444
}
4545

tools/testing/selftests/kselftest/runner.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ tap_timeout()
3636
{
3737
# Make sure tests will time out if utility is available.
3838
if [ -x /usr/bin/timeout ] ; then
39-
/usr/bin/timeout --foreground "$kselftest_timeout" $1
39+
/usr/bin/timeout --foreground "$kselftest_timeout" \
40+
/usr/bin/timeout "$kselftest_timeout" $1
4041
else
4142
$1
4243
fi

tools/testing/selftests/kselftest_deps.sh

+65-12
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ fi
4646
print_targets=0
4747

4848
while getopts "p" arg; do
49-
case $arg in
50-
p)
49+
case $arg in
50+
p)
5151
print_targets=1
5252
shift;;
53-
esac
53+
esac
5454
done
5555

5656
if [ $# -eq 0 ]
@@ -92,6 +92,10 @@ pass_cnt=0
9292
# Get all TARGETS from selftests Makefile
9393
targets=$(grep -E "^TARGETS +|^TARGETS =" Makefile | cut -d "=" -f2)
9494

95+
# Initially, in LDLIBS related lines, the dep checker needs
96+
# to ignore lines containing the following strings:
97+
filter="\$(VAR_LDLIBS)\|pkg-config\|PKG_CONFIG\|IOURING_EXTRA_LIBS"
98+
9599
# Single test case
96100
if [ $# -eq 2 ]
97101
then
@@ -100,6 +104,8 @@ then
100104
l1_test $test
101105
l2_test $test
102106
l3_test $test
107+
l4_test $test
108+
l5_test $test
103109

104110
print_results $1 $2
105111
exit $?
@@ -113,7 +119,7 @@ fi
113119
# Append space at the end of the list to append more tests.
114120

115121
l1_tests=$(grep -r --include=Makefile "^LDLIBS" | \
116-
grep -v "VAR_LDLIBS" | awk -F: '{print $1}')
122+
grep -v "$filter" | awk -F: '{print $1}' | uniq)
117123

118124
# Level 2: LDLIBS set dynamically.
119125
#
@@ -126,7 +132,7 @@ l1_tests=$(grep -r --include=Makefile "^LDLIBS" | \
126132
# Append space at the end of the list to append more tests.
127133

128134
l2_tests=$(grep -r --include=Makefile ": LDLIBS" | \
129-
grep -v "VAR_LDLIBS" | awk -F: '{print $1}')
135+
grep -v "$filter" | awk -F: '{print $1}' | uniq)
130136

131137
# Level 3
132138
# memfd and others use pkg-config to find mount and fuse libs
@@ -138,11 +144,32 @@ l2_tests=$(grep -r --include=Makefile ": LDLIBS" | \
138144
# VAR_LDLIBS := $(shell pkg-config fuse --libs 2>/dev/null)
139145

140146
l3_tests=$(grep -r --include=Makefile "^VAR_LDLIBS" | \
141-
grep -v "pkg-config" | awk -F: '{print $1}')
147+
grep -v "pkg-config\|PKG_CONFIG" | awk -F: '{print $1}' | uniq)
142148

143-
#echo $l1_tests
144-
#echo $l2_1_tests
145-
#echo $l3_tests
149+
# Level 4
150+
# some tests may fall back to default using `|| echo -l<libname>`
151+
# if pkg-config doesn't find the libs, instead of using VAR_LDLIBS
152+
# as per level 3 checks.
153+
# e.g:
154+
# netfilter/Makefile
155+
# LDLIBS += $(shell $(HOSTPKG_CONFIG) --libs libmnl 2>/dev/null || echo -lmnl)
156+
l4_tests=$(grep -r --include=Makefile "^LDLIBS" | \
157+
grep "pkg-config\|PKG_CONFIG" | awk -F: '{print $1}' | uniq)
158+
159+
# Level 5
160+
# some tests may use IOURING_EXTRA_LIBS to add extra libs to LDLIBS,
161+
# which in turn may be defined in a sub-Makefile
162+
# e.g.:
163+
# mm/Makefile
164+
# $(OUTPUT)/gup_longterm: LDLIBS += $(IOURING_EXTRA_LIBS)
165+
l5_tests=$(grep -r --include=Makefile "LDLIBS +=.*\$(IOURING_EXTRA_LIBS)" | \
166+
awk -F: '{print $1}' | uniq)
167+
168+
#echo l1_tests $l1_tests
169+
#echo l2_tests $l2_tests
170+
#echo l3_tests $l3_tests
171+
#echo l4_tests $l4_tests
172+
#echo l5_tests $l5_tests
146173

147174
all_tests
148175
print_results $1 $2
@@ -164,24 +191,32 @@ all_tests()
164191
for test in $l3_tests; do
165192
l3_test $test
166193
done
194+
195+
for test in $l4_tests; do
196+
l4_test $test
197+
done
198+
199+
for test in $l5_tests; do
200+
l5_test $test
201+
done
167202
}
168203

169204
# Use same parsing used for l1_tests and pick libraries this time.
170205
l1_test()
171206
{
172207
test_libs=$(grep --include=Makefile "^LDLIBS" $test | \
173-
grep -v "VAR_LDLIBS" | \
208+
grep -v "$filter" | \
174209
sed -e 's/\:/ /' | \
175210
sed -e 's/+/ /' | cut -d "=" -f 2)
176211

177212
check_libs $test $test_libs
178213
}
179214

180-
# Use same parsing used for l2__tests and pick libraries this time.
215+
# Use same parsing used for l2_tests and pick libraries this time.
181216
l2_test()
182217
{
183218
test_libs=$(grep --include=Makefile ": LDLIBS" $test | \
184-
grep -v "VAR_LDLIBS" | \
219+
grep -v "$filter" | \
185220
sed -e 's/\:/ /' | sed -e 's/+/ /' | \
186221
cut -d "=" -f 2)
187222

@@ -197,6 +232,24 @@ l3_test()
197232
check_libs $test $test_libs
198233
}
199234

235+
l4_test()
236+
{
237+
test_libs=$(grep --include=Makefile "^VAR_LDLIBS\|^LDLIBS" $test | \
238+
grep "\(pkg-config\|PKG_CONFIG\).*|| echo " | \
239+
sed -e 's/.*|| echo //' | sed -e 's/)$//')
240+
241+
check_libs $test $test_libs
242+
}
243+
244+
l5_test()
245+
{
246+
tests=$(find $(dirname "$test") -type f -name "*.mk")
247+
test_libs=$(grep "^IOURING_EXTRA_LIBS +\?=" $tests | \
248+
cut -d "=" -f 2)
249+
250+
check_libs $test $test_libs
251+
}
252+
200253
check_libs()
201254
{
202255

tools/testing/selftests/lib.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ endef
106106
run_tests: all
107107
ifdef building_out_of_srctree
108108
@if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \
109-
rsync -aLq $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(OUTPUT); \
109+
rsync -aq --copy-unsafe-links $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(OUTPUT); \
110110
fi
111111
@if [ "X$(TEST_PROGS)" != "X" ]; then \
112112
$(call RUN_TESTS, $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) \
@@ -120,7 +120,7 @@ endif
120120

121121
define INSTALL_SINGLE_RULE
122122
$(if $(INSTALL_LIST),@mkdir -p $(INSTALL_PATH))
123-
$(if $(INSTALL_LIST),rsync -aL $(INSTALL_LIST) $(INSTALL_PATH)/)
123+
$(if $(INSTALL_LIST),rsync -a --copy-unsafe-links $(INSTALL_LIST) $(INSTALL_PATH)/)
124124
endef
125125

126126
define INSTALL_RULE

0 commit comments

Comments
 (0)