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

Side by Side Diff: ports/devenv/tests/devenv_small_test.cc

Issue 1742043002: Make M-x shell work in emacs. (Closed) Base URL: https://chromium.googlesource.com/webports.git@master
Patch Set: fixes Created 4 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
OLDNEW
1 // Copyright (c) 2014 The Native Client Authors. All rights reserved. 1 // Copyright (c) 2014 The Native Client 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 #include "gtest/gtest.h" 5 #include "gtest/gtest.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <spawn.h> 9 #include <spawn.h>
10 #include <unistd.h> 10 #include <unistd.h>
11 11
12 #define pipe nacl_spawn_pipe
13
12 static char *argv0; 14 static char *argv0;
13 15
14 // Make sure that the plumbing works. 16 // Make sure that the plumbing works.
15 TEST(Plumbing, Identity) { 17 TEST(Plumbing, Identity) {
16 EXPECT_EQ(0, 0); 18 EXPECT_EQ(0, 0);
17 } 19 }
18 20
19 // Test process functions. 21 // Test process functions.
20 TEST(Plumbing, ProcessTests) { 22 TEST(Plumbing, ProcessTests) {
21 int pid = getpid(); 23 int pid = getpid();
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 ASSERT_EQ(1, dup2(pipes[1], 1)); 272 ASSERT_EQ(1, dup2(pipes[1], 1));
271 EXPECT_EQ(0, close(pipes[0])); 273 EXPECT_EQ(0, close(pipes[0]));
272 execlp(argv0, argv0, "echo", NULL); 274 execlp(argv0, argv0, "echo", NULL);
273 } 275 }
274 276
275 EXPECT_EQ(0, close(pipes[1])); 277 EXPECT_EQ(0, close(pipes[1]));
276 char check_msg[] = "test"; 278 char check_msg[] = "test";
277 char buffer[100]; 279 char buffer[100];
278 size_t total = 0; 280 size_t total = 0;
279 while (total < strlen(check_msg)) { 281 while (total < strlen(check_msg)) {
280 ssize_t len = read(pipes[0], buffer+total, sizeof(buffer)); 282 ssize_t len = read(pipes[0], buffer + total, sizeof(buffer));
281 ASSERT_GE(len, 0); 283 ASSERT_GE(len, 0);
282 if (len == 0) break; 284 if (len == 0) break;
283 total += len; 285 total += len;
284 } 286 }
285 ASSERT_EQ(0, memcmp(buffer, check_msg, total)); 287 ASSERT_EQ(0, memcmp(buffer, check_msg, total));
286 EXPECT_EQ(0, close(pipes[0])); 288 EXPECT_EQ(0, close(pipes[0]));
287 } 289 }
288 290
289 // Write to an echo process, close immediately, then wait for reply. 291 // Write to an echo process, close immediately, then wait for reply.
290 TEST(Pipes, PipeFastClose) { 292 TEST(Pipes, PipeFastClose) {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 } 506 }
505 printf("unknown child_command: %s\n", child_command); 507 printf("unknown child_command: %s\n", child_command);
506 return 1; 508 return 1;
507 } 509 }
508 510
509 // Preserve argv[0] for use in some tests. 511 // Preserve argv[0] for use in some tests.
510 argv0 = argv[0]; 512 argv0 = argv[0];
511 testing::InitGoogleTest(&argc, argv); 513 testing::InitGoogleTest(&argc, argv);
512 return RUN_ALL_TESTS(); 514 return RUN_ALL_TESTS();
513 } 515 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698