OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file tests the C API. | 5 // This file tests the C API. |
6 | 6 |
7 #include "mojo/public/c/system/core.h" | 7 #include "mojo/public/c/system/core.h" |
8 | 8 |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 // |h1| should no longer be readable or writable. | 134 // |h1| should no longer be readable or writable. |
135 EXPECT_EQ( | 135 EXPECT_EQ( |
136 MOJO_RESULT_FAILED_PRECONDITION, | 136 MOJO_RESULT_FAILED_PRECONDITION, |
137 MojoWait( | 137 MojoWait( |
138 h1, MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE, 1000)); | 138 h1, MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE, 1000)); |
139 | 139 |
140 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h1)); | 140 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h1)); |
141 } | 141 } |
142 | 142 |
143 TEST(CoreTest, BasicDataPipe) { | 143 // TODO(ncbray): enable these tests once NaCl supports the corresponding APIs. |
| 144 #ifdef __native_client__ |
| 145 #define MAYBE_BasicDataPipe DISABLED_BasicDataPipe |
| 146 #define MAYBE_BasicSharedBuffer DISABLED_BasicSharedBuffer |
| 147 #else |
| 148 #define MAYBE_BasicDataPipe BasicDataPipe |
| 149 #define MAYBE_BasicSharedBuffer BasicSharedBuffer |
| 150 #endif |
| 151 |
| 152 TEST(CoreTest, MAYBE_BasicDataPipe) { |
144 MojoHandle hp, hc; | 153 MojoHandle hp, hc; |
145 MojoHandleSignals sig; | 154 MojoHandleSignals sig; |
146 char buffer[20] = {0}; | 155 char buffer[20] = {0}; |
147 uint32_t buffer_size; | 156 uint32_t buffer_size; |
148 void* write_pointer; | 157 void* write_pointer; |
149 const void* read_pointer; | 158 const void* read_pointer; |
150 | 159 |
151 hp = MOJO_HANDLE_INVALID; | 160 hp = MOJO_HANDLE_INVALID; |
152 hc = MOJO_HANDLE_INVALID; | 161 hc = MOJO_HANDLE_INVALID; |
153 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateDataPipe(NULL, &hp, &hc)); | 162 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateDataPipe(NULL, &hp, &hc)); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // |hc| should no longer be readable. | 230 // |hc| should no longer be readable. |
222 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, | 231 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
223 MojoWait(hc, MOJO_HANDLE_SIGNAL_READABLE, 1000)); | 232 MojoWait(hc, MOJO_HANDLE_SIGNAL_READABLE, 1000)); |
224 | 233 |
225 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(hc)); | 234 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(hc)); |
226 | 235 |
227 // TODO(vtl): Test the other way around -- closing the consumer should make | 236 // TODO(vtl): Test the other way around -- closing the consumer should make |
228 // the producer never-writable? | 237 // the producer never-writable? |
229 } | 238 } |
230 | 239 |
231 TEST(CoreTest, BasicSharedBuffer) { | 240 TEST(CoreTest, MAYBE_BasicSharedBuffer) { |
232 MojoHandle h0, h1; | 241 MojoHandle h0, h1; |
233 void* pointer; | 242 void* pointer; |
234 | 243 |
235 // Create a shared buffer (|h0|). | 244 // Create a shared buffer (|h0|). |
236 h0 = MOJO_HANDLE_INVALID; | 245 h0 = MOJO_HANDLE_INVALID; |
237 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateSharedBuffer(NULL, 100, &h0)); | 246 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateSharedBuffer(NULL, 100, &h0)); |
238 EXPECT_NE(h0, MOJO_HANDLE_INVALID); | 247 EXPECT_NE(h0, MOJO_HANDLE_INVALID); |
239 | 248 |
240 // Map everything. | 249 // Map everything. |
241 pointer = NULL; | 250 pointer = NULL; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 // This checks that things actually work in C (not C++). | 289 // This checks that things actually work in C (not C++). |
281 TEST(CoreTest, MinimalCTest) { | 290 TEST(CoreTest, MinimalCTest) { |
282 const char* failure = MinimalCTest(); | 291 const char* failure = MinimalCTest(); |
283 EXPECT_TRUE(failure == NULL) << failure; | 292 EXPECT_TRUE(failure == NULL) << failure; |
284 } | 293 } |
285 | 294 |
286 // TODO(vtl): Add multi-threaded tests. | 295 // TODO(vtl): Add multi-threaded tests. |
287 | 296 |
288 } // namespace | 297 } // namespace |
289 } // namespace mojo | 298 } // namespace mojo |
OLD | NEW |