Files
sdk/runtime/vm/isolate_test.cc
T
turnidge@google.com e62f34ce77 Give isolates names to be used during debugging.
Implement --trace_isolates.

-------------

Sample output of --trace_isolates for the CrossIsolateMessageTest:

[+] Starting isolate:
    isolate:    CrossIsolateMessageTest.dart/main-7112
[+] Starting isolate:
    isolate:    CrossIsolateMessageTest.dart/CrossIsolate1.main-7114
[+] Starting isolate:
    isolate:    CrossIsolateMessageTest.dart/CrossIsolate2.main-7115
[>] Posting message:
    source:     CrossIsolateMessageTest.dart/main-7112
    reply_port: 7117
    dest:       CrossIsolateMessageTest.dart/CrossIsolate2.main-7115
    dest_port:  7115
[>] Posting message:
    source:     CrossIsolateMessageTest.dart/CrossIsolate2.main-7115
    reply_port: 7118
    dest:       CrossIsolateMessageTest.dart/main-7112
    dest_port:  7117
[>] Posting message:
    source:     CrossIsolateMessageTest.dart/main-7112
    reply_port: 7119
    dest:       CrossIsolateMessageTest.dart/CrossIsolate1.main-7114
    dest_port:  7114
[>] Posting message:
    source:     CrossIsolateMessageTest.dart/CrossIsolate1.main-7114
    reply_port: 7120
    dest:       CrossIsolateMessageTest.dart/main-7112
    dest_port:  7119
[>] Posting message:
    source:     CrossIsolateMessageTest.dart/main-7112
    reply_port: 0
    dest:       CrossIsolateMessageTest.dart/CrossIsolate1.main-7114
    dest_port:  7120
[>] Posting message:
    source:     CrossIsolateMessageTest.dart/CrossIsolate1.main-7114
    reply_port: 0
    dest:       CrossIsolateMessageTest.dart/CrossIsolate2.main-7115
    dest_port:  7118
[>] Posting message:
    source:     CrossIsolateMessageTest.dart/CrossIsolate2.main-7115
    reply_port: 0
    dest:       CrossIsolateMessageTest.dart/main-7112
    dest_port:  7116
[>] Posting message:
    source:     CrossIsolateMessageTest.dart/main-7112
    reply_port: 0
    dest:       CrossIsolateMessageTest.dart/main-7112
    dest_port:  7113
[-] Stopping isolate:
    isolate:    CrossIsolateMessageTest.dart/CrossIsolate2.main-7115
[-] Stopping isolate:
    isolate:    CrossIsolateMessageTest.dart/CrossIsolate1.main-7114
[-] Stopping isolate:
    isolate:    CrossIsolateMessageTest.dart/main-7112
Review URL: https://chromiumcodereview.appspot.com//9242035

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3416 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-18 21:46:27 +00:00

55 lines
1.8 KiB
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "platform/assert.h"
#include "vm/globals.h"
#include "vm/isolate.h"
#include "vm/unit_test.h"
namespace dart {
UNIT_TEST_CASE(IsolateCurrent) {
Isolate* isolate = Isolate::Init(NULL);
EXPECT_EQ(isolate, Isolate::Current());
isolate->Shutdown();
EXPECT_EQ(reinterpret_cast<Isolate*>(NULL), Isolate::Current());
delete isolate;
}
// Only ia32 and x64 can run dart execution tests.
#if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
// Unit test case to verify error during isolate spawning (application classes
// not loaded into the isolate).
TEST_CASE(IsolateSpawn) {
const char* kScriptChars =
"class SpawnNewIsolate extends Isolate {\n"
" SpawnNewIsolate() : super() { }\n"
" void main() {\n"
" }\n"
" static int testMain() {\n"
" try {\n"
" new SpawnNewIsolate().spawn().then(function(SendPort port) {\n"
" });\n"
" } catch (var e) {\n"
" throw;\n"
" }\n"
" return 0;\n"
" }\n"
"}\n";
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
Dart_Handle result = Dart_InvokeStatic(lib,
Dart_NewString("SpawnNewIsolate"),
Dart_NewString("testMain"),
0,
NULL);
EXPECT(Dart_IsError(result));
EXPECT(Dart_ErrorHasException(result));
Dart_Handle exception_result = Dart_ErrorGetException(result);
EXPECT_VALID(exception_result);
}
#endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
} // namespace dart