| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Tests of logging functions from log.h | 3 // Tests of logging functions from log.h |
| 4 | 4 |
| 5 #ifdef ENABLE_LOGGING_AND_PROFILING | 5 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 6 | 6 |
| 7 #ifdef __linux__ | 7 #ifdef __linux__ |
| 8 #include <math.h> | 8 #include <math.h> |
| 9 #include <pthread.h> | 9 #include <pthread.h> |
| 10 #include <signal.h> | 10 #include <signal.h> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 using v8::internal::EmbeddedVector; | 22 using v8::internal::EmbeddedVector; |
| 23 using v8::internal::Logger; | 23 using v8::internal::Logger; |
| 24 using v8::internal::StrLength; | 24 using v8::internal::StrLength; |
| 25 | 25 |
| 26 namespace i = v8::internal; | 26 namespace i = v8::internal; |
| 27 | 27 |
| 28 static void SetUp() { | 28 static void SetUp() { |
| 29 // Log to memory buffer. | 29 // Log to memory buffer. |
| 30 i::FLAG_logfile = "*"; | 30 i::FLAG_logfile = "*"; |
| 31 i::FLAG_log = true; | 31 i::FLAG_log = true; |
| 32 ISOLATE->InitializeLoggingAndCounters(); |
| 32 LOGGER->Setup(); | 33 LOGGER->Setup(); |
| 33 } | 34 } |
| 34 | 35 |
| 35 static void TearDown() { | 36 static void TearDown() { |
| 36 LOGGER->TearDown(); | 37 LOGGER->TearDown(); |
| 37 } | 38 } |
| 38 | 39 |
| 39 | 40 |
| 40 TEST(EmptyLog) { | 41 TEST(EmptyLog) { |
| 41 SetUp(); | 42 SetUp(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 CHECK_EQ(0, LOGGER->GetLogLines(10 * 1024 * 1024, buffer.start(), 1)); | 114 CHECK_EQ(0, LOGGER->GetLogLines(10 * 1024 * 1024, buffer.start(), 1)); |
| 114 CHECK_EQ(0, GetLogLines(10 * 1024 * 1024, &buffer)); | 115 CHECK_EQ(0, GetLogLines(10 * 1024 * 1024, &buffer)); |
| 115 TearDown(); | 116 TearDown(); |
| 116 } | 117 } |
| 117 | 118 |
| 118 | 119 |
| 119 TEST(MemoryLoggingTurnedOff) { | 120 TEST(MemoryLoggingTurnedOff) { |
| 120 // Log to stdout | 121 // Log to stdout |
| 121 i::FLAG_logfile = "-"; | 122 i::FLAG_logfile = "-"; |
| 122 i::FLAG_log = true; | 123 i::FLAG_log = true; |
| 124 ISOLATE->InitializeLoggingAndCounters(); |
| 123 LOGGER->Setup(); | 125 LOGGER->Setup(); |
| 124 CHECK_EQ(0, LOGGER->GetLogLines(0, NULL, 0)); | 126 CHECK_EQ(0, LOGGER->GetLogLines(0, NULL, 0)); |
| 125 CHECK_EQ(0, LOGGER->GetLogLines(100, NULL, 0)); | 127 CHECK_EQ(0, LOGGER->GetLogLines(100, NULL, 0)); |
| 126 CHECK_EQ(0, LOGGER->GetLogLines(0, NULL, 100)); | 128 CHECK_EQ(0, LOGGER->GetLogLines(0, NULL, 100)); |
| 127 CHECK_EQ(0, LOGGER->GetLogLines(100, NULL, 100)); | 129 CHECK_EQ(0, LOGGER->GetLogLines(100, NULL, 100)); |
| 128 LOGGER->TearDown(); | 130 LOGGER->TearDown(); |
| 129 } | 131 } |
| 130 | 132 |
| 131 | 133 |
| 132 static void CompileAndRunScript(const char *src) { | 134 static void CompileAndRunScript(const char *src) { |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 // Make sure that all log data is written prior crash due to CHECK failure. | 1190 // Make sure that all log data is written prior crash due to CHECK failure. |
| 1189 fflush(stdout); | 1191 fflush(stdout); |
| 1190 CHECK(results_equal); | 1192 CHECK(results_equal); |
| 1191 | 1193 |
| 1192 env->Exit(); | 1194 env->Exit(); |
| 1193 LOGGER->TearDown(); | 1195 LOGGER->TearDown(); |
| 1194 i::FLAG_always_compact = saved_always_compact; | 1196 i::FLAG_always_compact = saved_always_compact; |
| 1195 } | 1197 } |
| 1196 | 1198 |
| 1197 #endif // ENABLE_LOGGING_AND_PROFILING | 1199 #endif // ENABLE_LOGGING_AND_PROFILING |
| OLD | NEW |