Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 4 | |
| 5 | #ifndef LIBRARIES_NACL_IO_TEST_KERNEL_PROXY_MOCK_H_ |
| 6 | #define LIBRARIES_NACL_IO_TEST_KERNEL_PROXY_MOCK_H_ |
| 7 | |
| 8 | #include <sys/types.h> |
| 9 | #include <sys/stat.h> |
| 10 | #include "gmock/gmock.h" |
| 11 | |
| 12 | #include "nacl_io/kernel_proxy.h" |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 13 | #include "nacl_io/ossocket.h" |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 14 | #include "nacl_io/ostermios.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 15 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 16 | class KernelProxyMock : public nacl_io::KernelProxy { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 17 | public: |
| 18 | KernelProxyMock(); |
| 19 | virtual ~KernelProxyMock(); |
| 20 | |
| 21 | MOCK_METHOD2(access, int(const char*, int)); |
| 22 | MOCK_METHOD1(chdir, int(const char*)); |
| 23 | MOCK_METHOD2(chmod, int(const char*, mode_t)); |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 24 | MOCK_METHOD3(chown, int(const char*, uid_t, gid_t)); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 25 | MOCK_METHOD1(close, int(int)); |
| 26 | MOCK_METHOD1(dup, int(int)); |
| 27 | MOCK_METHOD2(dup2, int(int, int)); |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 28 | MOCK_METHOD3(fchown, int(int, uid_t, gid_t)); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 29 | MOCK_METHOD2(ftruncate, int(int, off_t)); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 30 | MOCK_METHOD2(fstat, int(int, struct stat*)); |
| 31 | MOCK_METHOD1(fsync, int(int)); |
| 32 | MOCK_METHOD2(getcwd, char*(char*, size_t)); |
| 33 | MOCK_METHOD3(getdents, int(int, void*, unsigned int)); |
| 34 | MOCK_METHOD1(getwd, char*(char*)); |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 35 | MOCK_METHOD3(ioctl, int(int, int, char*)); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 36 | MOCK_METHOD1(isatty, int(int)); |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 37 | MOCK_METHOD3(lchown, int(const char*, uid_t, gid_t)); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 38 | MOCK_METHOD3(lseek, off_t(int, off_t, int)); |
| 39 | MOCK_METHOD2(mkdir, int(const char*, mode_t)); |
| 40 | MOCK_METHOD5(mount, int(const char*, const char*, const char*, unsigned long, |
| 41 | const void*)); |
| 42 | MOCK_METHOD2(open, int(const char*, int)); |
| 43 | MOCK_METHOD3(read, ssize_t(int, void*, size_t)); |
| 44 | MOCK_METHOD1(remove, int(const char*)); |
| 45 | MOCK_METHOD1(rmdir, int(const char*)); |
| 46 | MOCK_METHOD2(stat, int(const char*, struct stat*)); |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 47 | MOCK_METHOD2(tcgetattr, int(int, struct termios*)); |
| 48 | MOCK_METHOD3(tcsetattr, int(int, int, const struct termios*)); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 49 | MOCK_METHOD1(umount, int(const char*)); |
| 50 | MOCK_METHOD1(unlink, int(const char*)); |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 51 | MOCK_METHOD2(utime, int(const char*, const struct utimbuf*)); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 52 | MOCK_METHOD3(write, ssize_t(int, const void*, size_t)); |
| 53 | MOCK_METHOD2(link, int(const char*, const char*)); |
| 54 | MOCK_METHOD2(symlink, int(const char*, const char*)); |
| 55 | MOCK_METHOD6(mmap, void*(void*, size_t, int, int, int, size_t)); |
| 56 | MOCK_METHOD1(open_resource, int(const char*)); |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 57 | |
| 58 | #ifdef PROVIDES_SOCKET_API |
Ben Murdoch | 3240926 | 2013-08-07 11:04:47 +0100 | [diff] [blame] | 59 | MOCK_METHOD3(poll, int(struct pollfd*, nfds_t, int)); |
| 60 | MOCK_METHOD5(select, int(int, fd_set*, fd_set*, fd_set*, struct timeval*)); |
| 61 | |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 62 | // Socket support functions |
| 63 | MOCK_METHOD3(accept, int(int, struct sockaddr*, socklen_t*)); |
| 64 | MOCK_METHOD3(bind, int(int, const struct sockaddr*, socklen_t)); |
| 65 | MOCK_METHOD3(connect, int(int, const struct sockaddr*, socklen_t)); |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 66 | MOCK_METHOD1(gethostbyname, struct hostent*(const char*)); |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 67 | MOCK_METHOD3(getpeername, int(int, struct sockaddr*, socklen_t*)); |
| 68 | MOCK_METHOD3(getsockname, int(int, struct sockaddr*, socklen_t*)); |
| 69 | MOCK_METHOD5(getsockopt, int(int, int, int, void*, socklen_t*)); |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 70 | MOCK_METHOD1(herror, void(const char*)); |
| 71 | MOCK_METHOD1(hstrerror, const char*(int)); |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 72 | MOCK_METHOD2(listen, int(int, int)); |
| 73 | MOCK_METHOD4(recv, ssize_t(int, void*, size_t, int)); |
| 74 | MOCK_METHOD6(recvfrom, ssize_t(int, void*, size_t, int, |
| 75 | struct sockaddr*, socklen_t*)); |
| 76 | MOCK_METHOD3(recvmsg, ssize_t(int, struct msghdr*, int)); |
| 77 | MOCK_METHOD4(send, ssize_t(int, const void*, size_t, int)); |
| 78 | MOCK_METHOD6(sendto, ssize_t(int, const void*, size_t, int, |
| 79 | const struct sockaddr*, socklen_t)); |
| 80 | MOCK_METHOD3(sendmsg, ssize_t(int, const struct msghdr*, int)); |
| 81 | MOCK_METHOD5(setsockopt, int(int, int, int, const void*, socklen_t)); |
| 82 | MOCK_METHOD2(shutdown, int(int, int)); |
| 83 | MOCK_METHOD3(socket, int(int, int, int)); |
| 84 | MOCK_METHOD4(socketpair, int(int, int, int, int*)); |
| 85 | #endif // PROVIDES_SOCKET_API |
| 86 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | #endif // LIBRARIES_NACL_IO_TEST_KERNEL_PROXY_MOCK_H_ |