| 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 __linux__ | 5 #ifdef __linux__ |
| 6 #include <math.h> | 6 #include <math.h> |
| 7 #include <pthread.h> | 7 #include <pthread.h> |
| 8 #include <signal.h> | 8 #include <signal.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 #endif // __linux__ | 10 #endif // __linux__ |
| 11 | 11 |
| 12 #include "v8.h" | 12 #include "v8.h" |
| 13 #include "log.h" | 13 #include "log.h" |
| 14 #include "cpu-profiler.h" | 14 #include "cpu-profiler.h" |
| 15 #include "natives.h" | 15 #include "natives.h" |
| 16 #include "v8threads.h" | 16 #include "v8threads.h" |
| 17 #include "v8utils.h" | 17 #include "v8utils.h" |
| 18 #include "cctest.h" | 18 #include "cctest.h" |
| 19 #include "vm-state-inl.h" | 19 #include "vm-state-inl.h" |
| 20 | 20 |
| 21 using v8::internal::Address; | 21 using v8::internal::Address; |
| 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 { | 26 namespace { |
| 27 | 27 |
| 28 |
| 28 class ScopedLoggerInitializer { | 29 class ScopedLoggerInitializer { |
| 29 public: | 30 public: |
| 30 explicit ScopedLoggerInitializer(bool prof_lazy) | 31 explicit ScopedLoggerInitializer(bool prof_lazy) |
| 31 : saved_log_(i::FLAG_log), | 32 : saved_log_(i::FLAG_log), |
| 32 saved_prof_lazy_(i::FLAG_prof_lazy), | 33 saved_prof_lazy_(i::FLAG_prof_lazy), |
| 33 saved_prof_(i::FLAG_prof), | 34 saved_prof_(i::FLAG_prof), |
| 34 saved_prof_auto_(i::FLAG_prof_auto), | 35 saved_prof_auto_(i::FLAG_prof_auto), |
| 35 temp_file_(NULL), | 36 temp_file_(NULL), |
| 36 // Need to run this prior to creating the scope. | 37 // Need to run this prior to creating the scope. |
| 37 trick_to_run_init_flags_(init_flags_(prof_lazy)), | 38 trick_to_run_init_flags_(init_flags_(prof_lazy)), |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 CHECK(LOGGER->is_logging()); | 464 CHECK(LOGGER->is_logging()); |
| 464 LOGGER->ResumeProfiler(); | 465 LOGGER->ResumeProfiler(); |
| 465 CHECK(LOGGER->is_logging()); | 466 CHECK(LOGGER->is_logging()); |
| 466 LOGGER->PauseProfiler(); | 467 LOGGER->PauseProfiler(); |
| 467 CHECK(LOGGER->is_logging()); | 468 CHECK(LOGGER->is_logging()); |
| 468 } | 469 } |
| 469 | 470 |
| 470 | 471 |
| 471 typedef i::NativesCollection<i::TEST> TestSources; | 472 typedef i::NativesCollection<i::TEST> TestSources; |
| 472 | 473 |
| 473 // Test that logging of code create / move / delete events | 474 |
| 474 // is equivalent to traversal of a resulting heap. | 475 // Test that logging of code create / move events is equivalent to traversal of |
| 476 // a resulting heap. |
| 475 TEST(EquivalenceOfLoggingAndTraversal) { | 477 TEST(EquivalenceOfLoggingAndTraversal) { |
| 476 // This test needs to be run on a "clean" V8 to ensure that snapshot log | 478 // This test needs to be run on a "clean" V8 to ensure that snapshot log |
| 477 // is loaded. This is always true when running using tools/test.py because | 479 // is loaded. This is always true when running using tools/test.py because |
| 478 // it launches a new cctest instance for every test. To be sure that launching | 480 // it launches a new cctest instance for every test. To be sure that launching |
| 479 // cctest manually also works, please be sure that no tests below | 481 // cctest manually also works, please be sure that no tests below |
| 480 // are using V8. | 482 // are using V8. |
| 481 // | 483 // |
| 482 // P.S. No, V8 can't be re-initialized after disposal, see include/v8.h. | 484 // P.S. No, V8 can't be re-initialized after disposal, see include/v8.h. |
| 483 CHECK(!i::V8::IsRunning()); | 485 CHECK(!i::V8::IsRunning()); |
| 484 | 486 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 v8::Local<v8::String> s = result->ToString(); | 529 v8::Local<v8::String> s = result->ToString(); |
| 528 i::ScopedVector<char> data(s->Length() + 1); | 530 i::ScopedVector<char> data(s->Length() + 1); |
| 529 CHECK_NE(NULL, data.start()); | 531 CHECK_NE(NULL, data.start()); |
| 530 s->WriteAscii(data.start()); | 532 s->WriteAscii(data.start()); |
| 531 printf("%s\n", data.start()); | 533 printf("%s\n", data.start()); |
| 532 // Make sure that our output is written prior crash due to CHECK failure. | 534 // Make sure that our output is written prior crash due to CHECK failure. |
| 533 fflush(stdout); | 535 fflush(stdout); |
| 534 CHECK(false); | 536 CHECK(false); |
| 535 } | 537 } |
| 536 } | 538 } |
| OLD | NEW |