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

[PATCH v2 11/12] fsmonitor: test updates

From
Eric DeCosta via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 14, 2022, 21:45 UTC
Message-ID
<6682938fff8a3bc7c0c4b08fdfd20effc4b2fc66.1665783945.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1352.v2.git.git.1665783944.gitgitgadget@gmail.com>
From: Eric DeCosta <edecosta@mathworks.com>

t7527-builtin-fsmonitor was leaking fsmonitor--daemon processes in some cases.

Accomodate slight difference in the number of events generated on Linux.

On lower-powered systems, spin a little to give the daemon time to respond to and log filesystem events.

Signed-off-by: Eric DeCosta <edecosta@mathworks.com>
---
 t/t7527-builtin-fsmonitor.sh | 72 +++++++++++++++++++++++++++++-------
 1 file changed, 58 insertions(+), 14 deletions(-)
diff --git a/t/t7527-builtin-fsmonitor.sh b/t/t7527-builtin-fsmonitor.sh
index 1746d30cf6a..d27bd3662a7 100755
--- a/t/t7527-builtin-fsmonitor.sh
+++ b/t/t7527-builtin-fsmonitor.sh
@@ -13,7 +13,7 @@ fi
 stop_daemon_delete_repo () {
 	r=$1 &&
 	test_might_fail git -C $r fsmonitor--daemon stop &&
-	rm -rf $1
+	rm -rf $r
 }
 
 start_daemon () {
@@ -72,6 +72,32 @@ start_daemon () {
 	)
 }
 
+IMPLICIT_TIMEOUT=5
+
+wait_for_update () {
+	func=$1 &&
+	file=$2 &&
+	sz=$(wc -c < "$file") &&
+	last=0 &&
+	$func &&
+	k=0 &&
+	while test "$k" -lt $IMPLICIT_TIMEOUT
+	do
+		nsz=$(wc -c < "$file")
+		if test "$nsz" -gt "$sz"
+		then
+			if test "$last" -eq "$nsz"
+			then
+				return 0
+			fi
+			last=$nsz
+		fi
+		sleep 1
+		k=$(( $k + 1 ))
+	done &&
+	return 0
+}
+
 # Is a Trace2 data event present with the given catetory and key?
 # We do not care what the value is.
 #
@@ -137,7 +163,6 @@ test_expect_success 'implicit daemon start' '
 # machines (where it might take a moment to wake and reschedule the
 # daemon process) to avoid false alarms during test runs.)
 #
