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

Unified Diff: native_client_sdk/src/libraries/nacl_mounts_test/kernel_intercept_test.cc

Issue 11066105: [NaCl SDK] nacl_mounts: wrap functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win fix Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/nacl_mounts_test/kernel_intercept_test.cc
diff --git a/native_client_sdk/src/libraries/nacl_mounts_test/kernel_intercept_test.cc b/native_client_sdk/src/libraries/nacl_mounts_test/kernel_intercept_test.cc
deleted file mode 100644
index 3b6657a5340321ff2f4800455e3f6d14c45136f7..0000000000000000000000000000000000000000
--- a/native_client_sdk/src/libraries/nacl_mounts_test/kernel_intercept_test.cc
+++ /dev/null
@@ -1,189 +0,0 @@
-/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <fcntl.h>
-#include <pthread.h>
-
-#include <map>
-#include <string>
-
-#include "nacl_mounts/kernel_intercept.h"
-#include "nacl_mounts/kernel_proxy.h"
-#include "nacl_mounts/path.h"
-
-#include "gtest/gtest.h"
-
-class KernelProxyMock : public KernelProxy {
- public:
- KernelProxyMock() {}
- virtual ~KernelProxyMock() {}
-
- virtual int chdir(const char* path) {
- events.push_back("chdir");
- return 0;
- }
- virtual char* getcwd(char* buf, size_t size) {
- events.push_back("getcwd");
- return buf;
- }
- virtual char* getwd(char* buf) {
- events.push_back("getwd");
- return buf;
- }
- virtual int dup(int oldfd) {
- events.push_back("dup");
- return oldfd;
- }
- virtual int chmod(const char *path, mode_t mode) {
- events.push_back("chmod");
- return 0;
- }
- virtual int stat(const char *path, struct stat *buf) {
- events.push_back("stat");
- return 0;
- }
- virtual int mkdir(const char *path, mode_t mode) {
- events.push_back("mkdir");
- return 0;
- }
- virtual int rmdir(const char *path) {
- events.push_back("rmdir");
- return 0;
- }
- virtual int mount(const char *source, const char *target,
- const char *filesystemtype, unsigned long mountflags, const void *data) {
- events.push_back("mount");
- return 0;
- }
- virtual int umount(const char *path) {
- events.push_back("umount");
- return 0;
- }
- virtual int open(const char *path, int oflag) {
- events.push_back("open");
- return 0;
- }
- virtual ssize_t read(int fd, void *buf, size_t nbyte) {
- events.push_back("read");
- return 0;
- }
- virtual ssize_t write(int fd, const void *buf, size_t nbyte) {
- events.push_back("write");
- return 0;
- }
- virtual int fstat(int fd, struct stat *buf) {
- events.push_back("fstat");
- return 0;
- }
- virtual int getdents(int fd, void *buf, unsigned int count) {
- events.push_back("getdents");
- return 0;
- }
- virtual int fsync(int fd) {
- events.push_back("fsync");
- return 0;
- }
- virtual int isatty(int fd) {
- events.push_back("isatty");
- return 0;
- }
- virtual int close(int fd) {
- events.push_back("close");
- return 0;
- }
- virtual off_t lseek(int fd, off_t offset, int whence) {
- events.push_back("lseek");
- return 0;
- }
- virtual int remove(const char* path) {
- events.push_back("remove");
- return 0;
- }
- virtual int unlink(const char* path) {
- events.push_back("unlink");
- return 0;
- }
- virtual int access(const char* path, int amode) {
- events.push_back("access");
- return 0;
- }
-
- std::string& LastStr() {
- return events.back();
- }
-
- std::vector<std::string> events;
-};
-
-
-TEST(KernelIntercept, SanityChecks) {
- static KernelProxyMock* mock = new KernelProxyMock();
- ki_init(mock);
-
- ki_chdir("foo");
- EXPECT_EQ("chdir", mock->LastStr());
-
- char getcwd_buffer[] = "foo";
- ki_getcwd(getcwd_buffer, 1);
- EXPECT_EQ("getcwd", mock->LastStr());
-
- char getwd_buffer[] = "foo";
- ki_getwd(getwd_buffer);
- EXPECT_EQ("getwd", mock->LastStr());
-
- ki_dup(1);
- EXPECT_EQ("dup", mock->LastStr());
-
- ki_chmod("foo", 0);
- EXPECT_EQ("chmod", mock->LastStr());
-
- ki_stat("foo", NULL);
- EXPECT_EQ("stat", mock->LastStr());
-
- ki_mkdir("foo", 0);
- EXPECT_EQ("mkdir", mock->LastStr());
-
- ki_rmdir("foo");
- EXPECT_EQ("rmdir", mock->LastStr());
-
- ki_mount("foo", "bar", NULL, 0, NULL);
- EXPECT_EQ("mount", mock->LastStr());
-
- ki_umount("foo");
- EXPECT_EQ("umount", mock->LastStr());
-
- ki_open("foo", 0);
- EXPECT_EQ("open", mock->LastStr());
-
- ki_read(1, NULL, 0);
- EXPECT_EQ("read", mock->LastStr());
-
- ki_write(1, NULL, 0);
- EXPECT_EQ("write", mock->LastStr());
-
- ki_fstat(1, NULL);
- EXPECT_EQ("fstat", mock->LastStr());
-
- ki_getdents(1, NULL, 0);
- EXPECT_EQ("getdents", mock->LastStr());
-
- ki_fsync(1);
- EXPECT_EQ("fsync", mock->LastStr());
-
- ki_isatty(1);
- EXPECT_EQ("isatty", mock->LastStr());
-
- ki_close(1);
- EXPECT_EQ("close", mock->LastStr());
-
- ki_remove("foo");
- EXPECT_EQ("fsync", mock->LastStr());
-
- ki_unlink("foo");
- EXPECT_EQ("isatty", mock->LastStr());
-
- ki_access("foo", 0);
- EXPECT_EQ("close", mock->LastStr());
-}

Powered by Google App Engine
This is Rietveld 408576698