git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 2/2] t0000: test taking over and releasing the EXPENSIVE lock

From
Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Date
Nov 28, 2026, 14:58 UTC
Message-ID
<20261128-ks-ci-long-test-hang-fix-v4-2-f117badd2e13@gmail.com>
In-Reply-To
<20261128-ks-ci-long-test-hang-fix-v4-0-f117badd2e13@gmail.com>

The previous commit serializes EXPENSIVE tests with a lock that a waiter takes over when its holder was killed, and that the EXIT trap releases when a script dies while holding it.

Add subtests checking that:
  - a lock left by a dead process is taken over, held while the test
    runs, and released afterwards;
  - a lock carrying the script's own PID, which can only be left by a
    dead holder whose PID was reused, is taken over;
  - a script exiting in the middle of an EXPENSIVE test does not leave
    the lock behind.
None of them has to wait, as a stale lock is cleared without polling.
Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
---
 t/t0000-basic.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 7bd1f4e7b7..1535b7aa7e 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -746,6 +746,54 @@ test_expect_success 'subtest: lazy prereqs do not turn off tracing' '
 	test_grep "echo trace" lazy-prereq-and-tracing/err
 '
 
+test_expect_success 'subtest: EXPENSIVE lock of a dead holder is taken over' '
+	write_sub_test_lib_test expensive-lock-dead <<-\EOF &&
+	test_expect_success EXPENSIVE "holds the lock" "
+		echo $$ >expect &&
+		test_cmp expect \"$TEST_RESULTS_DIR/expensive.lock\"
+	"
+	test_done
+	EOF
+	mkdir expensive-lock-dead/test-results &&
+	sh -c "echo \$\$" >expensive-lock-dead/test-results/expensive.lock &&
+	run_sub_test_lib_test expensive-lock-dead --long &&
+	check_sub_test_lib_test expensive-lock-dead <<-\EOF &&
+	> ok 1 - holds the lock
+	> # passed all 1 test(s)
+	> 1..1
+	EOF
+	test_path_is_missing expensive-lock-dead/test-results/expensive.lock
+'
+
+test_expect_success 'subtest: EXPENSIVE lock carrying our own PID is taken over' '
+	write_sub_test_lib_test expensive-lock-own-pid <<-\EOF &&
+	mkdir -p "$TEST_RESULTS_DIR" &&
+	echo $$ >"$TEST_RESULTS_DIR/expensive.lock"
+	test_expect_success EXPENSIVE "takes the lock" "true"
+	test_done
+	EOF
+	run_sub_test_lib_test expensive-lock-own-pid --long &&
+	check_sub_test_lib_test expensive-lock-own-pid <<-\EOF &&
+	> ok 1 - takes the lock
+	> # passed all 1 test(s)
+	> 1..1
+	EOF
+	test_path_is_missing expensive-lock-own-pid/test-results/expensive.lock
+'
+
+test_expect_success 'subtest: EXPENSIVE lock is released when exiting mid-test' '
+	write_sub_test_lib_test expensive-lock-exit <<-\EOF &&
+	test_expect_success EXPENSIVE "exits holding the lock" "
+		test_path_is_file \"$TEST_RESULTS_DIR/expensive.lock\" &&
+		exit 1
+	"
+	test_done
+	EOF
+	run_sub_test_lib_test_err expensive-lock-exit --long &&
+	test_grep "FATAL: Unexpected exit" expensive-lock-exit/out &&
+	test_path_is_missing expensive-lock-exit/test-results/expensive.lock
+'
+
 test_expect_success 'subtest: tests clean up after themselves' '
 	write_and_run_sub_test_lib_test cleanup <<-\EOF &&
 	clean=no
-- 
2.56.1.911.g883d8bcb20
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 27 of 32 in “test-lib: run EXPENSIVE tests one at a time”
  1. test-lib: run EXPENSIVE tests one at a timeKaartic Sivaraam, Nov 19, 2026
  2. Patrick SteinhardtNov 19, 2026
  3. Kaartic SivaraamNov 19, 2026
  4. test-lib: run EXPENSIVE tests one at a timeKaartic Sivaraam, Nov 19, 2026
  5. Kaartic SivaraamNov 19, 2026
  6. Junio C HamanoNov 20, 2026
  7. Kaartic SivaraamNov 24, 2026
  8. Junio C HamanoNov 25, 2026
  9. Kaartic SivaraamNov 27, 2026
  10. Junio C HamanoNov 27, 2026
  11. Harald NordgrenNov 25, 2026
  12. test-lib: run EXPENSIVE tests one at a timeKaartic Sivaraam, Nov 27, 2026
  13. Junio C HamanoNov 27, 2026
  14. Kaartic SivaraamNov 28, 2026
  15. 0/2 test-lib: serialize EXPENSIVE tests to avoid OOM in CIKaartic Sivaraam, Nov 28, 2026
  16. 1/2 test-lib: run EXPENSIVE tests one at a timeKaartic Sivaraam, Nov 28, 2026
  17. Junio C HamanoNov 29, 2026
  18. Christian CouderNov 30, 2026
  19. Kaartic SivaraamDec 1, 2026
  20. Christian CouderDec 1, 2026
  21. Kaartic SivaraamDec 1, 2026
  22. Patrick SteinhardtDec 1, 2026
  23. Kaartic SivaraamDec 1, 2026
  24. Patrick SteinhardtDec 1, 2026
  25. Kaartic SivaraamDec 1, 2026
  26. Patrick SteinhardtDec 1, 2026
  27. 2/2 t0000: test taking over and releasing the EXPENSIVE lockKaartic Sivaraam, Nov 28, 2026
  28. Patrick SteinhardtDec 1, 2026
  29. Kaartic SivaraamDec 1, 2026
  30. test-lib: run EXPENSIVE tests one at a timeKaartic Sivaraam, Dec 1, 2026
  31. Patrick SteinhardtDec 3, 2026
  32. Kaartic SivaraamDec 3, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.