From e2a7b890ed5a33dcc990cfd523b47f4781ced3c9 Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Mon, 11 Jul 2022 16:04:53 -0700 Subject: [PATCH 1/2] Remove needless "touch" in scripts.base.utils.dir test This touch happened after teardown of Zeek, so didn't add to the test. --- testing/btest/scripts/base/utils/dir.test | 1 - 1 file changed, 1 deletion(-) diff --git a/testing/btest/scripts/base/utils/dir.test b/testing/btest/scripts/base/utils/dir.test index 6043d54289..7fc9b7389c 100644 --- a/testing/btest/scripts/base/utils/dir.test +++ b/testing/btest/scripts/base/utils/dir.test @@ -5,7 +5,6 @@ # @TEST-EXEC: $SCRIPTS/wait-for-file zeek/next2 10 || (btest-bg-wait -k 1 && false) # @TEST-EXEC: touch testdir/bye # @TEST-EXEC: btest-bg-wait 20 -# @TEST-EXEC: touch testdir/newone # @TEST-EXEC: btest-diff zeek/.stdout @TEST-START-FILE dirtest.zeek From 3d87400f1daab448fba4cd7ef859aa81027f4b96 Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Mon, 11 Jul 2022 16:26:45 -0700 Subject: [PATCH 2/2] Fix race condition in scripts.base.utils.dir test The sequence of - adding a new file - deleting an existing one - waiting for Zeek to notice the addition - re-adding the pre-existing file was prone to a race: it could happen that Zeek's directory observation would see the new file in one round, and by the time the next round happens the removal and re-addition had already happened, thus missing the change and failing the test. This avoids the race by placing the removal of the existing file before the addition of the new one, ensuring that when Zeek notices the addition (and pushes the test to the next round), it has also seen the removal, so the re-addition cannot get lost. --- testing/btest/scripts/base/utils/dir.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/btest/scripts/base/utils/dir.test b/testing/btest/scripts/base/utils/dir.test index 7fc9b7389c..d37fe4a044 100644 --- a/testing/btest/scripts/base/utils/dir.test +++ b/testing/btest/scripts/base/utils/dir.test @@ -1,7 +1,7 @@ # @TEST-EXEC: btest-bg-run zeek zeek -b ../dirtest.zeek # @TEST-EXEC: $SCRIPTS/wait-for-file zeek/next1 10 || (btest-bg-wait -k 1 && false) -# @TEST-EXEC: touch testdir/newone # @TEST-EXEC: rm testdir/bye +# @TEST-EXEC: touch testdir/newone # @TEST-EXEC: $SCRIPTS/wait-for-file zeek/next2 10 || (btest-bg-wait -k 1 && false) # @TEST-EXEC: touch testdir/bye # @TEST-EXEC: btest-bg-wait 20