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

Side by Side Diff: native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc

Issue 412083002: [NaCl SDK] Allow ppapi_simple executables to run in both sel_ldr and in chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 // The linux host build of nacl_io can't do wrapping of syscalls so all 5 // The linux host build of nacl_io can't do wrapping of syscalls so all
6 // these tests must be disabled. 6 // these tests must be disabled.
7 #if !defined(__linux__) 7 #if !defined(__linux__)
8 8
9 #include <unistd.h> 9 #include <unistd.h>
10 10
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "gtest/gtest.h" 14 #include "gtest/gtest.h"
15 #include "mock_kernel_proxy.h" 15 #include "mock_kernel_proxy.h"
16 #include "nacl_io/kernel_intercept.h" 16 #include "nacl_io/kernel_intercept.h"
17 #include "nacl_io/kernel_wrap.h" 17 #include "nacl_io/kernel_wrap.h"
18 #include "nacl_io/kernel_wrap_real.h" 18 #include "nacl_io/kernel_wrap_real.h"
19 #include "nacl_io/osmman.h" 19 #include "nacl_io/osmman.h"
20 #include "nacl_io/ossocket.h" 20 #include "nacl_io/ossocket.h"
21 #include "nacl_io/ostermios.h" 21 #include "nacl_io/ostermios.h"
22 #include "ppapi_simple/ps.h"
22 23
23 #if defined(__native_client__) && !defined(__GLIBC__) 24 #if defined(__native_client__) && !defined(__GLIBC__)
24 extern "C" { 25 extern "C" {
25 // TODO(sbc): remove once these get added to the newlib toolchain headers. 26 // TODO(sbc): remove once these get added to the newlib toolchain headers.
26 int fchdir(int fd); 27 int fchdir(int fd);
27 int utimes(const char *filename, const struct timeval times[2]); 28 int utimes(const char *filename, const struct timeval times[2]);
28 } 29 }
29 #endif 30 #endif
30 31
31 using namespace nacl_io; 32 using namespace nacl_io;
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 EXPECT_EQ(-1, utimes(kDummyConstChar, times)); 627 EXPECT_EQ(-1, utimes(kDummyConstChar, times));
627 ASSERT_EQ(kDummyErrno, errno); 628 ASSERT_EQ(kDummyErrno, errno);
628 } 629 }
629 630
630 TEST_F(KernelWrapTest, write) { 631 TEST_F(KernelWrapTest, write) {
631 EXPECT_CALL(mock, write(kDummyInt, kDummyVoidPtr, kDummyInt2)) 632 EXPECT_CALL(mock, write(kDummyInt, kDummyVoidPtr, kDummyInt2))
632 .WillOnce(Return(kDummyInt3)); 633 .WillOnce(Return(kDummyInt3));
633 EXPECT_EQ(kDummyInt3, write(kDummyInt, kDummyVoidPtr, kDummyInt2)); 634 EXPECT_EQ(kDummyInt3, write(kDummyInt, kDummyVoidPtr, kDummyInt2));
634 } 635 }
635 636
636 #if defined SEL_LDR
637 class KernelWrapTestUninit : public ::testing::Test { 637 class KernelWrapTestUninit : public ::testing::Test {
638 void SetUp() { 638 void SetUp() {
639 ASSERT_EQ(0, ki_push_state_for_testing()); 639 ASSERT_EQ(0, ki_push_state_for_testing());
640 kernel_wrap_uninit();
640 } 641 }
641 642
642 void TearDown() { 643 void TearDown() {
644 kernel_wrap_init();
643 ki_pop_state_for_testing(); 645 ki_pop_state_for_testing();
644 } 646 }
645 }; 647 };
646 648
647 TEST_F(KernelWrapTestUninit, Mkdir_Uninitialised) { 649 TEST_F(KernelWrapTestUninit, Mkdir_Uninitialised) {
648 // If we are running within chrome we can't use these calls without 650 // If we are running within chrome we can't use these calls without
649 // nacl_io initialized. 651 // nacl_io initialized.
652 if (PSGetInstanceId() != 0)
653 return;
650 EXPECT_EQ(0, mkdir("./foo", S_IREAD | S_IWRITE)); 654 EXPECT_EQ(0, mkdir("./foo", S_IREAD | S_IWRITE));
651 EXPECT_EQ(0, rmdir("./foo")); 655 EXPECT_EQ(0, rmdir("./foo"));
652 } 656 }
653 657
654 TEST_F(KernelWrapTestUninit, Getcwd_Uninitialised) { 658 TEST_F(KernelWrapTestUninit, Getcwd_Uninitialised) {
655 // If we are running within chrome we can't use these calls without 659 // If we are running within chrome we can't use these calls without
656 // nacl_io initialized. 660 // nacl_io initialized.
661 if (PSGetInstanceId() != 0)
662 return;
657 char dir[PATH_MAX]; 663 char dir[PATH_MAX];
658 ASSERT_NE((char*)NULL, getcwd(dir, PATH_MAX)); 664 ASSERT_NE((char*)NULL, getcwd(dir, PATH_MAX));
659 // Verify that the CWD ends with 'nacl_io_test' 665 // Verify that the CWD ends with 'nacl_io_test'
660 const char* suffix = "nacl_io_test"; 666 const char* suffix = "nacl_io_test";
661 ASSERT_GT(strlen(dir), strlen(suffix)); 667 ASSERT_GT(strlen(dir), strlen(suffix));
662 ASSERT_EQ(0, strcmp(dir+strlen(dir)-strlen(suffix), suffix)); 668 ASSERT_EQ(0, strcmp(dir+strlen(dir)-strlen(suffix), suffix));
663 } 669 }
664 #endif
665 670
666 #if defined(PROVIDES_SOCKET_API) and !defined(__BIONIC__) 671 #if defined(PROVIDES_SOCKET_API) and !defined(__BIONIC__)
667 TEST_F(KernelWrapTest, poll) { 672 TEST_F(KernelWrapTest, poll) {
668 struct pollfd fds; 673 struct pollfd fds;
669 EXPECT_CALL(mock, poll(&fds, kDummyInt, kDummyInt2)) 674 EXPECT_CALL(mock, poll(&fds, kDummyInt, kDummyInt2))
670 .WillOnce(Return(kDummyInt3)); 675 .WillOnce(Return(kDummyInt3));
671 EXPECT_EQ(kDummyInt3, poll(&fds, kDummyInt, kDummyInt2)); 676 EXPECT_EQ(kDummyInt3, poll(&fds, kDummyInt, kDummyInt2));
672 } 677 }
673 678
674 TEST_F(KernelWrapTest, select) { 679 TEST_F(KernelWrapTest, select) {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 .WillOnce(Return(0)) 893 .WillOnce(Return(0))
889 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); 894 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1)));
890 EXPECT_EQ(0, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val)); 895 EXPECT_EQ(0, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val));
891 EXPECT_EQ(-1, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val)); 896 EXPECT_EQ(-1, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val));
892 EXPECT_EQ(kDummyErrno, errno); 897 EXPECT_EQ(kDummyErrno, errno);
893 } 898 }
894 899
895 #endif // PROVIDES_SOCKET_API 900 #endif // PROVIDES_SOCKET_API
896 901
897 #endif // __linux__ 902 #endif // __linux__
OLDNEW
« no previous file with comments | « native_client_sdk/src/tests/nacl_io_socket_test/main.cc ('k') | native_client_sdk/src/tests/nacl_io_test/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698