-IMPLICIT_TIMEOUT=5
 
 verify_implicit_shutdown () {
 	r=$1 &&
@@ -373,6 +398,10 @@ create_files () {
 	echo 3 >dir2/new
 }
 
+rename_directory () {
+	mv dirtorename dirrenamed
+}
+
 rename_files () {
 	mv rename renamed &&
 	mv dir1/rename dir1/renamed &&
@@ -427,10 +456,12 @@ test_expect_success 'edit some files' '
 
 	start_daemon --tf "$PWD/.git/trace" &&
 
-	edit_files &&
+	wait_for_update edit_files "$PWD/.git/trace" &&
 
 	test-tool fsmonitor-client query --token 0 &&
 
+	test_might_fail git fsmonitor--daemon stop &&
+
 	grep "^event: dir1/modified$"  .git/trace &&
 	grep "^event: dir2/modified$"  .git/trace &&
 	grep "^event: modified$"       .git/trace &&
@@ -442,10 +473,12 @@ test_expect_success 'create some files' '
 
 	start_daemon --tf "$PWD/.git/trace" &&
 
-	create_files &&
+	wait_for_update create_files "$PWD/.git/trace" &&
 
 	test-tool fsmonitor-client query --token 0 &&
 
+	test_might_fail git fsmonitor--daemon stop &&
+
 	grep "^event: dir1/new$" .git/trace &&
 	grep "^event: dir2/new$" .git/trace &&
 	grep "^event: new$"      .git/trace
@@ -456,10 +489,12 @@ test_expect_success 'delete some files' '
 
 	start_daemon --tf "$PWD/.git/trace" &&
 
-	delete_files &&
+	wait_for_update delete_files "$PWD/.git/trace" &&
 
 	test-tool fsmonitor-client query --token 0 &&
 
+	test_might_fail git fsmonitor--daemon stop &&
+
 	grep "^event: dir1/delete$" .git/trace &&
 	grep "^event: dir2/delete$" .git/trace &&
 	grep "^event: delete$"      .git/trace
@@ -470,10 +505,12 @@ test_expect_success 'rename some files' '
 
 	start_daemon --tf "$PWD/.git/trace" &&
 
-	rename_files &&
+	wait_for_update rename_files "$PWD/.git/trace" &&
 
 	test-tool fsmonitor-client query --token 0 &&
 
+	test_might_fail git fsmonitor--daemon stop &&
+
 	grep "^event: dir1/rename$"  .git/trace &&
 	grep "^event: dir2/rename$"  .git/trace &&
 	grep "^event: rename$"       .git/trace &&
@@ -487,10 +524,12 @@ test_expect_success 'rename directory' '
 
 	start_daemon --tf "$PWD/.git/trace" &&
 
-	mv dirtorename dirrenamed &&
+	wait_for_update rename_directory "$PWD/.git/trace" &&
 
 	test-tool fsmonitor-client query --token 0 &&
 
+	test_might_fail git fsmonitor--daemon stop &&
+
 	grep "^event: dirtorename/*$" .git/trace &&
 	grep "^event: dirrenamed/*$"  .git/trace
 '
@@ -500,10 +539,12 @@ test_expect_success 'file changes to directory' '
 
 	start_daemon --tf "$PWD/.git/trace" &&
 
-	file_to_directory &&
+	wait_for_update file_to_directory "$PWD/.git/trace" &&
 
 	test-tool fsmonitor-client query --token 0 &&
 
+	test_might_fail git fsmonitor--daemon stop &&
+
 	grep "^event: delete$"     .git/trace &&
 	grep "^event: delete/new$" .git/trace
 '
@@ -513,10 +554,12 @@ test_expect_success 'directory changes to a file' '
 
 	start_daemon --tf "$PWD/.git/trace" &&
 
-	directory_to_file &&
+	wait_for_update directory_to_file "$PWD/.git/trace" &&
 
 	test-tool fsmonitor-client query --token 0 &&
 
+	test_might_fail git fsmonitor--daemon stop &&
+
 	grep "^event: dir1$" .git/trace
 '
 
@@ -561,7 +604,7 @@ test_expect_success 'flush cached data' '
 	test-tool -C test_flush fsmonitor-client query --token "builtin:test_00000002:0" >actual_2 &&
 	nul_to_q <actual_2 >actual_q2 &&
 
-	grep "^builtin:test_00000002:0Q$" actual_q2 &&
+	grep "^builtin:test_00000002:[0-1]Q$" actual_q2 &&
 
 	>test_flush/file_3 &&
 
@@ -732,7 +775,8 @@ u_values="$u1 $u2"
 for u in $u_values
 do
 	test_expect_success "unicode in repo root path: $u" '
-		test_when_finished "stop_daemon_delete_repo $u" &&
+		test_when_finished \
+		"stop_daemon_delete_repo `echo "$u" | sed 's:x:\\\\\\\\\\\\\\x:g'`" &&
 
 		git init "$u" &&
 		echo 1 >"$u"/file1 &&
@@ -814,8 +858,7 @@ my_match_and_clean () {
 }
 
 test_expect_success 'submodule always visited' '
-	test_when_finished "git -C super fsmonitor--daemon stop; \
-			    rm -rf super; \
+	test_when_finished "rm -rf super; \
 			    rm -rf sub" &&
 
 	create_super super &&
@@ -883,7 +926,8 @@ have_t2_error_event () {
 }
 
 test_expect_success "stray submodule super-prefix warning" '
-	test_when_finished "rm -rf super; \
+	test_when_finished "git -C super/dir_1/dir_2/sub fsmonitor--daemon stop; \
+			    rm -rf super; \
 			    rm -rf sub;   \
 			    rm super-sub.trace" &&
 
-- 
gitgitgadget
Previous: Eric DeCosta via GitGitGadgetNext: Eric DeCosta via GitGitGadget
Message 37 of 89 in “fsmonitor: Implement fsmonitor for Linux”
  1. 00/12 fsmonitor: Implement fsmonitor for LinuxEric DeCosta via GitGitGadget, Oct 9, 2022
  2. 02/12 fsmonitor: relocate socket file if .git directory is remoteEric DeCosta via GitGitGadget, Oct 9, 2022
  3. 04/12 fsmonitor: deal with synthetic firmlinks on macOSEric DeCosta via GitGitGadget, Oct 9, 2022
  4. 03/12 fsmonitor: avoid socket location check if using hookEric DeCosta via GitGitGadget, Oct 9, 2022
  5. 05/12 fsmonitor: check for compatability before communicating with fsmonitorEric DeCosta via GitGitGadget, Oct 9, 2022
  6. 01/12 fsmonitor: refactor filesystem checks to common interfaceEric DeCosta via GitGitGadget, Oct 9, 2022
  7. Ævar Arnfjörð BjarmasonOct 18, 2022
  8. 06/12 fsmonitor: add documentation for allowRemote and socketDir optionsEric DeCosta via GitGitGadget, Oct 9, 2022
  9. 07/12 fsmonitor: prepare to share code between Mac OS and LinuxEric DeCosta via GitGitGadget, Oct 9, 2022
  10. Junio C HamanoOct 9, 2022
  11. Jeff HostetlerOct 10, 2022
  12. 08/12 fsmonitor: determine if filesystem is local or remoteEric DeCosta via GitGitGadget, Oct 9, 2022
  13. Ævar Arnfjörð BjarmasonOct 10, 2022
  14. Eric DeCostaOct 14, 2022
  15. 09/12 fsmonitor: implement filesystem change listener for LinuxEric DeCosta via GitGitGadget, Oct 9, 2022
  16. 10/12 fsmonitor: enable fsmonitor for LinuxEric DeCosta via GitGitGadget, Oct 9, 2022
  17. 11/12 fsmonitor: test updatesEric DeCosta via GitGitGadget, Oct 9, 2022
  18. Ævar Arnfjörð BjarmasonOct 18, 2022
  19. 12/12 fsmonitor: update doc for LinuxEric DeCosta via GitGitGadget, Oct 9, 2022
  20. Ævar Arnfjörð BjarmasonOct 18, 2022
  21. Junio C HamanoOct 9, 2022
  22. Eric SunshineOct 10, 2022
  23. Junio C HamanoOct 10, 2022
  24. 00/12 fsmonitor: Implement fsmonitor for LinuxEric DeCosta via GitGitGadget, Oct 14, 2022
  25. 01/12 fsmonitor: refactor filesystem checks to common interfaceEric DeCosta via GitGitGadget, Oct 14, 2022
  26. 02/12 fsmonitor: relocate socket file if .git directory is remoteEric DeCosta via GitGitGadget, Oct 14, 2022
  27. Ævar Arnfjörð BjarmasonOct 18, 2022
  28. 05/12 fsmonitor: check for compatability before communicating with fsmonitorEric DeCosta via GitGitGadget, Oct 14, 2022
  29. 03/12 fsmonitor: avoid socket location check if using hookEric DeCosta via GitGitGadget, Oct 14, 2022
  30. 04/12 fsmonitor: deal with synthetic firmlinks on macOSEric DeCosta via GitGitGadget, Oct 14, 2022
  31. 06/12 fsmonitor: add documentation for allowRemote and socketDir optionsEric DeCosta via GitGitGadget, Oct 14, 2022
  32. 07/12 fsmonitor: prepare to share code between Mac OS and LinuxEric DeCosta via GitGitGadget, Oct 14, 2022
  33. Junio C HamanoOct 14, 2022
  34. Eric DeCostaOct 17, 2022
  35. Junio C HamanoOct 18, 2022
  36. 10/12 fsmonitor: enable fsmonitor for LinuxEric DeCosta via GitGitGadget, Oct 14, 2022
  37. 11/12 fsmonitor: test updatesEric DeCosta via GitGitGadget, Oct 14, 2022
  38. 09/12 fsmonitor: implement filesystem change listener for LinuxEric DeCosta via GitGitGadget, Oct 14, 2022
  39. Ævar Arnfjörð BjarmasonOct 18, 2022
  40. 08/12 fsmonitor: determine if filesystem is local or remoteEric DeCosta via GitGitGadget, Oct 14, 2022
  41. 12/12 fsmonitor: update doc for LinuxEric DeCosta via GitGitGadget, Oct 14, 2022
  42. Junio C HamanoOct 14, 2022
  43. Eric DeCostaOct 17, 2022
  44. Junio C HamanoOct 17, 2022
  45. Johannes SchindelinOct 18, 2022
  46. Glen ChooOct 17, 2022
  47. Junio C HamanoOct 18, 2022
  48. Glen ChooOct 18, 2022
  49. Junio C HamanoOct 18, 2022
  50. Ævar Arnfjörð BjarmasonOct 19, 2022
  51. Eric SunshineOct 19, 2022
  52. Junio C HamanoOct 19, 2022
  53. Ævar Arnfjörð BjarmasonOct 19, 2022
  54. Eric SunshineOct 19, 2022
  55. Ævar Arnfjörð BjarmasonOct 19, 2022
  56. Junio C HamanoOct 19, 2022
  57. Junio C HamanoOct 20, 2022
  58. Eric SunshineOct 20, 2022
  59. Junio C HamanoOct 20, 2022
  60. Eric SunshineOct 20, 2022
  61. Junio C HamanoOct 20, 2022
  62. Junio C HamanoOct 20, 2022
  63. 0/6 fsmonitor: Implement fsmonitor for LinuxEric DeCosta via GitGitGadget, Nov 16, 2022
  64. 1/6 fsmonitor: prepare to share code between Mac OS and LinuxEric DeCosta via GitGitGadget, Nov 16, 2022
  65. 2/6 fsmonitor: determine if filesystem is local or remoteEric DeCosta via GitGitGadget, Nov 16, 2022
  66. 3/6 fsmonitor: implement filesystem change listener for LinuxEric DeCosta via GitGitGadget, Nov 16, 2022
  67. 4/6 fsmonitor: enable fsmonitor for LinuxEric DeCosta via GitGitGadget, Nov 16, 2022
  68. 5/6 fsmonitor: test updatesEric DeCosta via GitGitGadget, Nov 16, 2022
  69. 6/6 fsmonitor: update doc for LinuxEric DeCosta via GitGitGadget, Nov 16, 2022
  70. Taylor BlauNov 16, 2022
  71. 0/6 fsmonitor: Implement fsmonitor for LinuxEric DeCosta via GitGitGadget, Nov 23, 2022
  72. 1/6 fsmonitor: prepare to share code between Mac OS and LinuxEric DeCosta via GitGitGadget, Nov 23, 2022
  73. 2/6 fsmonitor: determine if filesystem is local or remoteEric DeCosta via GitGitGadget, Nov 23, 2022
  74. Junio C HamanoNov 25, 2022
  75. Ævar Arnfjörð BjarmasonDec 12, 2022
  76. 3/6 fsmonitor: implement filesystem change listener for LinuxEric DeCosta via GitGitGadget, Nov 23, 2022
  77. Ævar Arnfjörð BjarmasonDec 12, 2022
  78. 4/6 fsmonitor: enable fsmonitor for LinuxEric DeCosta via GitGitGadget, Nov 23, 2022
  79. 5/6 fsmonitor: test updatesEric DeCosta via GitGitGadget, Nov 23, 2022
  80. 6/6 fsmonitor: update doc for LinuxEric DeCosta via GitGitGadget, Nov 23, 2022
  81. 0/6 fsmonitor: Implement fsmonitor for LinuxEric DeCosta via GitGitGadget, Dec 12, 2022
  82. 1/6 fsmonitor: prepare to share code between Mac OS and LinuxEric DeCosta via GitGitGadget, Dec 12, 2022
  83. 2/6 fsmonitor: determine if filesystem is local or remoteEric DeCosta via GitGitGadget, Dec 12, 2022
  84. 4/6 fsmonitor: enable fsmonitor for LinuxEric DeCosta via GitGitGadget, Dec 12, 2022
  85. 3/6 fsmonitor: implement filesystem change listener for LinuxEric DeCosta via GitGitGadget, Dec 12, 2022
  86. 5/6 fsmonitor: test updatesEric DeCosta via GitGitGadget, Dec 12, 2022
  87. 6/6 fsmonitor: update doc for LinuxEric DeCosta via GitGitGadget, Dec 12, 2022
  88. Junio C HamanoApr 12, 2023
  89. Ævar Arnfjörð BjarmasonOct 18, 2022

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.