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

Side by Side Diff: runtime/vm/debugger_api_impl_test.cc

Issue 9475030: Print more info in debugger tests (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_debugger_api.h" 5 #include "include/dart_debugger_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/unit_test.h" 8 #include "vm/unit_test.h"
9 9
10 namespace dart { 10 namespace dart {
11 11
12 // Only ia32 and x64 can run execution tests. 12 // Only ia32 and x64 can run execution tests.
13 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) 13 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
14 14
15 static bool breakpoint_hit = false; 15 static bool breakpoint_hit = false;
16 static int breakpoint_hit_counter = 0; 16 static int breakpoint_hit_counter = 0;
17 17
18 static const bool verbose = false; 18 static const bool verbose = true;
19 19
20 #define EXPECT_NOT_ERROR(handle) \ 20 #define EXPECT_NOT_ERROR(handle) \
21 if (Dart_IsError(handle)) { \ 21 if (Dart_IsError(handle)) { \
22 OS::Print("Error: %s\n", Dart_GetError(handle)); \ 22 OS::Print("Error: %s\n", Dart_GetError(handle)); \
23 } \ 23 } \
24 EXPECT(!Dart_IsError(handle)); 24 EXPECT(!Dart_IsError(handle));
25 25
26 26
27 static Dart_Handle Invoke(Dart_Handle lib, const char* func_name) { 27 static Dart_Handle Invoke(Dart_Handle lib, const char* func_name) {
28 return Dart_InvokeStatic(lib, 28 return Dart_InvokeStatic(lib,
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 EXPECT(breakpoint_hit_counter < expected_bpts_length); 259 EXPECT(breakpoint_hit_counter < expected_bpts_length);
260 Dart_ActivationFrame frame; 260 Dart_ActivationFrame frame;
261 res = Dart_GetActivationFrame(trace, 0, &frame); 261 res = Dart_GetActivationFrame(trace, 0, &frame);
262 EXPECT_NOT_ERROR(res); 262 EXPECT_NOT_ERROR(res);
263 Dart_Handle func_name; 263 Dart_Handle func_name;
264 res = Dart_ActivationFrameInfo(frame, &func_name, NULL, NULL); 264 res = Dart_ActivationFrameInfo(frame, &func_name, NULL, NULL);
265 EXPECT_NOT_ERROR(res); 265 EXPECT_NOT_ERROR(res);
266 EXPECT(Dart_IsString(func_name)); 266 EXPECT(Dart_IsString(func_name));
267 const char* name_chars; 267 const char* name_chars;
268 Dart_StringToCString(func_name, &name_chars); 268 Dart_StringToCString(func_name, &name_chars);
269 if (verbose) {
270 printf(" >> bpt nr %d: %s\n", breakpoint_hit_counter, name_chars);
271 }
269 if (breakpoint_hit_counter < expected_bpts_length) { 272 if (breakpoint_hit_counter < expected_bpts_length) {
270 EXPECT_STREQ(expected_bpts[breakpoint_hit_counter], name_chars); 273 EXPECT_STREQ(expected_bpts[breakpoint_hit_counter], name_chars);
271 } 274 }
272 if (verbose) {
273 printf(" >> bpt nr %d: %s\n", breakpoint_hit_counter, name_chars);
274 }
275 breakpoint_hit = true; 275 breakpoint_hit = true;
276 breakpoint_hit_counter++; 276 breakpoint_hit_counter++;
277 Dart_SetStepOver(); 277 Dart_SetStepOver();
278 } 278 }
279 279
280 280
281 TEST_CASE(Debug_SingleStep) { 281 TEST_CASE(Debug_SingleStep) {
282 const char* kScriptChars = 282 const char* kScriptChars =
283 "void moo(s) { return 1; } \n" 283 "void moo(s) { return 1; } \n"
284 " \n" 284 " \n"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 Dart_Breakpoint bpt; 368 Dart_Breakpoint bpt;
369 Dart_Handle res = Dart_SetBreakpointAtLine(script_url, line_no, &bpt); 369 Dart_Handle res = Dart_SetBreakpointAtLine(script_url, line_no, &bpt);
370 EXPECT_NOT_ERROR(res); 370 EXPECT_NOT_ERROR(res);
371 371
372 // Function main() calls foo() 3 times. On the second iteration, the 372 // Function main() calls foo() 3 times. On the second iteration, the
373 // breakpoint is removed by the handler, so we expect the breakpoint 373 // breakpoint is removed by the handler, so we expect the breakpoint
374 // to fire twice only. 374 // to fire twice only.
375 breakpoint_hit_counter = 0; 375 breakpoint_hit_counter = 0;
376 Dart_Handle retval = Invoke(lib, "main"); 376 Dart_Handle retval = Invoke(lib, "main");
377 EXPECT(!Dart_IsError(retval)); 377 EXPECT(!Dart_IsError(retval));
378 EXPECT(breakpoint_hit_counter == 2); 378 EXPECT_EQ(2, breakpoint_hit_counter);
379 } 379 }
380 380
381 381
382 TEST_CASE(Debug_InspectObject) { 382 TEST_CASE(Debug_InspectObject) {
383 const char* kScriptChars = 383 const char* kScriptChars =
384 " class A { \n" 384 " class A { \n"
385 " var a_field = 'a'; \n" 385 " var a_field = 'a'; \n"
386 " static var bla = 'yada yada yada'; \n" 386 " static var bla = 'yada yada yada'; \n"
387 " static var error = unresolvedName(); \n" 387 " static var error = unresolvedName(); \n"
388 " var d = 42.1; \n" 388 " var d = 42.1; \n"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 EXPECT(Dart_IsString(source)); 572 EXPECT(Dart_IsString(source));
573 char const* source_chars; 573 char const* source_chars;
574 Dart_StringToCString(source, &source_chars); 574 Dart_StringToCString(source, &source_chars);
575 printf("\n=== source: ===\n%s", source_chars); 575 printf("\n=== source: ===\n%s", source_chars);
576 EXPECT_STREQ(kScriptChars, source_chars); 576 EXPECT_STREQ(kScriptChars, source_chars);
577 } 577 }
578 578
579 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 579 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
580 580
581 } // namespace dart 581 } // namespace dart
OLDNEW
« 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