Skip to content

Commit 8fb1e2e

Browse files
committed
Merge tag 'linux_kselftest-next-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kselftest updates from Shuah Khan: - fixes, reporting improvements, and cleanup changes to several tests - add support for DT_GNU_HASH to selftests/vDSO * tag 'linux_kselftest-next-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: selftests/rseq: Fix handling of glibc without rseq support selftests/resctrl: Discover SNC kernel support and adjust messages selftests/resctrl: Adjust effective L3 cache size with SNC enabled selftests/ftrace: Make uprobe test more robust against binary name selftests/ftrace: Fix to use remount when testing mount GID option selftests: tmpfs: Add kselftest support to tmpfs selftests: tmpfs: Add Test-skip if not run as root selftests: harness: fix printing of mismatch values in __EXPECT() selftests/ring-buffer: Add test for out-of-bound pgoff mapping selftests/run_kselftest.sh: Fix help string for --per-test-log selftests: acct: Add ksft_exit_skip if not running as root selftests: kselftest: Fix the wrong format specifier selftests: timers: clocksource-switch: Adapt progress to kselftest framework selftests/zram: gitignore output file selftests/filesystems: Add missing gitignore file selftests: Warn about skipped tests in result summary selftests: kselftest: Add ksft_test_result_xpass selftests/vDSO: support DT_GNU_HASH selftests/ipc: Remove unused variables selftest: media_tests: fix trivial UAF typo
2 parents 88e969f + 336d02b commit 8fb1e2e

File tree

25 files changed

+371
-86
lines changed

25 files changed

+371
-86
lines changed

tools/testing/selftests/acct/acct_syscall.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int main(void)
2424

2525
// Check if test is run a root
2626
if (geteuid()) {
27-
ksft_test_result_skip("This test needs root to run!\n");
27+
ksft_exit_skip("This test needs root to run!\n");
2828
return 1;
2929
}
3030

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2+
statmount_test_ns
23
/*_test

tools/testing/selftests/ftrace/test.d/00basic/mount_options.tc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ find_alternate_gid() {
1515
tac /etc/group | grep -v ":$original_gid:" | head -1 | cut -d: -f3
1616
}
1717

18-
mount_tracefs_with_options() {
18+
remount_tracefs_with_options() {
1919
local mount_point="$1"
2020
local options="$2"
2121

22-
mount -t tracefs -o "$options" nodev "$mount_point"
22+
mount -t tracefs -o "remount,$options" nodev "$mount_point"
2323

2424
setup
2525
}
@@ -81,7 +81,7 @@ test_gid_mount_option() {
8181

8282
# Unmount existing tracefs instance and mount with new GID
8383
unmount_tracefs "$mount_point"
84-
mount_tracefs_with_options "$mount_point" "$new_options"
84+
remount_tracefs_with_options "$mount_point" "$new_options"
8585

8686
check_gid "$mount_point" "$other_group"
8787

@@ -92,7 +92,7 @@ test_gid_mount_option() {
9292

9393
# Unmount and remount with the original GID
9494
unmount_tracefs "$mount_point"
95-
mount_tracefs_with_options "$mount_point" "$mount_options"
95+
remount_tracefs_with_options "$mount_point" "$mount_options"
9696
check_gid "$mount_point" "$original_group"
9797
}
9898

tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
echo 0 > events/enable
77
echo > dynamic_events
88

9+
REALBIN=`readlink -f /bin/sh`
10+
911
echo 'cat /proc/$$/maps' | /bin/sh | \
10-
grep "r-xp .*/bin/.*sh$" | \
12+
grep "r-xp .*${REALBIN}$" | \
1113
awk '{printf "p:myevent %s:0x%s\n", $6,$3 }' >> uprobe_events
1214

1315
grep -q myevent uprobe_events

tools/testing/selftests/ipc/msgque.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ int fill_msgque(struct msgque_data *msgque)
194194

