Index: test/cctest/test-cpu-profiler.cc |
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc |
index be745c815a672cdd236d3793f698a6a6ea0e4337..042b989899fd30ce571c0e0cf0bbc90a794f5cbd 100644 |
--- a/test/cctest/test-cpu-profiler.cc |
+++ b/test/cctest/test-cpu-profiler.cc |
@@ -297,6 +297,19 @@ TEST(DeleteAllCpuProfiles) { |
} |
+static const v8::CpuProfile* FindCpuProfile(v8::CpuProfiler* profiler, |
+ unsigned uid) { |
+ int length = profiler->GetProfileCount(); |
+ for (int i = 0; i < length; i++) { |
+ const v8::CpuProfile* profile = profiler->GetCpuProfile(i); |
+ if (profile->GetUid() == uid) { |
+ return profile; |
+ } |
+ } |
+ return NULL; |
+} |
+ |
+ |
TEST(DeleteCpuProfile) { |
LocalContext env; |
v8::HandleScope scope(env->GetIsolate()); |
@@ -309,10 +322,10 @@ TEST(DeleteCpuProfile) { |
CHECK_NE(NULL, p1); |
CHECK_EQ(1, cpu_profiler->GetProfileCount()); |
unsigned uid1 = p1->GetUid(); |
- CHECK_EQ(p1, cpu_profiler->FindCpuProfile(uid1)); |
+ CHECK_EQ(p1, FindCpuProfile(cpu_profiler, uid1)); |
alph
2013/05/28 05:27:51
Perhaps we should keep testing the current API unt
yurys
2013/05/28 06:14:57
That would break compilation because of V8_DEPRECA
alph
2013/05/28 06:28:54
I see two ways:
1. #define V8_DISABLE_DEPRECATIONS
yurys
2013/05/28 07:19:31
Done #1. PTAL
|
const_cast<v8::CpuProfile*>(p1)->Delete(); |
CHECK_EQ(0, cpu_profiler->GetProfileCount()); |
- CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); |
+ CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1)); |
v8::Local<v8::String> name2 = v8::String::New("2"); |
cpu_profiler->StartCpuProfiling(name2); |
@@ -321,64 +334,8 @@ TEST(DeleteCpuProfile) { |
CHECK_EQ(1, cpu_profiler->GetProfileCount()); |
unsigned uid2 = p2->GetUid(); |
CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); |
- CHECK_EQ(p2, cpu_profiler->FindCpuProfile(uid2)); |
- CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); |
- v8::Local<v8::String> name3 = v8::String::New("3"); |
- cpu_profiler->StartCpuProfiling(name3); |
- const v8::CpuProfile* p3 = cpu_profiler->StopCpuProfiling(name3); |
- CHECK_NE(NULL, p3); |
- CHECK_EQ(2, cpu_profiler->GetProfileCount()); |
- unsigned uid3 = p3->GetUid(); |
- CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); |
- CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); |
- CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); |
- const_cast<v8::CpuProfile*>(p2)->Delete(); |
- CHECK_EQ(1, cpu_profiler->GetProfileCount()); |
- CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); |
- CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); |
- const_cast<v8::CpuProfile*>(p3)->Delete(); |
- CHECK_EQ(0, cpu_profiler->GetProfileCount()); |
- CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid3)); |
- CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); |
- CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); |
-} |
- |
- |
-TEST(DeleteCpuProfileDifferentTokens) { |
- LocalContext env; |
- v8::HandleScope scope(env->GetIsolate()); |
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); |
- |
- CHECK_EQ(0, cpu_profiler->GetProfileCount()); |
- v8::Local<v8::String> name1 = v8::String::New("1"); |
- cpu_profiler->StartCpuProfiling(name1); |
- const v8::CpuProfile* p1 = cpu_profiler->StopCpuProfiling(name1); |
- CHECK_NE(NULL, p1); |
- CHECK_EQ(1, cpu_profiler->GetProfileCount()); |
- unsigned uid1 = p1->GetUid(); |
- CHECK_EQ(p1, cpu_profiler->FindCpuProfile(uid1)); |
- v8::Local<v8::String> token1 = v8::String::New("token1"); |
- const v8::CpuProfile* p1_t1 = cpu_profiler->FindCpuProfile(uid1, token1); |
- CHECK_NE(NULL, p1_t1); |
- CHECK_NE(p1, p1_t1); |
- CHECK_EQ(1, cpu_profiler->GetProfileCount()); |
- const_cast<v8::CpuProfile*>(p1)->Delete(); |
- CHECK_EQ(0, cpu_profiler->GetProfileCount()); |
- CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); |
- CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1, token1)); |
- const_cast<v8::CpuProfile*>(p1_t1)->Delete(); |
- CHECK_EQ(0, cpu_profiler->GetProfileCount()); |
- |
- v8::Local<v8::String> name2 = v8::String::New("2"); |
- cpu_profiler->StartCpuProfiling(name2); |
- v8::Local<v8::String> token2 = v8::String::New("token2"); |
- const v8::CpuProfile* p2_t2 = cpu_profiler->StopCpuProfiling(name2, token2); |
- CHECK_NE(NULL, p2_t2); |
- CHECK_EQ(1, cpu_profiler->GetProfileCount()); |
- unsigned uid2 = p2_t2->GetUid(); |
- CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); |
- const v8::CpuProfile* p2 = cpu_profiler->FindCpuProfile(uid2); |
- CHECK_NE(p2_t2, p2); |
+ CHECK_EQ(p2, FindCpuProfile(cpu_profiler, uid2)); |
+ CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1)); |
v8::Local<v8::String> name3 = v8::String::New("3"); |
cpu_profiler->StartCpuProfiling(name3); |
const v8::CpuProfile* p3 = cpu_profiler->StopCpuProfiling(name3); |
@@ -386,18 +343,17 @@ TEST(DeleteCpuProfileDifferentTokens) { |
CHECK_EQ(2, cpu_profiler->GetProfileCount()); |
unsigned uid3 = p3->GetUid(); |
CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); |
- CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); |
- const_cast<v8::CpuProfile*>(p2_t2)->Delete(); |
- CHECK_EQ(1, cpu_profiler->GetProfileCount()); |
- CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); |
- CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); |
+ CHECK_EQ(p3, FindCpuProfile(cpu_profiler, uid3)); |
+ CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1)); |
const_cast<v8::CpuProfile*>(p2)->Delete(); |
CHECK_EQ(1, cpu_profiler->GetProfileCount()); |
- CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); |
- CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); |
+ CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid2)); |
+ CHECK_EQ(p3, FindCpuProfile(cpu_profiler, uid3)); |
const_cast<v8::CpuProfile*>(p3)->Delete(); |
CHECK_EQ(0, cpu_profiler->GetProfileCount()); |
- CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid3)); |
+ CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid3)); |
+ CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid2)); |
+ CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1)); |
} |