Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Unified Diff: test/cctest/test-log.cc

Issue 159406: Fix issue 410: test-log/ProfLazyMode flakinness under Linux. (Closed)
Patch Set: Renamed variabled to match V8 naming convention Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-log.cc
diff --git a/test/cctest/test-log.cc b/test/cctest/test-log.cc
index f3f7efc710b99091c6e1e268acfc12ff09477c5f..ba7c2d8e9d9ae250aa365d34a0e3368f0773f0a3 100644
--- a/test/cctest/test-log.cc
+++ b/test/cctest/test-log.cc
@@ -144,6 +144,26 @@ class LoggerTestHelper : public AllStatic {
using v8::internal::LoggerTestHelper;
+// Under Linux, we need to check if signals were delivered to avoid false
+// positives. Under other platforms profiling is done via a high-priority
+// thread, so this case never happen.
+static bool was_sigprof_received = true;
Søren Thygesen Gjesse 2009/07/28 08:12:37 Maybe move this down to 'struct sigaction old_sigp
Mikhail Naganov 2009/07/28 08:34:15 This will add another 'ifdef' branch around lines
+#ifdef __linux__
+
+#include <signal.h>
+#include <unistd.h>
+
+struct sigaction old_sigprof_handler;
+
+static void SigProfSignalHandler(int signal, siginfo_t* info, void* context) {
+ if (signal != SIGPROF) return;
+ was_sigprof_received = true;
+ old_sigprof_handler.sa_sigaction(signal, info, context);
+}
+
+#endif // __linux__
+
+
static int CheckThatProfilerWorks(int log_pos) {
Logger::ResumeProfiler();
CHECK(LoggerTestHelper::IsSamplerActive());
@@ -160,6 +180,18 @@ static int CheckThatProfilerWorks(int log_pos) {
const char* code_creation = "\ncode-creation,"; // eq. to /^code-creation,/
CHECK_NE(NULL, strstr(buffer.start(), code_creation));
+#ifdef __linux__
+ // Intercept SIGPROF handler to make sure that the test process
+ // had received it. Under load, system can defer it causing test failure.
+ // It is important to execute this after 'ResumeProfiler'.
+ was_sigprof_received = false;
+ struct sigaction sa;
+ sa.sa_sigaction = SigProfSignalHandler;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_SIGINFO;
+ CHECK_EQ(0, sigaction(SIGPROF, &sa, &old_sigprof_handler));
+#endif // __linux__
+
// Force compiler to generate new code by parametrizing source.
EmbeddedVector<char, 100> script_src;
i::OS::SNPrintF(script_src,
@@ -170,6 +202,8 @@ static int CheckThatProfilerWorks(int log_pos) {
const double end_time = i::OS::TimeCurrentMillis() + 200;
while (i::OS::TimeCurrentMillis() < end_time) {
CompileAndRunScript(script_src.start());
+ // Yield CPU to give Profiler thread a chance to process ticks.
+ i::OS::Sleep(1);
}
Logger::PauseProfiler();
@@ -189,7 +223,8 @@ static int CheckThatProfilerWorks(int log_pos) {
buffer[log_size] = '\0';
const char* tick = "\ntick,";
CHECK_NE(NULL, strstr(buffer.start(), code_creation));
- CHECK_NE(NULL, strstr(buffer.start(), tick));
+ const bool ticks_found = strstr(buffer.start(), tick) != NULL;
+ CHECK_EQ(was_sigprof_received, ticks_found);
return log_pos;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698