| OLD | NEW |
| 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> |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 EXPECT_EQ(0, close(p[0])); | 447 EXPECT_EQ(0, close(p[0])); |
| 448 EXPECT_EQ(0, close(p[1])); | 448 EXPECT_EQ(0, close(p[1])); |
| 449 | 449 |
| 450 int status; | 450 int status; |
| 451 pid_t npid = waitpid(pid, &status, 0); | 451 pid_t npid = waitpid(pid, &status, 0); |
| 452 EXPECT_EQ(pid, npid); | 452 EXPECT_EQ(pid, npid); |
| 453 EXPECT_TRUE(WIFEXITED(status)); | 453 EXPECT_TRUE(WIFEXITED(status)); |
| 454 EXPECT_EQ(42, WEXITSTATUS(status)); | 454 EXPECT_EQ(42, WEXITSTATUS(status)); |
| 455 } | 455 } |
| 456 | 456 |
| 457 extern "C" int nacl_main(int argc, char **argv) { | 457 int main(int argc, char **argv) { |
| 458 if (argc == 4 && strcmp(argv[1], "return") == 0) { | 458 if (argc == 4 && strcmp(argv[1], "return") == 0) { |
| 459 return return_child(argc, argv); | 459 return return_child(argc, argv); |
| 460 } else if (argc == 4 && strcmp(argv[1], "_exit") == 0) { | 460 } else if (argc == 4 && strcmp(argv[1], "_exit") == 0) { |
| 461 return exit_child(argc, argv); | 461 return exit_child(argc, argv); |
| 462 } else if (argc == 2 && strcmp(argv[1], "pipes") == 0) { | 462 } else if (argc == 2 && strcmp(argv[1], "pipes") == 0) { |
| 463 return pipes_child(argc, argv); | 463 return pipes_child(argc, argv); |
| 464 } else if (argc == 4 && strcmp(argv[1], "cloexec_check") == 0) { | 464 } else if (argc == 4 && strcmp(argv[1], "cloexec_check") == 0) { |
| 465 return cloexec_check_child(argc, argv); | 465 return cloexec_check_child(argc, argv); |
| 466 } else if (argc == 2 && strcmp(argv[1], "echo") == 0) { | 466 } else if (argc == 2 && strcmp(argv[1], "echo") == 0) { |
| 467 char msg[] = "test"; | 467 char msg[] = "test"; |
| 468 write(1, msg, sizeof(msg)); | 468 write(1, msg, sizeof(msg)); |
| 469 return 0; | 469 return 0; |
| 470 } | 470 } |
| 471 // Preserve argv[0] for use in some tests. | 471 // Preserve argv[0] for use in some tests. |
| 472 argv0 = argv[0]; | 472 argv0 = argv[0]; |
| 473 testing::InitGoogleTest(&argc, argv); | 473 testing::InitGoogleTest(&argc, argv); |
| 474 return RUN_ALL_TESTS(); | 474 return RUN_ALL_TESTS(); |
| 475 } | 475 } |
| OLD | NEW |