Skip to contentSkip to conversation

test: Improve sync mechanism in tst.multiple.sh

PATCH New [email protected] 1 participant 1 message Dec 11, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test: Improve sync mechanism in tst.multiple.sh

From: Eugene Loh <[email protected]>

In this test, a USDT process is launched. Subsequently, dtrace is started. To give dtrace a chance to enable the USDT probes, the USDT process waits a few seconds. On some systems and when the amount of work dtrace does upon startup is high, "a few seconds" may not be enough, causing the test to miss expected probes.

Have the USDT process loop on an is-enabled probe; this is a more resilient sync mechanism between it and dtrace.

That said, dtrace does not enable all probes in one instant, and it makes no promises in what order probes will be started. So, we still leave a (shorter) sleep() in the target process.

Arguably, the test could be simplified by launching the USDT process with "dtrace -c". In this patch, we choose instead to retain the overall character of the existing test.

---
 test/unittest/usdt/tst.multiple.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
test/unittest/usdt/tst.multiple.sh +7 -2
index 1fd30dc6f..440a7d7ba 100755
@@ -1,7 +1,7 @@
 #!/bin/bash
 #
 # Oracle Linux DTrace.
-# Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved.
 # Licensed under the Universal Permissive License v 1.0 as shown at
 # http://oss.oracle.com/licenses/upl.
 #
@@ -41,7 +41,12 @@ cat > test.c <<EOF
 int
 main(int argc, char **argv)
 {
-	sleep(5); /* Until proper synchronization is implemented. */
+	/* Wait for probes to be enabled. */
+	while (! TEST_PROV_GO_ENABLED());
+
+	/* Allow a generous delay. (Not all probes are enabled instantaneously.) */
+	sleep(2);
+
 	TEST_PROV_GO();
 	TEST_PROV_GO();
 	TEST_PROV_GO();
Signature · 1 line
2.43.5