mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 06:20:13 +00:00
[VM logging] Fix nesting of log blocker (second attempt).
Fix expectations of log blocker test, i.e. no swapping occurs anymore. R=rmacnak@google.com Review-Url: https://codereview.chromium.org/2999833002 .
This commit is contained in:
parent
6f81034a73
commit
407f1f8ca1
3 changed files with 15 additions and 7 deletions
|
@ -149,7 +149,7 @@ void Log::EnableManualFlush() {
|
|||
manual_flush_++;
|
||||
}
|
||||
|
||||
void Log::DisableManualFlush() {
|
||||
void Log::DisableManualFlush(const intptr_t cursor) {
|
||||
if (this == NoOpLog()) {
|
||||
return;
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ void Log::DisableManualFlush() {
|
|||
manual_flush_--;
|
||||
ASSERT(manual_flush_ >= 0);
|
||||
if (manual_flush_ == 0) {
|
||||
Flush();
|
||||
Flush(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,8 +166,7 @@ void LogBlock::Initialize() {
|
|||
}
|
||||
|
||||
LogBlock::~LogBlock() {
|
||||
log_->Flush(cursor_);
|
||||
log_->DisableManualFlush();
|
||||
log_->DisableManualFlush(cursor_);
|
||||
}
|
||||
|
||||
} // namespace dart
|
||||
|
|
|
@ -52,7 +52,7 @@ class Log {
|
|||
private:
|
||||
void TerminateString();
|
||||
void EnableManualFlush();
|
||||
void DisableManualFlush();
|
||||
void DisableManualFlush(const intptr_t cursor);
|
||||
|
||||
// Returns false if we should drop log messages related to 'isolate'.
|
||||
static bool ShouldLogForIsolate(const Isolate* isolate);
|
||||
|
|
|
@ -36,6 +36,9 @@ static void TestPrinter(const char* format, ...) {
|
|||
test_output_ = NULL;
|
||||
}
|
||||
test_output_ = buffer;
|
||||
|
||||
// Also print to stdout to see the overall result.
|
||||
OS::Print("%s", test_output_);
|
||||
}
|
||||
|
||||
class LogTestHelper : public AllStatic {
|
||||
|
@ -92,9 +95,15 @@ TEST_CASE(Log_Block) {
|
|||
log->Print("BANANA");
|
||||
EXPECT_EQ(reinterpret_cast<const char*>(NULL), test_output_);
|
||||
}
|
||||
EXPECT_STREQ("BANANA", test_output_);
|
||||
EXPECT_EQ(reinterpret_cast<const char*>(NULL), test_output_);
|
||||
{
|
||||
LogBlock ba(thread, log);
|
||||
log->Print("PEAR");
|
||||
EXPECT_EQ(reinterpret_cast<const char*>(NULL), test_output_);
|
||||
}
|
||||
EXPECT_EQ(reinterpret_cast<const char*>(NULL), test_output_);
|
||||
}
|
||||
EXPECT_STREQ("APPLE", test_output_);
|
||||
EXPECT_STREQ("APPLEBANANAPEAR", test_output_);
|
||||
delete log;
|
||||
LogTestHelper::FreeTestOutput();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue