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

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

Issue 474433005: [NaCl SDK] Remove syscalls wrappers for chmod and unlink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 EXPECT_EQ(0, chdir(kDummyConstChar)); 181 EXPECT_EQ(0, chdir(kDummyConstChar));
182 182
183 EXPECT_CALL(mock, chdir(kDummyConstChar)) 183 EXPECT_CALL(mock, chdir(kDummyConstChar))
184 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); 184 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1)));
185 EXPECT_EQ(-1, chdir(kDummyConstChar)); 185 EXPECT_EQ(-1, chdir(kDummyConstChar));
186 ASSERT_EQ(kDummyErrno, errno); 186 ASSERT_EQ(kDummyErrno, errno);
187 } 187 }
188 188
189 TEST_F(KernelWrapTest, chmod) { 189 TEST_F(KernelWrapTest, chmod) {
190 EXPECT_CALL(mock, chmod(kDummyConstChar, kDummyMode)) 190 EXPECT_CALL(mock, chmod(kDummyConstChar, kDummyMode))
191 .WillOnce(Return(kDummyInt2)); 191 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1)));
192 EXPECT_EQ(kDummyInt2,chmod(kDummyConstChar, kDummyMode)); 192 EXPECT_EQ(-1, chmod(kDummyConstChar, kDummyMode));
193 ASSERT_EQ(kDummyErrno, errno);
193 } 194 }
194 195
195 TEST_F(KernelWrapTest, chown) { 196 TEST_F(KernelWrapTest, chown) {
196 EXPECT_CALL(mock, chown(kDummyConstChar, kDummyUid, kDummyGid)) 197 EXPECT_CALL(mock, chown(kDummyConstChar, kDummyUid, kDummyGid))
197 .WillOnce(Return(kDummyInt)); 198 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1)));
198 EXPECT_EQ(kDummyInt, chown(kDummyConstChar, kDummyUid, kDummyGid)); 199 EXPECT_EQ(-1, chown(kDummyConstChar, kDummyUid, kDummyGid));
200 ASSERT_EQ(kDummyErrno, errno);
199 } 201 }
200 202
201 TEST_F(KernelWrapTest, close) { 203 TEST_F(KernelWrapTest, close) {
202 // The way we wrap close does not support returning arbitrary values, so we 204 // The way we wrap close does not support returning arbitrary values, so we
203 // test 0 and -1. 205 // test 0 and -1.
204 EXPECT_CALL(mock, close(kDummyInt)) 206 EXPECT_CALL(mock, close(kDummyInt))
205 .WillOnce(Return(0)); 207 .WillOnce(Return(0));
206 208
207 EXPECT_EQ(0, close(kDummyInt)); 209 EXPECT_EQ(0, close(kDummyInt));
208 210
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 } 367 }
366 368
367 TEST_F(KernelWrapTest, lchown) { 369 TEST_F(KernelWrapTest, lchown) {
368 EXPECT_CALL(mock, lchown(kDummyConstChar, kDummyUid, kDummyGid)) 370 EXPECT_CALL(mock, lchown(kDummyConstChar, kDummyUid, kDummyGid))
369 .WillOnce(Return(kDummyInt)); 371 .WillOnce(Return(kDummyInt));
370 EXPECT_EQ(kDummyInt, lchown(kDummyConstChar, kDummyUid, kDummyGid)); 372 EXPECT_EQ(kDummyInt, lchown(kDummyConstChar, kDummyUid, kDummyGid));
371 } 373 }
372 374
373 TEST_F(KernelWrapTest, link) { 375 TEST_F(KernelWrapTest, link) {
374 EXPECT_CALL(mock, link(kDummyConstChar, kDummyConstChar2)) 376 EXPECT_CALL(mock, link(kDummyConstChar, kDummyConstChar2))
375 .WillOnce(Return(kDummyInt)); 377 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1)));
376 EXPECT_EQ(kDummyInt, link(kDummyConstChar, kDummyConstChar2)); 378 EXPECT_EQ(-1, link(kDummyConstChar, kDummyConstChar2));
379 ASSERT_EQ(kDummyErrno, errno);
377 } 380 }
378 381
379 TEST_F(KernelWrapTest, lseek) { 382 TEST_F(KernelWrapTest, lseek) {
380 EXPECT_CALL(mock, lseek(kDummyInt, kDummyInt2, kDummyInt3)) 383 EXPECT_CALL(mock, lseek(kDummyInt, kDummyInt2, kDummyInt3))
381 .WillOnce(Return(kDummyInt4)); 384 .WillOnce(Return(kDummyInt4));
382 EXPECT_EQ(kDummyInt4, lseek(kDummyInt, kDummyInt2, kDummyInt3)); 385 EXPECT_EQ(kDummyInt4, lseek(kDummyInt, kDummyInt2, kDummyInt3));
383 } 386 }
384 387
385 TEST_F(KernelWrapTest, mkdir) { 388 TEST_F(KernelWrapTest, mkdir) {
386 #if defined(WIN32) 389 #if defined(WIN32)
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 EXPECT_EQ(-1, utimes(kDummyConstChar, times)); 626 EXPECT_EQ(-1, utimes(kDummyConstChar, times));
624 ASSERT_EQ(kDummyErrno, errno); 627 ASSERT_EQ(kDummyErrno, errno);
625 } 628 }
626 629
627 TEST_F(KernelWrapTest, write) { 630 TEST_F(KernelWrapTest, write) {
628 EXPECT_CALL(mock, write(kDummyInt, kDummyVoidPtr, kDummyInt2)) 631 EXPECT_CALL(mock, write(kDummyInt, kDummyVoidPtr, kDummyInt2))
629 .WillOnce(Return(kDummyInt3)); 632 .WillOnce(Return(kDummyInt3));
630 EXPECT_EQ(kDummyInt3, write(kDummyInt, kDummyVoidPtr, kDummyInt2)); 633 EXPECT_EQ(kDummyInt3, write(kDummyInt, kDummyVoidPtr, kDummyInt2));
631 } 634 }
632 635
636 #if defined SEL_LDR
637 class KernelWrapTestUninit : public ::testing::Test {
638 void SetUp() {
639 ASSERT_EQ(0, ki_push_state_for_testing());
640 }
641
642 void TearDown() {
643 ki_pop_state_for_testing();
644 }
645 };
646
647 TEST_F(KernelWrapTestUninit, Mkdir_Uninitialised) {
648 // If we are running within chrome we can't use these calls without
649 // nacl_io initialized.
650 EXPECT_EQ(0, mkdir("./foo", S_IREAD | S_IWRITE));
651 EXPECT_EQ(0, rmdir("./foo"));
652 }
653
654 TEST_F(KernelWrapTestUninit, Getcwd_Uninitialised) {
655 // If we are running within chrome we can't use these calls without
656 // nacl_io initialized.
657 char dir[PATH_MAX];
658 ASSERT_NE((char*)NULL, getcwd(dir, 1024));
binji 2014/08/20 18:13:35 PATH_MAX?
Sam Clegg 2014/08/21 10:19:34 Done.
659 // Verify that the CWD ends with 'nacl_io_test'
660 const char* suffix = "nacl_io_test";
binji 2014/08/20 18:13:35 hm, seems like a fragile test. There's no reason w
Sam Clegg 2014/08/21 10:19:34 Got any better ideas? My goal here is to check th
661 ASSERT_GT(strlen(dir), strlen(suffix));
662 ASSERT_EQ(0, strcmp(dir+strlen(dir)-strlen(suffix), suffix));
663 }
664 #endif
665
633 #if defined(PROVIDES_SOCKET_API) and !defined(__BIONIC__) 666 #if defined(PROVIDES_SOCKET_API) and !defined(__BIONIC__)
634 TEST_F(KernelWrapTest, poll) { 667 TEST_F(KernelWrapTest, poll) {
635 struct pollfd fds; 668 struct pollfd fds;
636 EXPECT_CALL(mock, poll(&fds, kDummyInt, kDummyInt2)) 669 EXPECT_CALL(mock, poll(&fds, kDummyInt, kDummyInt2))
637 .WillOnce(Return(kDummyInt3)); 670 .WillOnce(Return(kDummyInt3));
638 EXPECT_EQ(kDummyInt3, poll(&fds, kDummyInt, kDummyInt2)); 671 EXPECT_EQ(kDummyInt3, poll(&fds, kDummyInt, kDummyInt2));
639 } 672 }
640 673
641 TEST_F(KernelWrapTest, select) { 674 TEST_F(KernelWrapTest, select) {
642 fd_set readfds; 675 fd_set readfds;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 .WillOnce(Return(0)) 888 .WillOnce(Return(0))
856 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); 889 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1)));
857 EXPECT_EQ(0, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val)); 890 EXPECT_EQ(0, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val));
858 EXPECT_EQ(-1, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val)); 891 EXPECT_EQ(-1, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val));
859 EXPECT_EQ(kDummyErrno, errno); 892 EXPECT_EQ(kDummyErrno, errno);
860 } 893 }
861 894
862 #endif // PROVIDES_SOCKET_API 895 #endif // PROVIDES_SOCKET_API
863 896
864 #endif // __linux__ 897 #endif // __linux__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698