| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 // |h1| should no longer be readable or writable. | 130 // |h1| should no longer be readable or writable. |
| 131 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, | 131 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
| 132 MojoWait(h1, | 132 MojoWait(h1, |
| 133 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE, | 133 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE, |
| 134 1000)); | 134 1000)); |
| 135 | 135 |
| 136 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h1)); | 136 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h1)); |
| 137 } | 137 } |
| 138 | 138 |
| 139 TEST(CoreTest, BasicDataPipe) { | 139 // TODO(ncbray): enable these tests once NaCl supports the corresponding APIs. |
| 140 #ifdef __native_client__ |
| 141 #define MAYBE_BasicDataPipe DISABLED_BasicDataPipe |
| 142 #define MAYBE_BasicSharedBuffer DISABLED_BasicSharedBuffer |
| 143 #else |
| 144 #define MAYBE_BasicDataPipe BasicDataPipe |
| 145 #define MAYBE_BasicSharedBuffer BasicSharedBuffer |
| 146 #endif |
| 147 |
| 148 TEST(CoreTest, MAYBE_BasicDataPipe) { |
| 140 MojoHandle hp, hc; | 149 MojoHandle hp, hc; |
| 141 MojoHandleSignals sig; | 150 MojoHandleSignals sig; |
| 142 char buffer[20] = { 0 }; | 151 char buffer[20] = { 0 }; |
| 143 uint32_t buffer_size; | 152 uint32_t buffer_size; |
| 144 void* write_pointer; | 153 void* write_pointer; |
| 145 const void* read_pointer; | 154 const void* read_pointer; |
| 146 | 155 |
| 147 hp = MOJO_HANDLE_INVALID; | 156 hp = MOJO_HANDLE_INVALID; |
| 148 hc = MOJO_HANDLE_INVALID; | 157 hc = MOJO_HANDLE_INVALID; |
| 149 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateDataPipe(NULL, &hp, &hc)); | 158 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateDataPipe(NULL, &hp, &hc)); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // |hc| should no longer be readable. | 226 // |hc| should no longer be readable. |
| 218 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, | 227 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
| 219 MojoWait(hc, MOJO_HANDLE_SIGNAL_READABLE, 1000)); | 228 MojoWait(hc, MOJO_HANDLE_SIGNAL_READABLE, 1000)); |
| 220 | 229 |
| 221 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(hc)); | 230 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(hc)); |
| 222 | 231 |
| 223 // TODO(vtl): Test the other way around -- closing the consumer should make | 232 // TODO(vtl): Test the other way around -- closing the consumer should make |
| 224 // the producer never-writable? | 233 // the producer never-writable? |
| 225 } | 234 } |
| 226 | 235 |
| 227 TEST(CoreTest, BasicSharedBuffer) { | 236 TEST(CoreTest, MAYBE_BasicSharedBuffer) { |
| 228 MojoHandle h0, h1; | 237 MojoHandle h0, h1; |
| 229 void* pointer; | 238 void* pointer; |
| 230 | 239 |
| 231 // Create a shared buffer (|h0|). | 240 // Create a shared buffer (|h0|). |
| 232 h0 = MOJO_HANDLE_INVALID; | 241 h0 = MOJO_HANDLE_INVALID; |
| 233 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateSharedBuffer(NULL, 100, &h0)); | 242 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateSharedBuffer(NULL, 100, &h0)); |
| 234 EXPECT_NE(h0, MOJO_HANDLE_INVALID); | 243 EXPECT_NE(h0, MOJO_HANDLE_INVALID); |
| 235 | 244 |
| 236 // Map everything. | 245 // Map everything. |
| 237 pointer = NULL; | 246 pointer = NULL; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // This checks that things actually work in C (not C++). | 285 // This checks that things actually work in C (not C++). |
| 277 TEST(CoreTest, MinimalCTest) { | 286 TEST(CoreTest, MinimalCTest) { |
| 278 const char* failure = MinimalCTest(); | 287 const char* failure = MinimalCTest(); |
| 279 EXPECT_TRUE(failure == NULL) << failure; | 288 EXPECT_TRUE(failure == NULL) << failure; |
| 280 } | 289 } |
| 281 | 290 |
| 282 // TODO(vtl): Add multi-threaded tests. | 291 // TODO(vtl): Add multi-threaded tests. |
| 283 | 292 |
| 284 } // namespace | 293 } // namespace |
| 285 } // namespace mojo | 294 } // namespace mojo |
| OLD | NEW |