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

Unified Diff: native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc

Issue 304013002: [NaCl SDK] Create Filesystem nodes in /dev/fs/... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/tests/nacl_io_test/kernel_proxy_test.cc
diff --git a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
index ffa4eeef9e7c197e6af0ee73dfd2149b8448235a..98fd431ea8fb1a437bbe925747eafae3586061c4 100644
--- a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
@@ -542,18 +542,27 @@ TEST_F(KernelProxyTest, UseAfterClose) {
namespace {
StringMap_t g_string_map;
+bool g_fs_ioctl_called;
+int g_fs_dev;
class KernelProxyMountTest_Filesystem : public MemFs {
public:
- using MemFs::Init;
-
virtual Error Init(const FsInitArgs& args) {
+ MemFs::Init(args);
+
g_string_map = args.string_map;
+ g_fs_dev = args.dev;
+
if (g_string_map.find("false") != g_string_map.end())
return EINVAL;
return 0;
}
+ virtual Error Filesystem_VIoctl(int request, va_list arglist) {
+ g_fs_ioctl_called = true;
+ return 0;
+ }
+
friend class TypedFsFactory<KernelProxyMountTest_Filesystem>;
};
@@ -570,16 +579,33 @@ class KernelProxyMountTest : public ::testing::Test {
KernelProxyMountTest() {}
void SetUp() {
+ g_string_map.clear();
+ g_fs_dev = -1;
+ g_fs_ioctl_called = false;
+
ASSERT_EQ(0, ki_push_state_for_testing());
ASSERT_EQ(0, ki_init(&kp_));
}
- void TearDown() { ki_uninit(); }
+ void TearDown() {
+ g_string_map.clear();
+ ki_uninit();
+ }
private:
KernelProxyMountTest_KernelProxy kp_;
};
+// Helper function for calling ki_ioctl without having
+// to construct a va_list.
+int ki_ioctl_wrapper(int fd, int request, ...) {
+ va_list ap;
+ va_start(ap, request);
+ int rtn = ki_ioctl(fd, request, ap);
+ va_end(ap);
+ return rtn;
+}
+
} // namespace
TEST_F(KernelProxyMountTest, MountInit) {
@@ -594,6 +620,20 @@ TEST_F(KernelProxyMountTest, MountInit) {
EXPECT_EQ("y", g_string_map["x"]);
}
+TEST_F(KernelProxyMountTest, MountAndIoctl) {
+ ASSERT_EQ(0, ki_mount("/", "/mnt1", "initfs", 0, ""));
+ ASSERT_NE(-1, g_fs_dev);
+
+ char path[100];
+ snprintf(path, 100, "dev/fs/%d", g_fs_dev);
+
+ int fd = ki_open(path, O_RDONLY);
+ ASSERT_GT(fd, -1);
+
+ EXPECT_EQ(0, ki_ioctl_wrapper(fd, 0xdeadbeef));
+ EXPECT_EQ(true, g_fs_ioctl_called);
+}
+
namespace {
int g_MMapCount = 0;
« no previous file with comments | « native_client_sdk/src/libraries/sdk_util/scoped_ref.h ('k') | native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698