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

Re: [PATCH 4/6] test-lib: simplify leak-log checking

From
Jeff King <peff@peff.net>
Date
Jan 3, 2025, 20:24 UTC
Message-ID
<20250103202410.GC3212696@coredump.intra.peff.net>
In-Reply-To
<Z3fSmSYoWs-a6afW@pks.im>
On Fri, Jan 03, 2025 at 01:05:45PM +0100, Patrick Steinhardt wrote:
Show 19 quoted lines
> On Wed, Jan 01, 2025 at 03:17:21PM -0500, Jeff King wrote:
> > @@ -1181,8 +1170,14 @@ test_atexit_handler () {
> >  }
> >  
> >  check_test_results_san_file_empty_ () {
> > -	test -z "$TEST_RESULTS_SAN_FILE" ||
> > -	test "$(nr_san_dir_leaks_)" = 0
> > +	test -z "$TEST_RESULTS_SAN_FILE" && return 0
> > +
> > +	# stderr piped to /dev/null because the directory may have
> > +	# been "rmdir"'d already.
> > +	! find "$TEST_RESULTS_SAN_DIR" \
> > +		-type f \
> > +		-name "$TEST_RESULTS_SAN_FILE_PFX.*" 2>/dev/null |
> > +	xargs grep -qv "Unable to get registers from thread"
> 
> Can't we use `-exec grep -qv "Unable to get registers from thread" {}
> \+` instead of using xargs? Or is that unportable? Might make it a bit
> easier to reason about the `!` in the presence of a pipe.

I don't think that saves us from negating, though. The "grep" will tell us if it matched any "real" lines, but we want to report that we found no real lines.

Plus I don't think "find" propagates the exit code from -exec anyway. I think you can check the exit status with more find logic, so you'd then use a conditional -print for each file like:

  find ... \
    -exec grep -qv "Unable to get registers from thread" \{} \; \
    -print

and you have to check whether the output is empty. The easiest way to do that is with another grep! Which also needs negated. ;)

I think if we really want to drop the negation, we'd be best to flip the function's return, like:

  have_leaks() {
	# not leak-checking
	test -z "$TEST_RESULTS_SAN_FILE" && return 1
	find "$TEST_RESULTS_SAN_DIR" \
		-type f \
		-name "$TEST_RESULTS_SAN_FILE_PFX.*" 2>/dev/null |
	xargs grep ^DEDUP_TOKEN |
	grep -qv sanitizer::GetThreadStackTopAndBottom
  }

And then you could switch the initial "grep" to -exec if you want, but there's no negation to get rid of, so it is only a preference of -exec versus xargs.

-Peff
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 13 of 37 in “What's cooking in git.git (Dec 2024, #11; Mon, 30)”
  1. Junio C HamanoDec 30, 2024
  2. René ScharfeDec 31, 2024
  3. Patrick SteinhardtJan 3, 2025
  4. a less-invasive racy-leak fix, was Re: What's cooking in git.git (Dec 2024, #11; Mon, 30)Jeff King, Jan 1, 2025
  5. 0/6 a less-invasive racy-leak fixJeff King, Jan 1, 2025
  6. 1/6 test-lib: use individual lsan dir for --stress runsJeff King, Jan 1, 2025
  7. 2/6 Revert "index-pack: spawn threads atomically"Jeff King, Jan 1, 2025
  8. 3/6 test-lib: rely on logs to detect leaksJeff King, Jan 1, 2025
  9. Patrick SteinhardtJan 3, 2025
  10. Jeff KingJan 3, 2025
  11. 4/6 test-lib: simplify leak-log checkingJeff King, Jan 1, 2025
  12. Patrick SteinhardtJan 3, 2025
  13. Jeff KingJan 3, 2025
  14. Patrick SteinhardtJan 6, 2025
  15. Jeff KingJan 7, 2025
  16. 5/6 test-lib: check leak logs for presence of DEDUP_TOKENJeff King, Jan 1, 2025
  17. 6/6 test-lib: ignore leaks in the sanitizer's thread codeJeff King, Jan 1, 2025
  18. Patrick SteinhardtJan 3, 2025
  19. Jeff KingJan 3, 2025
  20. Patrick SteinhardtJan 6, 2025
  21. 0/3 lsan test-lib readabilityJeff King, Jan 7, 2025
  22. 1/3 test-lib: invert return value of check_test_results_san_file_emptyJeff King, Jan 7, 2025
  23. 2/3 test-lib: simplify lsan results checkJeff King, Jan 7, 2025
  24. Patrick SteinhardtJan 7, 2025
  25. Jeff KingJan 9, 2025
  26. Patrick SteinhardtJan 9, 2025
  27. Junio C HamanoJan 7, 2025
  28. Jeff KingJan 9, 2025
  29. 3/3 test-lib: add a few comments to LSan log checkingJeff King, Jan 7, 2025
  30. Patrick SteinhardtJan 7, 2025
  31. Junio C HamanoJan 2, 2025
  32. Jeff KingJan 2, 2025
  33. Chris TorekJan 2, 2025
  34. Junio C HamanoJan 2, 2025
  35. Jeff KingJan 2, 2025
  36. Junio C HamanoJan 2, 2025
  37. Jeff KingJan 2, 2025

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.