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

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

Issue 195613002: Fix service test breakage (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | tests/standalone/vmservice/isolate_echo_test.dart » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "vm/dart_api_impl.h" 6 #include "vm/dart_api_impl.h"
7 #include "vm/dart_entry.h" 7 #include "vm/dart_entry.h"
8 #include "vm/debugger.h" 8 #include "vm/debugger.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/message_handler.h" 10 #include "vm/message_handler.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 EXPECT_VALID(port); 182 EXPECT_VALID(port);
183 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 183 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
184 184
185 Instance& service_msg = Instance::Handle(); 185 Instance& service_msg = Instance::Handle();
186 186
187 // Get the stacktrace. 187 // Get the stacktrace.
188 service_msg = Eval(lib, "[port, ['stacktrace'], [], []]"); 188 service_msg = Eval(lib, "[port, ['stacktrace'], [], []]");
189 Service::HandleIsolateMessage(isolate, service_msg); 189 Service::HandleIsolateMessage(isolate, service_msg);
190 handler.HandleNextMessage(); 190 handler.HandleNextMessage();
191 EXPECT_STREQ( 191 EXPECT_STREQ(
192 "{\"type\":\"StackTrace\",\"members\":[]}", 192 "{\"type\":\"StackTrace\",\"id\":\"stacktrace\",\"members\":[]}",
193 handler.msg()); 193 handler.msg());
194 194
195 // Malformed request. 195 // Malformed request.
196 service_msg = Eval(lib, "[port, ['stacktrace', 'jamboree'], [], []]"); 196 service_msg = Eval(lib, "[port, ['stacktrace', 'jamboree'], [], []]");
197 Service::HandleIsolateMessage(isolate, service_msg); 197 Service::HandleIsolateMessage(isolate, service_msg);
198 handler.HandleNextMessage(); 198 handler.HandleNextMessage();
199 EXPECT_STREQ( 199 EXPECT_STREQ(
200 "{\"type\":\"Error\",\"text\":\"Command too long\"," 200 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Command too long\","
201 "\"message\":{\"arguments\":[\"stacktrace\",\"jamboree\"]," 201 "\"request\":{\"arguments\":[\"stacktrace\",\"jamboree\"],"
202 "\"option_keys\":[],\"option_values\":[]}}", 202 "\"option_keys\":[],\"option_values\":[]}}",
203 handler.msg()); 203 handler.msg());
204 } 204 }
205 205
206 206
207 TEST_CASE(Service_DebugBreakpoints) { 207 TEST_CASE(Service_DebugBreakpoints) {
208 const char* kScript = 208 const char* kScript =
209 "var port;\n" // Set to our mock port by C++. 209 "var port;\n" // Set to our mock port by C++.
210 "\n" 210 "\n"
211 "main() {\n" // We set breakpoint here. 211 "main() {\n" // We set breakpoint here.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 "\"resolved\":false," 250 "\"resolved\":false,"
251 "\"location\":{\"type\":\"Location\"," 251 "\"location\":{\"type\":\"Location\","
252 "\"script\":\"dart:test-lib\",\"tokenPos\":5}}", 252 "\"script\":\"dart:test-lib\",\"tokenPos\":5}}",
253 handler.msg()); 253 handler.msg());
254 254
255 // Missing sub-command. 255 // Missing sub-command.
256 service_msg = Eval(lib, "[port, ['debug'], [], []]"); 256 service_msg = Eval(lib, "[port, ['debug'], [], []]");
257 Service::HandleIsolateMessage(isolate, service_msg); 257 Service::HandleIsolateMessage(isolate, service_msg);
258 handler.HandleNextMessage(); 258 handler.HandleNextMessage();
259 EXPECT_STREQ( 259 EXPECT_STREQ(
260 "{\"type\":\"Error\"," 260 "{\"type\":\"Error\",\"id\":\"\","
261 "\"text\":\"Must specify a subcommand\"," 261 "\"message\":\"Must specify a subcommand\","
262 "\"message\":{\"arguments\":[\"debug\"],\"option_keys\":[]," 262 "\"request\":{\"arguments\":[\"debug\"],\"option_keys\":[],"
263 "\"option_values\":[]}}", 263 "\"option_values\":[]}}",
264 handler.msg()); 264 handler.msg());
265 265
266 // Unrecognized breakpoint. 266 // Unrecognized breakpoint.
267 service_msg = Eval(lib, "[port, ['debug', 'breakpoints', '1111'], [], []]"); 267 service_msg = Eval(lib, "[port, ['debug', 'breakpoints', '1111'], [], []]");
268 Service::HandleIsolateMessage(isolate, service_msg); 268 Service::HandleIsolateMessage(isolate, service_msg);
269 handler.HandleNextMessage(); 269 handler.HandleNextMessage();
270 EXPECT_STREQ("{\"type\":\"Error\"," 270 EXPECT_STREQ("{\"type\":\"Error\",\"id\":\"\","
271 "\"text\":\"Unrecognized breakpoint id 1111\"," 271 "\"message\":\"Unrecognized breakpoint id 1111\","
272 "\"message\":{" 272 "\"request\":{"
273 "\"arguments\":[\"debug\",\"breakpoints\",\"1111\"]," 273 "\"arguments\":[\"debug\",\"breakpoints\",\"1111\"],"
274 "\"option_keys\":[],\"option_values\":[]}}", 274 "\"option_keys\":[],\"option_values\":[]}}",
275 handler.msg()); 275 handler.msg());
276 276
277 // Command too long. 277 // Command too long.
278 service_msg = 278 service_msg =
279 Eval(lib, "[port, ['debug', 'breakpoints', '1111', 'green'], [], []]"); 279 Eval(lib, "[port, ['debug', 'breakpoints', '1111', 'green'], [], []]");
280 Service::HandleIsolateMessage(isolate, service_msg); 280 Service::HandleIsolateMessage(isolate, service_msg);
281 handler.HandleNextMessage(); 281 handler.HandleNextMessage();
282 EXPECT_STREQ("{\"type\":\"Error\",\"text\":\"Command too long\"," 282 EXPECT_STREQ("{\"type\":\"Error\",\"id\":\"\","
283 "\"message\":{\"arguments\":[\"debug\",\"breakpoints\"," 283 "\"message\":\"Command too long\","
284 "\"request\":{\"arguments\":[\"debug\",\"breakpoints\","
284 "\"1111\",\"green\"]," 285 "\"1111\",\"green\"],"
285 "\"option_keys\":[],\"option_values\":[]}}", 286 "\"option_keys\":[],\"option_values\":[]}}",
286 handler.msg()); 287 handler.msg());
287 288
288 // Unrecognized subcommand. 289 // Unrecognized subcommand.
289 service_msg = Eval(lib, "[port, ['debug', 'nosferatu'], [], []]"); 290 service_msg = Eval(lib, "[port, ['debug', 'nosferatu'], [], []]");
290 Service::HandleIsolateMessage(isolate, service_msg); 291 Service::HandleIsolateMessage(isolate, service_msg);
291 handler.HandleNextMessage(); 292 handler.HandleNextMessage();
292 EXPECT_STREQ("{\"type\":\"Error\"," 293 EXPECT_STREQ("{\"type\":\"Error\",\"id\":\"\","
293 "\"text\":\"Unrecognized subcommand 'nosferatu'\"," 294 "\"message\":\"Unrecognized subcommand 'nosferatu'\","
294 "\"message\":{\"arguments\":[\"debug\",\"nosferatu\"]," 295 "\"request\":{\"arguments\":[\"debug\",\"nosferatu\"],"
295 "\"option_keys\":[],\"option_values\":[]}}", 296 "\"option_keys\":[],\"option_values\":[]}}",
296 handler.msg()); 297 handler.msg());
297 } 298 }
298 299
299 300
300 TEST_CASE(Service_Classes) { 301 TEST_CASE(Service_Classes) {
301 const char* kScript = 302 const char* kScript =
302 "var port;\n" // Set to our mock port by C++. 303 "var port;\n" // Set to our mock port by C++.
303 "\n" 304 "\n"
304 "class A {\n" 305 "class A {\n"
(...skipping 30 matching lines...) Expand all
335 EXPECT_VALID(port); 336 EXPECT_VALID(port);
336 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); 337 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port));
337 338
338 Instance& service_msg = Instance::Handle(); 339 Instance& service_msg = Instance::Handle();
339 340
340 // Request an invalid class id. 341 // Request an invalid class id.
341 service_msg = Eval(h_lib, "[port, ['classes', '999999'], [], []]"); 342 service_msg = Eval(h_lib, "[port, ['classes', '999999'], [], []]");
342 Service::HandleIsolateMessage(isolate, service_msg); 343 Service::HandleIsolateMessage(isolate, service_msg);
343 handler.HandleNextMessage(); 344 handler.HandleNextMessage();
344 EXPECT_STREQ( 345 EXPECT_STREQ(
345 "{\"type\":\"Error\",\"text\":\"999999 is not a valid class id.\"," 346 "{\"type\":\"Error\",\"id\":\"\","
346 "\"message\":{\"arguments\":[\"classes\",\"999999\"]," 347 "\"message\":\"999999 is not a valid class id.\","
348 "\"request\":{\"arguments\":[\"classes\",\"999999\"],"
347 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); 349 "\"option_keys\":[],\"option_values\":[]}}", handler.msg());
348 350
349 // Request the class A over the service. 351 // Request the class A over the service.
350 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "'], [], []]", cid); 352 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "'], [], []]", cid);
351 Service::HandleIsolateMessage(isolate, service_msg); 353 Service::HandleIsolateMessage(isolate, service_msg);
352 handler.HandleNextMessage(); 354 handler.HandleNextMessage();
353 355
354 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg()); 356 EXPECT_SUBSTRING("\"type\":\"Class\"", handler.msg());
355 ExpectSubstringF(handler.msg(), 357 ExpectSubstringF(handler.msg(),
356 "\"id\":\"classes\\/%" Pd "\",\"name\":\"A\",", cid); 358 "\"id\":\"classes\\/%" Pd "\",\"name\":\"A\",", cid);
(...skipping 16 matching lines...) Expand all
373 ExpectSubstringF(handler.msg(), 375 ExpectSubstringF(handler.msg(),
374 "\"id\":\"classes\\/%" Pd "\\/fields\\/0\"," 376 "\"id\":\"classes\\/%" Pd "\\/fields\\/0\","
375 "\"name\":\"a\",", cid); 377 "\"name\":\"a\",", cid);
376 378
377 // Invalid sub command. 379 // Invalid sub command.
378 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'huh', '0']," 380 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'huh', '0'],"
379 "[], []]", cid); 381 "[], []]", cid);
380 Service::HandleIsolateMessage(isolate, service_msg); 382 Service::HandleIsolateMessage(isolate, service_msg);
381 handler.HandleNextMessage(); 383 handler.HandleNextMessage();
382 ExpectSubstringF(handler.msg(), 384 ExpectSubstringF(handler.msg(),
383 "{\"type\":\"Error\",\"text\":\"Invalid sub collection huh\",\"message\":" 385 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Invalid sub collection huh\""
386 ",\"request\":"
384 "{\"arguments\":[\"classes\",\"%" Pd "\",\"huh\",\"0\"],\"option_keys\":[]," 387 "{\"arguments\":[\"classes\",\"%" Pd "\",\"huh\",\"0\"],\"option_keys\":[],"
385 "\"option_values\":[]}}", cid); 388 "\"option_values\":[]}}", cid);
386 389
387 // Invalid field request. 390 // Invalid field request.
388 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '9']," 391 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '9'],"
389 "[], []]", cid); 392 "[], []]", cid);
390 Service::HandleIsolateMessage(isolate, service_msg); 393 Service::HandleIsolateMessage(isolate, service_msg);
391 handler.HandleNextMessage(); 394 handler.HandleNextMessage();
392 ExpectSubstringF(handler.msg(), 395 ExpectSubstringF(handler.msg(),
393 "{\"type\":\"Error\",\"text\":\"Field 9 not found\"," 396 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Field 9 not found\","
394 "\"message\":{\"arguments\":[\"classes\",\"%" Pd "\",\"fields\",\"9\"]," 397 "\"request\":{\"arguments\":[\"classes\",\"%" Pd "\",\"fields\",\"9\"],"
395 "\"option_keys\":[],\"option_values\":[]}}", cid); 398 "\"option_keys\":[],\"option_values\":[]}}", cid);
396 399
397 // Invalid function request. 400 // Invalid function request.
398 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '9']," 401 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '9'],"
399 "[], []]", cid); 402 "[], []]", cid);
400 Service::HandleIsolateMessage(isolate, service_msg); 403 Service::HandleIsolateMessage(isolate, service_msg);
401 handler.HandleNextMessage(); 404 handler.HandleNextMessage();
402 ExpectSubstringF(handler.msg(), 405 ExpectSubstringF(handler.msg(),
403 "{\"type\":\"Error\",\"text\":\"Function 9 not found\"," 406 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Function 9 not found\","
404 "\"message\":{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"9\"]," 407 "\"request\":{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"9\"],"
405 "\"option_keys\":[],\"option_values\":[]}}", cid); 408 "\"option_keys\":[],\"option_values\":[]}}", cid);
406 409
407 410
408 // Invalid field subcommand. 411 // Invalid field subcommand.
409 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '9', 'x']" 412 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'fields', '9', 'x']"
410 ",[], []]", cid); 413 ",[], []]", cid);
411 Service::HandleIsolateMessage(isolate, service_msg); 414 Service::HandleIsolateMessage(isolate, service_msg);
412 handler.HandleNextMessage(); 415 handler.HandleNextMessage();
413 ExpectSubstringF(handler.msg(), 416 ExpectSubstringF(handler.msg(),
414 "{\"type\":\"Error\",\"text\":\"Command too long\",\"message\":" 417 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Command too long\","
418 "\"request\":"
415 "{\"arguments\":[\"classes\",\"%" Pd "\",\"fields\",\"9\",\"x\"]," 419 "{\"arguments\":[\"classes\",\"%" Pd "\",\"fields\",\"9\",\"x\"],"
416 "\"option_keys\":[],\"option_values\":[]}}", cid); 420 "\"option_keys\":[],\"option_values\":[]}}", cid);
417 421
418 // Invalid function request. 422 // Invalid function request.
419 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '9'," 423 service_msg = EvalF(h_lib, "[port, ['classes', '%" Pd "', 'functions', '9',"
420 "'x'], [], []]", cid); 424 "'x'], [], []]", cid);
421 Service::HandleIsolateMessage(isolate, service_msg); 425 Service::HandleIsolateMessage(isolate, service_msg);
422 handler.HandleNextMessage(); 426 handler.HandleNextMessage();
423 ExpectSubstringF(handler.msg(), 427 ExpectSubstringF(handler.msg(),
424 "{\"type\":\"Error\",\"text\":\"Command too long\",\"message\":" 428 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Command too long\","
429 "\"request\":"
425 "{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"9\",\"x\"]," 430 "{\"arguments\":[\"classes\",\"%" Pd "\",\"functions\",\"9\",\"x\"],"
426 "\"option_keys\":[],\"option_values\":[]}}", cid); 431 "\"option_keys\":[],\"option_values\":[]}}", cid);
427 } 432 }
428 433
429 434
430 TEST_CASE(Service_Code) { 435 TEST_CASE(Service_Code) {
431 const char* kScript = 436 const char* kScript =
432 "var port;\n" // Set to our mock port by C++. 437 "var port;\n" // Set to our mock port by C++.
433 "\n" 438 "\n"
434 "class A {\n" 439 "class A {\n"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 EXPECT_VALID(port); 477 EXPECT_VALID(port);
473 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port)); 478 EXPECT_VALID(Dart_SetField(h_lib, NewString("port"), port));
474 479
475 Instance& service_msg = Instance::Handle(); 480 Instance& service_msg = Instance::Handle();
476 481
477 // Request an invalid code object. 482 // Request an invalid code object.
478 service_msg = Eval(h_lib, "[port, ['code', '0'], [], []]"); 483 service_msg = Eval(h_lib, "[port, ['code', '0'], [], []]");
479 Service::HandleIsolateMessage(isolate, service_msg); 484 Service::HandleIsolateMessage(isolate, service_msg);
480 handler.HandleNextMessage(); 485 handler.HandleNextMessage();
481 EXPECT_STREQ( 486 EXPECT_STREQ(
482 "{\"type\":\"Error\",\"text\":\"Could not find code at 0\",\"message\":" 487 "{\"type\":\"Error\",\"id\":\"\",\"message\":\"Could not find code at 0\","
483 "{\"arguments\":[\"code\",\"0\"]," 488 "\"request\":{\"arguments\":[\"code\",\"0\"],"
484 "\"option_keys\":[],\"option_values\":[]}}", handler.msg()); 489 "\"option_keys\":[],\"option_values\":[]}}", handler.msg());
485 490
486 // The following four tests check that a code object can be found 491 // The following four tests check that a code object can be found
487 // inside the range: [code.EntryPoint(), code.EntryPoint() + code.Size()). 492 // inside the range: [code.EntryPoint(), code.EntryPoint() + code.Size()).
488 // Request code object at code.EntryPoint() 493 // Request code object at code.EntryPoint()
489 // Expect this to succeed as it is inside [entry, entry + size). 494 // Expect this to succeed as it is inside [entry, entry + size).
490 service_msg = EvalF(h_lib, "[port, ['code', '%" Px "'], [], []]", entry); 495 service_msg = EvalF(h_lib, "[port, ['code', '%" Px "'], [], []]", entry);
491 Service::HandleIsolateMessage(isolate, service_msg); 496 Service::HandleIsolateMessage(isolate, service_msg);
492 handler.HandleNextMessage(); 497 handler.HandleNextMessage();
493 { 498 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 // Request code object at code.EntryPoint() + code.Size(). Expect this 537 // Request code object at code.EntryPoint() + code.Size(). Expect this
533 // to fail as it's outside of [entry, entry + size). 538 // to fail as it's outside of [entry, entry + size).
534 address = last; 539 address = last;
535 service_msg = EvalF(h_lib, "[port, ['code', '%" Px "'], [], []]", address); 540 service_msg = EvalF(h_lib, "[port, ['code', '%" Px "'], [], []]", address);
536 Service::HandleIsolateMessage(isolate, service_msg); 541 Service::HandleIsolateMessage(isolate, service_msg);
537 handler.HandleNextMessage(); 542 handler.HandleNextMessage();
538 { 543 {
539 const intptr_t kBufferSize = 1024; 544 const intptr_t kBufferSize = 1024;
540 char buffer[kBufferSize]; 545 char buffer[kBufferSize];
541 OS::SNPrint(buffer, kBufferSize-1, 546 OS::SNPrint(buffer, kBufferSize-1,
542 "{\"type\":\"Error\",\"text\":\"Could not find code at %" Px "\"," 547 "{\"type\":\"Error\",\"id\":\"\","
543 "\"message\":{\"arguments\":[\"code\",\"%" Px "\"]," 548 "\"message\":\"Could not find code at %" Px "\","
549 "\"request\":{\"arguments\":[\"code\",\"%" Px "\"],"
544 "\"option_keys\":[],\"option_values\":[]}}", address, address); 550 "\"option_keys\":[],\"option_values\":[]}}", address, address);
545 EXPECT_STREQ(buffer, handler.msg()); 551 EXPECT_STREQ(buffer, handler.msg());
546 } 552 }
547 } 553 }
548 554
549 555
550 TEST_CASE(Service_Cpu) { 556 TEST_CASE(Service_Cpu) {
551 const char* kScript = 557 const char* kScript =
552 "var port;\n" // Set to our mock port by C++. 558 "var port;\n" // Set to our mock port by C++.
553 "\n" 559 "\n"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 Service::HandleIsolateMessage(isolate, service_msg); 751 Service::HandleIsolateMessage(isolate, service_msg);
746 handler.HandleNextMessage(); 752 handler.HandleNextMessage();
747 EXPECT_STREQ("alpha", handler.msg()); 753 EXPECT_STREQ("alpha", handler.msg());
748 service_msg = Eval(lib, "[port, ['beta'], [], []]"); 754 service_msg = Eval(lib, "[port, ['beta'], [], []]");
749 Service::HandleIsolateMessage(isolate, service_msg); 755 Service::HandleIsolateMessage(isolate, service_msg);
750 handler.HandleNextMessage(); 756 handler.HandleNextMessage();
751 EXPECT_STREQ("beta", handler.msg()); 757 EXPECT_STREQ("beta", handler.msg());
752 } 758 }
753 759
754 } // namespace dart 760 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/vmservice/isolate_echo_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698