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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 2651633002: VM: [Kernel] Fix bootstraping when Kernel isolate is used. (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/dart_api_impl_test.cc
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index 037fb4bb06dc8e4db77c61f04165539c524099dd..6542a75e5fc96b3762c20ee9e31aa71d6945be4e 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -7148,12 +7148,19 @@ TEST_CASE(ImportLibrary5) {
}
-void NewNativePort_send123(Dart_Port dest_port_id, Dart_CObject* message) {
+void NewNativePort_send123(Dart_Port dest_port_id,
+ Dart_CObject* message,
+ void* peer) {
// Gets a send port message.
EXPECT_NOTNULL(message);
EXPECT_EQ(Dart_CObject_kArray, message->type);
EXPECT_EQ(Dart_CObject_kSendPort, message->value.as_array.values[0]->type);
+ // Check peer validity.
+ EXPECT_NOTNULL(peer);
+ EXPECT_EQ(0xDEADBEEF, *static_cast<intptr_t*>(peer));
+ *static_cast<intptr_t*>(peer) = 123;
+
// Post integer value.
Dart_CObject* response =
reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject)));
@@ -7164,12 +7171,19 @@ void NewNativePort_send123(Dart_Port dest_port_id, Dart_CObject* message) {
}
-void NewNativePort_send321(Dart_Port dest_port_id, Dart_CObject* message) {
+void NewNativePort_send321(Dart_Port dest_port_id,
+ Dart_CObject* message,
+ void* peer) {
// Gets a null message.
EXPECT_NOTNULL(message);
EXPECT_EQ(Dart_CObject_kArray, message->type);
EXPECT_EQ(Dart_CObject_kSendPort, message->value.as_array.values[0]->type);
+ // Check peer validity.
+ EXPECT_NOTNULL(peer);
+ EXPECT_EQ(0xDEADBEEF, *static_cast<intptr_t*>(peer));
+ *static_cast<intptr_t*>(peer) = 321;
+
// Post integer value.
Dart_CObject* response =
reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject)));
@@ -7196,12 +7210,13 @@ TEST_CASE(IllegalPost) {
UNIT_TEST_CASE(NewNativePort) {
// Create a port with a bogus handler.
- Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true);
+ Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true, NULL);
EXPECT_EQ(ILLEGAL_PORT, error_port);
+ intptr_t peer1 = 0xDEADBEEF;
// Create the port w/o a current isolate, just to make sure that works.
Dart_Port port_id1 =
- Dart_NewNativePort("Port123", NewNativePort_send123, true);
+ Dart_NewNativePort("Port123", NewNativePort_send123, true, &peer1);
TestIsolateScope __test_isolate__;
const char* kScriptChars =
@@ -7219,8 +7234,9 @@ UNIT_TEST_CASE(NewNativePort) {
Dart_EnterScope();
// Create a port w/ a current isolate, to make sure that works too.
+ intptr_t peer2 = 0xDEADBEEF;
Dart_Port port_id2 =
- Dart_NewNativePort("Port321", NewNativePort_send321, true);
+ Dart_NewNativePort("Port321", NewNativePort_send321, true, &peer2);
Dart_Handle send_port1 = Dart_NewSendPort(port_id1);
EXPECT_VALID(send_port1);
@@ -7236,6 +7252,7 @@ UNIT_TEST_CASE(NewNativePort) {
EXPECT(Dart_IsError(result));
EXPECT(Dart_ErrorHasException(result));
EXPECT_SUBSTRING("Exception: 123\n", Dart_GetError(result));
+ EXPECT_EQ(123, peer1);
// result second port.
dart_args[0] = send_port2;
@@ -7245,6 +7262,7 @@ UNIT_TEST_CASE(NewNativePort) {
EXPECT(Dart_IsError(result));
EXPECT(Dart_ErrorHasException(result));
EXPECT_SUBSTRING("Exception: 321\n", Dart_GetError(result));
+ EXPECT_EQ(321, peer2);
Dart_ExitScope();
@@ -7255,7 +7273,8 @@ UNIT_TEST_CASE(NewNativePort) {
void NewNativePort_sendInteger123(Dart_Port dest_port_id,
- Dart_CObject* message) {
+ Dart_CObject* message,
+ void* peer) {
// Gets a send port message.
EXPECT_NOTNULL(message);
EXPECT_EQ(Dart_CObject_kArray, message->type);
@@ -7268,7 +7287,8 @@ void NewNativePort_sendInteger123(Dart_Port dest_port_id,
void NewNativePort_sendInteger321(Dart_Port dest_port_id,
- Dart_CObject* message) {
+ Dart_CObject* message,
+ void* peer) {
// Gets a null message.
EXPECT_NOTNULL(message);
EXPECT_EQ(Dart_CObject_kArray, message->type);
@@ -7296,9 +7316,9 @@ TEST_CASE(NativePortPostInteger) {
Dart_EnterScope();
Dart_Port port_id1 =
- Dart_NewNativePort("Port123", NewNativePort_sendInteger123, true);
+ Dart_NewNativePort("Port123", NewNativePort_sendInteger123, true, NULL);
Dart_Port port_id2 =
- Dart_NewNativePort("Port321", NewNativePort_sendInteger321, true);
+ Dart_NewNativePort("Port321", NewNativePort_sendInteger321, true, NULL);
Dart_Handle send_port1 = Dart_NewSendPort(port_id1);
EXPECT_VALID(send_port1);
@@ -7333,7 +7353,8 @@ TEST_CASE(NativePortPostInteger) {
void NewNativePort_nativeReceiveNull(Dart_Port dest_port_id,
- Dart_CObject* message) {
+ Dart_CObject* message,
+ void* peer) {
EXPECT_NOTNULL(message);
if ((message->type == Dart_CObject_kArray) &&
@@ -7363,8 +7384,8 @@ TEST_CASE(NativePortReceiveNull) {
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
Dart_EnterScope();
- Dart_Port port_id1 =
- Dart_NewNativePort("PortNull", NewNativePort_nativeReceiveNull, true);
+ Dart_Port port_id1 = Dart_NewNativePort(
+ "PortNull", NewNativePort_nativeReceiveNull, true, NULL);
Dart_Handle send_port1 = Dart_NewSendPort(port_id1);
EXPECT_VALID(send_port1);
@@ -7386,7 +7407,8 @@ TEST_CASE(NativePortReceiveNull) {
void NewNativePort_nativeReceiveInteger(Dart_Port dest_port_id,
- Dart_CObject* message) {
+ Dart_CObject* message,
+ void* peer) {
EXPECT_NOTNULL(message);
if ((message->type == Dart_CObject_kArray) &&
@@ -7417,8 +7439,8 @@ TEST_CASE(NativePortReceiveInteger) {
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
Dart_EnterScope();
- Dart_Port port_id1 =
- Dart_NewNativePort("PortNull", NewNativePort_nativeReceiveInteger, true);
+ Dart_Port port_id1 = Dart_NewNativePort(
+ "PortNull", NewNativePort_nativeReceiveInteger, true, NULL);
Dart_Handle send_port1 = Dart_NewSendPort(port_id1);
EXPECT_VALID(send_port1);

Powered by Google App Engine
This is Rietveld 408576698