Skip to contentSkip to conversation

kselftest/filelock: plan for the five ofdlocks tests

PATCH Applied Danish Khateeb 1 participant 1 message Sep 25 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kselftest/filelock: plan for the five ofdlocks tests

ofdlocks reports five results but plans for four, so even when they all pass it ends with

# Planned tests != run tests (4 != 5)

and exits with KSFT_FAIL, which run_kselftest.sh reports as a failure.

Fixes 33d5b13098fb ("kselftest/filelock: report each test in oftlocks separately")
Assisted-by LLM

---

Notes:
Tested on x86_64 with the kselftest build of ofdlocks:

- Arch host (gcc 16.2, 7.2.6 kernel): before, all 5 pass but it exits 1 with "Planned tests != run tests (4 != 5)"; after, 5/5 and exit 0.
- Debian trixie guest (gcc 14.2, next-20260925): test 4 fails before and after this patch, because it memcmp()s two struct flock whose padding was never initialized (bytes 28-29 differ). Zhou Yuhang's "selftests:
filelock: Initialize the flock to zero" [1] fixes that, and with both patches all 5 pass there too.

[1] https://lore.kernel.org/all/?q=s%3A%22filelock%3A+Initialize+the+flock+to+zero%22

 tools/testing/selftests/filelock/ofdlocks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/filelock/ofdlocks.c +1 -1
index 68bac28b234b..0ab484cb075b 100644
@@ -40,7 +40,7 @@ int main(void)
 	int fd2 = open("/tmp/aa", O_RDONLY);
 
 	ksft_print_header();
-	ksft_set_plan(4);
+	ksft_set_plan(5);
 
 	unlink("/tmp/aa");
 	assert(fd != -1);

base-commit: aa98230e410f0ed212b6788c46b1e4d49e0ff7ca

Signature · 1 line
2.55.0