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

[PATCH] test: accept death by SIGPIPE as a valid failure mode

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 30, 2015, 21:22 UTC
Message-ID
<xmqqr3kcjbll.fsf_-_@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqvb9ojcmf.fsf@gitster.mtv.corp.google.com>

On a local host, the object/history transport code often talks over pipe with the other side. The other side may notice some (expected) failure, send the error message either to our process or to the standard error and hung up. In such codepaths, if timing were not unfortunate, our side would receive the report of (expected) failure from the other side over the pipe and die(). Otherwise, our side may still be trying to talk to it and would die with a SIGPIPE.

This was observed as an intermittent breakage in t5516 by a few people.

In the real-life scenario, either mode of death exits with a non-zero status, and the user would learn that the command failed. The test_must_fail helper should also know that dying with SIGPIPE is one of the valid failure modes when we are expecting the tested operation to notice problem and fail.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * This time with a real commit log message.  As the goal is to
   treat death-by-sigpipe just like a call to die(), this version
   silently lets the test pass instead of giving a message to the
   standard error stream.
 t/test-lib-functions.sh | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 8f8858a..4f40ffe 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -556,6 +556,9 @@ test_must_fail () {
 	if test $exit_code = 0; then
 		echo >&2 "test_must_fail: command succeeded: $*"
 		return 1
+	elif test $exit_code -eq 141; then
+		# died with sigpipe
+		return 0
 	elif test $exit_code -gt 129 && test $exit_code -le 192; then
 		echo >&2 "test_must_fail: died by signal: $*"
 		return 1
-- 
2.6.2-456-gc12a6fe
Previous: Junio C HamanoNext: Jeff King
Message 6 of 9 in “[RFC] t5516 "75 - deny fetch unreachable SHA1, allowtipsha1inwant=true" flaky?”
  1. Lars SchneiderOct 24, 2015
  2. Fredrik MedleyOct 25, 2015
  3. Lars SchneiderOct 25, 2015
  4. Junio C HamanoOct 25, 2015
  5. Junio C HamanoOct 30, 2015
  6. test: accept death by SIGPIPE as a valid failure modeJunio C Hamano, Oct 30, 2015
  7. Jeff KingNov 5, 2015
  8. Lars SchneiderNov 5, 2015
  9. Junio C HamanoNov 5, 2015

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.