195195
int main(int argc, char **argv)
196196
{
197-
int msg, pid, err;
197+
int err;
198198
struct msgque_data msgque;
199199

200200
if (getuid() != 0)

tools/testing/selftests/kselftest.h

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818
* ksft_print_msg(fmt, ...);
1919
* ksft_perror(msg);
2020
*
21-
* and finally report the pass/fail/skip/xfail state of the test with one of:
21+
* and finally report the pass/fail/skip/xfail/xpass state of the test
22+
* with one of:
2223
*
2324
* ksft_test_result(condition, fmt, ...);
2425
* ksft_test_result_report(result, fmt, ...);
2526
* ksft_test_result_pass(fmt, ...);
2627
* ksft_test_result_fail(fmt, ...);
2728
* ksft_test_result_skip(fmt, ...);
2829
* ksft_test_result_xfail(fmt, ...);
30+
* ksft_test_result_xpass(fmt, ...);
2931
* ksft_test_result_error(fmt, ...);
3032
* ksft_test_result_code(exit_code, test_name, fmt, ...);
3133
*
@@ -147,6 +149,11 @@ static inline void ksft_set_plan(unsigned int plan)
147149

148150
static inline void ksft_print_cnts(void)
149151
{
152+
if (ksft_cnt.ksft_xskip > 0)
153+
printf(
154+
"# %u skipped test(s) detected. Consider enabling relevant config options to improve coverage.\n",
155+
ksft_cnt.ksft_xskip
156+
);
150157
if (ksft_plan != ksft_test_num())
151158
printf("# Planned tests != run tests (%u != %u)\n",
152159
ksft_plan, ksft_test_num());
@@ -227,6 +234,20 @@ static inline __printf(1, 2) void ksft_test_result_xfail(const char *msg, ...)
227234
va_end(args);
228235
}
229236

237+
static inline __printf(1, 2) void ksft_test_result_xpass(const char *msg, ...)
238+
{
239+
int saved_errno = errno;
240+
va_list args;
241+
242+
ksft_cnt.ksft_xpass++;
243+
244+
va_start(args, msg);
245+
printf("ok %u # XPASS ", ksft_test_num());
246+
errno = saved_errno;
247+
vprintf(msg, args);
248+
va_end(args);
249+
}
250+
230251
static inline __printf(1, 2) void ksft_test_result_skip(const char *msg, ...)
231252
{
232253
int saved_errno = errno;
@@ -318,6 +339,9 @@ void ksft_test_result_code(int exit_code, const char *test_name,
318339
case KSFT_XFAIL: \
319340
ksft_test_result_xfail(fmt, ##__VA_ARGS__); \
320341
break; \
342+
case KSFT_XPASS: \
343+
ksft_test_result_xpass(fmt, ##__VA_ARGS__); \
344+
break; \
321345
case KSFT_SKIP: \
322346
ksft_test_result_skip(fmt, ##__VA_ARGS__); \
323347
break; \
@@ -403,7 +427,7 @@ static inline __noreturn __printf(1, 2) void ksft_exit_skip(const char *msg, ...
403427
*/
404428
if (ksft_plan || ksft_test_num()) {
405429
ksft_cnt.ksft_xskip++;
406-
printf("ok %d # SKIP ", 1 + ksft_test_num());
430+
printf("ok %u # SKIP ", 1 + ksft_test_num());
407431
} else {
408432
printf("1..0 # SKIP ");
409433
}

tools/testing/selftests/kselftest/ksft.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def set_plan(num_tests):
2727

2828

2929
def print_cnts():
30+
if ksft_cnt['skip'] > 0:
31+
print(f"# {ksft_cnt['skip']} skipped test(s) detected. Consider enabling relevant config options to improve coverage.")
32+
3033
print(
3134
f"# Totals: pass:{ksft_cnt['pass']} fail:{ksft_cnt['fail']} xfail:0 xpass:0 skip:{ksft_cnt['skip']} error:0"
3235
)

tools/testing/selftests/kselftest/ktap_helpers.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,9 @@ ktap_finished() {
118118
}
119119

120120
ktap_print_totals() {
121+
if [ "$KTAP_CNT_SKIP" -gt 0 ]; then
122+
echo "# $KTAP_CNT_SKIP skipped test(s) detected. " \
123+
"Consider enabling relevant config options to improve coverage."
124+
fi
121125
echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:$KTAP_CNT_XFAIL xpass:0 skip:$KTAP_CNT_SKIP error:0"
122126
}

tools/testing/selftests/kselftest_harness.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -760,33 +760,33 @@
760760
/* Report with actual signedness to avoid weird output. */ \
761761
switch (is_signed_type(__exp) * 2 + is_signed_type(__seen)) { \
762762
case 0: { \
763-
unsigned long long __exp_print = (uintptr_t)__exp; \
764-
unsigned long long __seen_print = (uintptr_t)__seen; \
765-
__TH_LOG("Expected %s (%llu) %s %s (%llu)", \
763+
uintmax_t __exp_print = (uintmax_t)__exp; \
764+
uintmax_t __seen_print = (uintmax_t)__seen; \
765+
__TH_LOG("Expected %s (%ju) %s %s (%ju)", \
766766
_expected_str, __exp_print, #_t, \
767767
_seen_str, __seen_print); \
768768
break; \
769769
} \
770770
case 1: { \
771-
unsigned long long __exp_print = (uintptr_t)__exp; \
772-
long long __seen_print = (intptr_t)__seen; \
773-
__TH_LOG("Expected %s (%llu) %s %s (%lld)", \
771+
uintmax_t __exp_print = (uintmax_t)__exp; \
772+
intmax_t __seen_print = (intmax_t)__seen; \
773+
__TH_LOG("Expected %s (%ju) %s %s (%jd)", \
774774
_expected_str, __exp_print, #_t, \
775775
_seen_str, __seen_print); \
776776
break; \
777777
} \
778778
case 2: { \
779-
long long __exp_print = (intptr_t)__exp; \
780-
unsigned long long __seen_print = (uintptr_t)__seen; \
781-
__TH_LOG("Expected %s (%lld) %s %s (%llu)", \
779+
intmax_t __exp_print = (intmax_t)__exp; \
780+
uintmax_t __seen_print = (uintmax_t)__seen; \
781+
__TH_LOG("Expected %s (%jd) %s %s (%ju)", \
782782
_expected_str, __exp_print, #_t, \
783783
_seen_str, __seen_print); \
784784
break; \
785785
} \
786786
case 3: { \
787-
long long __exp_print = (intptr_t)__exp; \
788-
long long __seen_print = (intptr_t)__seen; \
789-
__TH_LOG("Expected %s (%lld) %s %s (%lld)", \
787+
intmax_t __exp_print = (intmax_t)__exp; \
788+
intmax_t __seen_print = (intmax_t)__seen; \
789+
__TH_LOG("Expected %s (%jd) %s %s (%jd)", \
790790
_expected_str, __exp_print, #_t, \
791791
_seen_str, __seen_print); \
792792
break; \

tools/testing/selftests/media_tests/regression_test.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Testing for regressions in Media Controller API register, ioctl, syscall,
2-
and unregister paths. There have a few problems that result in user-after
2+
and unregister paths. There have a few problems that result in use-after
33
free on media_device, media_devnode, and cdev pointers when the driver is
44
unbound while ioctl is in progress.
55

@@ -15,11 +15,11 @@ Build media_device_test
1515
cd tools/testing/selftests/media_tests
1616
make
1717

18-
Regressions test for cdev user-after free error on /dev/mediaX when driver
18+
Regressions test for cdev use-after-free error on /dev/mediaX when driver
1919
is unbound:
2020

2121
Start media_device_test to regression test media devnode dynamic alloc
22-
and cdev user-after-free fixes. This opens media dev files and sits in
22+
and cdev use-after-free fixes. This opens media dev files and sits in
2323
a loop running media ioctl MEDIA_IOC_DEVICE_INFO command once every 10
2424
seconds. The idea is when device file goes away, media devnode and cdev
2525
should stick around until this test exits.
@@ -40,4 +40,4 @@ keep ioctls going while bind/unbind runs.
4040
Copy bind_unbind_sample.txt and make changes to specify the driver name
4141
and number to run bind and unbind. Start the bind_unbind.sh
4242

43-
Run dmesg looking for any user-after free errors or mutex lock errors.
43+
Run dmesg looking for any use-after-free errors or mutex lock errors.

0 commit comments

Comments
 (0)