diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
commit | a90a5cba08fdf6c0ceb95101c275108a152a3aed (patch) | |
tree | 532507288f3defd7f4dcf1af49698bcb76034855 /tools/profiler/tests | |
parent | Adding debian version 126.0.1-1. (diff) | |
download | firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/profiler/tests')
-rw-r--r-- | tools/profiler/tests/gtest/moz.build | 3 | ||||
-rw-r--r-- | tools/profiler/tests/xpcshell/test_feature_posix_signals.js | 85 | ||||
-rw-r--r-- | tools/profiler/tests/xpcshell/xpcshell.toml | 6 |
3 files changed, 63 insertions, 31 deletions
diff --git a/tools/profiler/tests/gtest/moz.build b/tools/profiler/tests/gtest/moz.build index e1c3994621..ea5ca1f228 100644 --- a/tools/profiler/tests/gtest/moz.build +++ b/tools/profiler/tests/gtest/moz.build @@ -30,7 +30,8 @@ LOCAL_INCLUDES += [ "/tools/profiler/lul", ] -if CONFIG["OS_TARGET"] != "Android": +# Bug 1885381 - Hangs/timeouts under TSAN +if CONFIG["OS_TARGET"] != "Android" and not CONFIG["MOZ_TSAN"]: UNIFIED_SOURCES += [ "GeckoProfiler.cpp", "ThreadProfileTest.cpp", diff --git a/tools/profiler/tests/xpcshell/test_feature_posix_signals.js b/tools/profiler/tests/xpcshell/test_feature_posix_signals.js index 28fbf890e8..d4b77d6550 100644 --- a/tools/profiler/tests/xpcshell/test_feature_posix_signals.js +++ b/tools/profiler/tests/xpcshell/test_feature_posix_signals.js @@ -5,7 +5,7 @@ ChromeUtils.defineESModuleGetters(this, { Downloads: "resource://gre/modules/Downloads.sys.mjs", FileUtils: "resource://gre/modules/FileUtils.sys.mjs", - BrowserTestUtils: "resource://testing-common/BrowserTestUtils.sys.mjs", + TestUtils: "resource://testing-common/TestUtils.sys.mjs", }); const { ctypes } = ChromeUtils.importESModule( @@ -68,23 +68,6 @@ function raiseSignal(pid, sig) { return { ok: true }; } -// We would like to use the following to wait for a stop signal to actually be -// handled: -// await Services.profiler.waitOnePeriodicSampling(); -// However, as we are trying to shut down the profiler using the sampler -// thread, this can cause complications between the callback waiting for the -// sampling to be over, and the sampler thread actually finishing. -// Instead, we use the BrowserTestUtils.waitForCondition to wait until the -// profiler is no longer active. -async function waitUntilProfilerStopped(interval = 1000, maxTries = 100) { - await BrowserTestUtils.waitForCondition( - () => !Services.profiler.IsActive(), - "the profiler should be inactive", - interval, - maxTries - ); -} - async function cleanupAfterTest() { // We need to cleanup written profiles after a test // Get the system downloads directory, and use it to build a profile file @@ -112,10 +95,46 @@ async function cleanupAfterTest() { // may cause a mismatch if we test on on, say, a gnu hurd kernel, or on a // linux kernel running on sparc, but the feature will not break - only // the testing. -// const SIGUSR1 = Services.appinfo.OS === "Darwin" ? 30 : 10; +const SIGUSR1 = Services.appinfo.OS === "Darwin" ? 30 : 10; const SIGUSR2 = Services.appinfo.OS === "Darwin" ? 31 : 12; add_task(async () => { + info("Test that starting the profiler with a posix signal works."); + + Assert.ok( + !Services.profiler.IsActive(), + "The profiler should not begin the test active." + ); + + // Get the process ID + let pid = Services.appinfo.processID; + + // Set up an observer to watch for the profiler starting + let startPromise = TestUtils.topicObserved("profiler-started"); + + // Try and start the profiler using a signal. + let result = raiseSignal(pid, SIGUSR1); + Assert.ok(result, "Raising a signal should succeed"); + + // Wait for the profiler to stop + Assert.ok(await startPromise, "The profiler should start"); + + // Wait until the profiler is active + Assert.ok(Services.profiler.IsActive(), "The profiler should now be active."); + + // Let the profiler sample at least once + await Services.profiler.waitOnePeriodicSampling(); + info("Waiting a periodic sampling completed"); + + // Stop the profiler + await Services.profiler.StopProfiler(); + Assert.ok( + !Services.profiler.IsActive(), + "The profiler should now be inactive." + ); +}); + +add_task(async () => { info("Test that stopping the profiler with a posix signal works."); registerCleanupFunction(cleanupAfterTest); @@ -136,13 +155,20 @@ add_task(async () => { // Get the process ID let pid = Services.appinfo.processID; + // Set up an observer to watch for the profiler stopping + let stopPromise = TestUtils.topicObserved("profiler-stopped"); + // Try and stop the profiler using a signal. let result = raiseSignal(pid, SIGUSR2); Assert.ok(result, "Raising a SIGUSR2 signal should succeed."); - await waitUntilProfilerStopped(); + // Wait for the profiler to stop + Assert.ok(await stopPromise, "The profiler should stop"); - do_test_finished(); + Assert.ok( + !Services.profiler.IsActive(), + "The profiler should now be inactive." + ); }); add_task(async () => { @@ -174,21 +200,24 @@ add_task(async () => { await Services.profiler.StartProfiler(entries, interval, threads, features); Assert.ok(Services.profiler.IsActive(), "The profiler should now be active."); + // Set up an observer to watch for the profiler stopping + let stopPromise = TestUtils.topicObserved("profiler-stopped"); + // Try and stop the profiler using a signal. let result = raiseSignal(pid, SIGUSR2); Assert.ok(result, "Raising a SIGUSR2 signal should succeed."); - // Wait for the file to exist - await BrowserTestUtils.waitForCondition( - async () => await IOUtils.exists(profile.path), - "Waiting for a profile file to be written to disk." + // Wait for the profiler to stop + Assert.ok(await stopPromise, "The profiler should stop"); + + // Now that it's stopped, make sure that we have a profile file + Assert.ok( + await IOUtils.exists(profile.path), + "A profile file should be written to disk." ); - await waitUntilProfilerStopped(); Assert.ok( !Services.profiler.IsActive(), "The profiler should now be inactive." ); - - do_test_finished(); }); diff --git a/tools/profiler/tests/xpcshell/xpcshell.toml b/tools/profiler/tests/xpcshell/xpcshell.toml index 2cde39d09f..8e58e1ff08 100644 --- a/tools/profiler/tests/xpcshell/xpcshell.toml +++ b/tools/profiler/tests/xpcshell/xpcshell.toml @@ -49,8 +49,10 @@ skip-if = [ ["test_feature_posix_signals.js"] skip-if = [ - "ccov", - "os == 'win'", + "tsan", # We have intermittent timeout issues in TSan, see Bug 1889828 + "ccov", # The signals for the profiler conflict with the ccov signals + "os == 'win'", # Not yet supported on windows + "os == 'android'", # Not yet supported on android ] # Native stackwalking is somewhat unreliable depending on the platform. |