mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
added unit tests for lookup operation (adapter)
This commit is contained in:
parent
654015c95c
commit
745d47bb30
@ -48,11 +48,13 @@ add_executable(alltests
|
|||||||
test/webfuse/tests/adapter/test_authenticators.cc
|
test/webfuse/tests/adapter/test_authenticators.cc
|
||||||
test/webfuse/tests/adapter/test_mountpoint.cc
|
test/webfuse/tests/adapter/test_mountpoint.cc
|
||||||
test/webfuse/tests/adapter/test_fuse_req.cc
|
test/webfuse/tests/adapter/test_fuse_req.cc
|
||||||
|
test/webfuse/tests/adapter/operation/test_context.cc
|
||||||
test/webfuse/tests/adapter/operation/test_open.cc
|
test/webfuse/tests/adapter/operation/test_open.cc
|
||||||
test/webfuse/tests/adapter/operation/test_close.cc
|
test/webfuse/tests/adapter/operation/test_close.cc
|
||||||
test/webfuse/tests/adapter/operation/test_read.cc
|
test/webfuse/tests/adapter/operation/test_read.cc
|
||||||
test/webfuse/tests/adapter/operation/test_readdir.cc
|
test/webfuse/tests/adapter/operation/test_readdir.cc
|
||||||
test/webfuse/tests/adapter/operation/test_getattr.cc
|
test/webfuse/tests/adapter/operation/test_getattr.cc
|
||||||
|
test/webfuse/tests/adapter/operation/test_lookup.cc
|
||||||
test/webfuse/tests/provider/test_url.cc
|
test/webfuse/tests/provider/test_url.cc
|
||||||
test/webfuse/tests/provider/test_client_protocol.cc
|
test/webfuse/tests/provider/test_client_protocol.cc
|
||||||
test/webfuse/tests/provider/operation/test_close.cc
|
test/webfuse/tests/provider/operation/test_close.cc
|
||||||
@ -83,6 +85,7 @@ target_link_libraries(alltests PUBLIC
|
|||||||
-Wl,--wrap=fuse_reply_err
|
-Wl,--wrap=fuse_reply_err
|
||||||
-Wl,--wrap=fuse_reply_buf
|
-Wl,--wrap=fuse_reply_buf
|
||||||
-Wl,--wrap=fuse_reply_attr
|
-Wl,--wrap=fuse_reply_attr
|
||||||
|
-Wl,--wrap=fuse_reply_entry
|
||||||
-Wl,--wrap=fuse_req_ctx
|
-Wl,--wrap=fuse_req_ctx
|
||||||
|
|
||||||
webfuse-adapter-static
|
webfuse-adapter-static
|
||||||
|
@ -13,9 +13,9 @@ add_library(webfuse-adapter-static STATIC
|
|||||||
lib/webfuse/adapter/impl/authenticator.c
|
lib/webfuse/adapter/impl/authenticator.c
|
||||||
lib/webfuse/adapter/impl/authenticators.c
|
lib/webfuse/adapter/impl/authenticators.c
|
||||||
lib/webfuse/adapter/impl/credentials.c
|
lib/webfuse/adapter/impl/credentials.c
|
||||||
lib/webfuse/adapter/impl/operations.c
|
|
||||||
lib/webfuse/adapter/impl/mountpoint.c
|
lib/webfuse/adapter/impl/mountpoint.c
|
||||||
lib/webfuse/adapter/impl/mountpoint_factory.c
|
lib/webfuse/adapter/impl/mountpoint_factory.c
|
||||||
|
lib/webfuse/adapter/impl/operation/context.c
|
||||||
lib/webfuse/adapter/impl/operation/lookup.c
|
lib/webfuse/adapter/impl/operation/lookup.c
|
||||||
lib/webfuse/adapter/impl/operation/getattr.c
|
lib/webfuse/adapter/impl/operation/getattr.c
|
||||||
lib/webfuse/adapter/impl/operation/readdir.c
|
lib/webfuse/adapter/impl/operation/readdir.c
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#include "webfuse/adapter/impl/filesystem.h"
|
#include "webfuse/adapter/impl/filesystem.h"
|
||||||
#include "webfuse/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operation/context.h"
|
||||||
#include "webfuse/adapter/impl/operation/open.h"
|
#include "webfuse/adapter/impl/operation/open.h"
|
||||||
#include "webfuse/adapter/impl/operation/close.h"
|
#include "webfuse/adapter/impl/operation/close.h"
|
||||||
#include "webfuse/adapter/impl/operation/read.h"
|
#include "webfuse/adapter/impl/operation/read.h"
|
||||||
#include "webfuse/adapter/impl/operation/readdir.h"
|
#include "webfuse/adapter/impl/operation/readdir.h"
|
||||||
#include "webfuse/adapter/impl/operation/getattr.h"
|
#include "webfuse/adapter/impl/operation/getattr.h"
|
||||||
|
#include "webfuse/adapter/impl/operation/lookup.h"
|
||||||
#include "webfuse/adapter/impl/session.h"
|
#include "webfuse/adapter/impl/session.h"
|
||||||
#include "webfuse/adapter/impl/mountpoint.h"
|
#include "webfuse/adapter/impl/mountpoint.h"
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "webfuse/adapter/impl/fuse_wrapper.h"
|
#include "webfuse/adapter/impl/fuse_wrapper.h"
|
||||||
#include "webfuse/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operation/context.h"
|
||||||
#include "webfuse/core/slist.h"
|
#include "webfuse/core/slist.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "webfuse/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operation/close.h"
|
||||||
|
#include "webfuse/adapter/impl/operation/context.h"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "webfuse/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operation/context.h"
|
||||||
#include "webfuse/adapter/impl/session_manager.h"
|
#include "webfuse/adapter/impl/session_manager.h"
|
||||||
#include "webfuse/adapter/impl/session.h"
|
#include "webfuse/adapter/impl/session.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef WF_ADAPTER_IMPL_OPERATIONS_H
|
#ifndef WF_ADAPTER_IMPL_OPERATION_CONTEXT_H
|
||||||
#define WF_ADAPTER_IMPL_OPERATIONS_H
|
#define WF_ADAPTER_IMPL_OPERATION_CONTEXT_H
|
||||||
|
|
||||||
#include "webfuse/adapter/impl/fuse_wrapper.h"
|
#include "webfuse/adapter/impl/fuse_wrapper.h"
|
||||||
|
|
||||||
@ -17,11 +17,6 @@ struct wf_impl_operations_context
|
|||||||
char * name;
|
char * name;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void wf_impl_operation_lookup (
|
|
||||||
fuse_req_t req,
|
|
||||||
fuse_ino_t parent,
|
|
||||||
char const * name);
|
|
||||||
|
|
||||||
extern struct wf_jsonrpc_proxy * wf_impl_operations_context_get_proxy(
|
extern struct wf_jsonrpc_proxy * wf_impl_operations_context_get_proxy(
|
||||||
struct wf_impl_operations_context * context);
|
struct wf_impl_operations_context * context);
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
#include "webfuse/adapter/impl/operation/getattr.h"
|
#include "webfuse/adapter/impl/operation/getattr.h"
|
||||||
#include "webfuse/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operation/context.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "webfuse/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operation/lookup.h"
|
||||||
|
#include "webfuse/adapter/impl/operation/context.h"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -14,15 +15,7 @@
|
|||||||
#include "webfuse/core/json_util.h"
|
#include "webfuse/core/json_util.h"
|
||||||
#include "webfuse/core/util.h"
|
#include "webfuse/core/util.h"
|
||||||
|
|
||||||
struct wf_impl_operation_lookup_context
|
void wf_impl_operation_lookup_finished(
|
||||||
{
|
|
||||||
fuse_req_t request;
|
|
||||||
double timeout;
|
|
||||||
uid_t uid;
|
|
||||||
gid_t gid;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void wf_impl_operation_lookup_finished(
|
|
||||||
void * user_data,
|
void * user_data,
|
||||||
json_t const * result,
|
json_t const * result,
|
||||||
json_t const * error
|
json_t const * error
|
||||||
@ -37,9 +30,9 @@ static void wf_impl_operation_lookup_finished(
|
|||||||
json_t * inode_holder = json_object_get(result, "inode");
|
json_t * inode_holder = json_object_get(result, "inode");
|
||||||
json_t * mode_holder = json_object_get(result, "mode");
|
json_t * mode_holder = json_object_get(result, "mode");
|
||||||
json_t * type_holder = json_object_get(result, "type");
|
json_t * type_holder = json_object_get(result, "type");
|
||||||
if ((NULL != inode_holder) && (json_is_integer(inode_holder)) &&
|
if ((json_is_integer(inode_holder)) &&
|
||||||
(NULL != mode_holder) && (json_is_integer(mode_holder)) &&
|
(json_is_integer(mode_holder)) &&
|
||||||
(NULL != type_holder) && (json_is_string(type_holder)))
|
(json_is_string(type_holder)))
|
||||||
{
|
{
|
||||||
memset(&buffer, 0, sizeof(struct stat));
|
memset(&buffer, 0, sizeof(struct stat));
|
||||||
|
|
||||||
|
36
lib/webfuse/adapter/impl/operation/lookup.h
Normal file
36
lib/webfuse/adapter/impl/operation/lookup.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef WF_ADAPTER_IMPL_OPERATION_LOOKUP_H
|
||||||
|
#define WF_ADAPTER_IMPL_OPERATION_LOOKUP_H
|
||||||
|
|
||||||
|
#include "webfuse/adapter/impl/fuse_wrapper.h"
|
||||||
|
|
||||||
|
#include <jansson.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_impl_operation_lookup_context
|
||||||
|
{
|
||||||
|
fuse_req_t request;
|
||||||
|
double timeout;
|
||||||
|
uid_t uid;
|
||||||
|
gid_t gid;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void wf_impl_operation_lookup_finished(
|
||||||
|
void * user_data,
|
||||||
|
json_t const * result,
|
||||||
|
json_t const * error);
|
||||||
|
|
||||||
|
extern void wf_impl_operation_lookup (
|
||||||
|
fuse_req_t req,
|
||||||
|
fuse_ino_t parent,
|
||||||
|
char const * name);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -1,5 +1,5 @@
|
|||||||
#include "webfuse/adapter/impl/operation/open.h"
|
#include "webfuse/adapter/impl/operation/open.h"
|
||||||
#include "webfuse/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operation/context.h"
|
||||||
|
|
||||||
#include "webfuse/core/jsonrpc/proxy.h"
|
#include "webfuse/core/jsonrpc/proxy.h"
|
||||||
#include "webfuse/core/util.h"
|
#include "webfuse/core/util.h"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "webfuse/adapter/impl/operation/read.h"
|
#include "webfuse/adapter/impl/operation/read.h"
|
||||||
#include "webfuse/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operation/context.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "webfuse/adapter/impl/operation/readdir.h"
|
#include "webfuse/adapter/impl/operation/readdir.h"
|
||||||
#include "webfuse/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operation/context.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -11,7 +11,7 @@ WF_WRAP_FUNC2(webfuse_test_FuseMock, int, fuse_reply_err, fuse_req_t, int);
|
|||||||
WF_WRAP_FUNC3(webfuse_test_FuseMock, int, fuse_reply_buf, fuse_req_t, const char *, size_t);
|
WF_WRAP_FUNC3(webfuse_test_FuseMock, int, fuse_reply_buf, fuse_req_t, const char *, size_t);
|
||||||
WF_WRAP_FUNC3(webfuse_test_FuseMock, int, fuse_reply_attr, fuse_req_t, const struct stat *, double);
|
WF_WRAP_FUNC3(webfuse_test_FuseMock, int, fuse_reply_attr, fuse_req_t, const struct stat *, double);
|
||||||
WF_WRAP_FUNC1(webfuse_test_FuseMock, const struct fuse_ctx *, fuse_req_ctx, fuse_req_t);
|
WF_WRAP_FUNC1(webfuse_test_FuseMock, const struct fuse_ctx *, fuse_req_ctx, fuse_req_t);
|
||||||
|
WF_WRAP_FUNC2(webfuse_test_FuseMock, int, fuse_reply_entry, fuse_req_t, const struct fuse_entry_param *);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace webfuse_test
|
namespace webfuse_test
|
||||||
|
@ -19,6 +19,7 @@ public:
|
|||||||
MOCK_METHOD3(fuse_reply_buf, int (fuse_req_t req, const char *buf, size_t size));
|
MOCK_METHOD3(fuse_reply_buf, int (fuse_req_t req, const char *buf, size_t size));
|
||||||
MOCK_METHOD3(fuse_reply_attr, int (fuse_req_t req, const struct stat *attr, double attr_timeout));
|
MOCK_METHOD3(fuse_reply_attr, int (fuse_req_t req, const struct stat *attr, double attr_timeout));
|
||||||
MOCK_METHOD1(fuse_req_ctx, const struct fuse_ctx *(fuse_req_t req));
|
MOCK_METHOD1(fuse_req_ctx, const struct fuse_ctx *(fuse_req_t req));
|
||||||
|
MOCK_METHOD2(fuse_reply_entry, int (fuse_req_t req, const struct fuse_entry_param *e));
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef MOCK_OPERATIONS_CONTEXT_HPP
|
#ifndef MOCK_OPERATIONS_CONTEXT_HPP
|
||||||
#define MOCK_OPERATIONS_CONTEXT_HPP
|
#define MOCK_OPERATIONS_CONTEXT_HPP
|
||||||
|
|
||||||
#include "webfuse/adapter/impl/operations.h"
|
#include "webfuse/adapter/impl/operation/context.h"
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
|
|
||||||
namespace webfuse_test
|
namespace webfuse_test
|
||||||
|
23
test/webfuse/tests/adapter/operation/test_context.cc
Normal file
23
test/webfuse/tests/adapter/operation/test_context.cc
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include "webfuse/adapter/impl/operation/context.h"
|
||||||
|
#include "webfuse/adapter/impl/session.h"
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_context, get_proxy)
|
||||||
|
{
|
||||||
|
wf_jsonrpc_proxy * proxy = reinterpret_cast<wf_jsonrpc_proxy*>(42);
|
||||||
|
wf_impl_session session;
|
||||||
|
session.rpc = proxy;
|
||||||
|
wf_impl_operations_context context;
|
||||||
|
context.session = &session;
|
||||||
|
|
||||||
|
ASSERT_EQ(proxy, wf_impl_operations_context_get_proxy(&context));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_context, get_proxy_fail_no_session)
|
||||||
|
{
|
||||||
|
wf_impl_operations_context context;
|
||||||
|
context.session = nullptr;
|
||||||
|
|
||||||
|
ASSERT_EQ(nullptr, wf_impl_operations_context_get_proxy(&context));
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
#include "webfuse/adapter/impl/operation/getattr.h"
|
#include "webfuse/adapter/impl/operation/getattr.h"
|
||||||
#include "webfuse/adapter/impl/operations.h"
|
|
||||||
|
|
||||||
#include "webfuse/core/status.h"
|
#include "webfuse/core/status.h"
|
||||||
|
|
||||||
|
255
test/webfuse/tests/adapter/operation/test_lookup.cc
Normal file
255
test/webfuse/tests/adapter/operation/test_lookup.cc
Normal file
@ -0,0 +1,255 @@
|
|||||||
|
#include "webfuse/adapter/impl/operation/lookup.h"
|
||||||
|
|
||||||
|
#include "webfuse/core/status.h"
|
||||||
|
|
||||||
|
#include "webfuse/mocks/mock_fuse.hpp"
|
||||||
|
#include "webfuse/mocks/mock_operations_context.hpp"
|
||||||
|
#include "webfuse/mocks/mock_jsonrpc_proxy.hpp"
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
using webfuse_test::MockJsonRpcProxy;
|
||||||
|
using webfuse_test::MockOperationsContext;
|
||||||
|
using webfuse_test::FuseMock;
|
||||||
|
using testing::_;
|
||||||
|
using testing::Return;
|
||||||
|
using testing::Invoke;
|
||||||
|
using testing::StrEq;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
void free_context(
|
||||||
|
struct wf_jsonrpc_proxy * ,
|
||||||
|
wf_jsonrpc_proxy_finished_fn * ,
|
||||||
|
void * user_data,
|
||||||
|
char const * ,
|
||||||
|
char const *)
|
||||||
|
{
|
||||||
|
free(user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_lookup, invoke_proxy)
|
||||||
|
{
|
||||||
|
MockJsonRpcProxy proxy;
|
||||||
|
EXPECT_CALL(proxy, wf_jsonrpc_proxy_vinvoke(_,_,_,StrEq("lookup"),StrEq("sis"))).Times(1)
|
||||||
|
.WillOnce(Invoke(free_context));
|
||||||
|
|
||||||
|
MockOperationsContext context;
|
||||||
|
EXPECT_CALL(context, wf_impl_operations_context_get_proxy(_)).Times(1)
|
||||||
|
.WillOnce(Return(reinterpret_cast<wf_jsonrpc_proxy*>(&proxy)));
|
||||||
|
|
||||||
|
wf_impl_operations_context op_context;
|
||||||
|
op_context.name = nullptr;
|
||||||
|
fuse_ctx fuse_context;
|
||||||
|
fuse_context.gid = 0;
|
||||||
|
fuse_context.uid = 0;
|
||||||
|
FuseMock fuse;
|
||||||
|
EXPECT_CALL(fuse, fuse_req_ctx(_)).Times(1).WillOnce(Return(&fuse_context));
|
||||||
|
EXPECT_CALL(fuse, fuse_req_userdata(_)).Times(1).WillOnce(Return(&op_context));
|
||||||
|
|
||||||
|
|
||||||
|
fuse_req_t request = nullptr;
|
||||||
|
fuse_ino_t inode = 1;
|
||||||
|
wf_impl_operation_lookup(request, inode, "some.file");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_lookup, fail_rpc_null)
|
||||||
|
{
|
||||||
|
MockOperationsContext context;
|
||||||
|
EXPECT_CALL(context, wf_impl_operations_context_get_proxy(_)).Times(1)
|
||||||
|
.WillOnce(Return(nullptr));
|
||||||
|
|
||||||
|
FuseMock fuse;
|
||||||
|
EXPECT_CALL(fuse, fuse_req_ctx(_)).Times(1).WillOnce(Return(nullptr));
|
||||||
|
EXPECT_CALL(fuse, fuse_req_userdata(_)).Times(1).WillOnce(Return(nullptr));
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_err(_, ENOENT)).Times(1).WillOnce(Return(0));
|
||||||
|
|
||||||
|
fuse_req_t request = nullptr;
|
||||||
|
fuse_ino_t inode = 1;
|
||||||
|
wf_impl_operation_lookup(request, inode, "some.file");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_lookup, finished_file)
|
||||||
|
{
|
||||||
|
FuseMock fuse;
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_entry(_,_)).Times(1).WillOnce(Return(0));
|
||||||
|
|
||||||
|
json_t * result = json_object();
|
||||||
|
json_object_set_new(result, "inode", json_integer(42));
|
||||||
|
json_object_set_new(result, "mode", json_integer(0755));
|
||||||
|
json_object_set_new(result, "type", json_string("file"));
|
||||||
|
|
||||||
|
auto * context = reinterpret_cast<wf_impl_operation_lookup_context*>(malloc(sizeof(wf_impl_operation_lookup_context)));
|
||||||
|
context->timeout = 1.0;
|
||||||
|
context->gid = 0;
|
||||||
|
context->uid = 0;
|
||||||
|
wf_impl_operation_lookup_finished(context, result, nullptr);
|
||||||
|
json_decref(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_lookup, finished_dir)
|
||||||
|
{
|
||||||
|
FuseMock fuse;
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_entry(_,_)).Times(1).WillOnce(Return(0));
|
||||||
|
|
||||||
|
json_t * result = json_object();
|
||||||
|
json_object_set_new(result, "inode", json_integer(42));
|
||||||
|
json_object_set_new(result, "mode", json_integer(0755));
|
||||||
|
json_object_set_new(result, "type", json_string("dir"));
|
||||||
|
|
||||||
|
auto * context = reinterpret_cast<wf_impl_operation_lookup_context*>(malloc(sizeof(wf_impl_operation_lookup_context)));
|
||||||
|
context->timeout = 1.0;
|
||||||
|
context->gid = 0;
|
||||||
|
context->uid = 0;
|
||||||
|
wf_impl_operation_lookup_finished(context, result, nullptr);
|
||||||
|
json_decref(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_lookup, finished_unknown_type)
|
||||||
|
{
|
||||||
|
FuseMock fuse;
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_entry(_,_)).Times(1).WillOnce(Return(0));
|
||||||
|
|
||||||
|
json_t * result = json_object();
|
||||||
|
json_object_set_new(result, "inode", json_integer(42));
|
||||||
|
json_object_set_new(result, "mode", json_integer(0755));
|
||||||
|
json_object_set_new(result, "type", json_string("unknown"));
|
||||||
|
|
||||||
|
auto * context = reinterpret_cast<wf_impl_operation_lookup_context*>(malloc(sizeof(wf_impl_operation_lookup_context)));
|
||||||
|
context->timeout = 1.0;
|
||||||
|
context->gid = 0;
|
||||||
|
context->uid = 0;
|
||||||
|
wf_impl_operation_lookup_finished(context, result, nullptr);
|
||||||
|
json_decref(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_lookup, finished_fail_missing_inode)
|
||||||
|
{
|
||||||
|
FuseMock fuse;
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_open(_,_)).Times(0);
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_err(_, ENOENT)).Times(1).WillOnce(Return(0));
|
||||||
|
|
||||||
|
json_t * result = json_object();
|
||||||
|
json_object_set_new(result, "mode", json_integer(0755));
|
||||||
|
json_object_set_new(result, "type", json_string("file"));
|
||||||
|
|
||||||
|
auto * context = reinterpret_cast<wf_impl_operation_lookup_context*>(malloc(sizeof(wf_impl_operation_lookup_context)));
|
||||||
|
context->timeout = 1.0;
|
||||||
|
context->gid = 0;
|
||||||
|
context->uid = 0;
|
||||||
|
wf_impl_operation_lookup_finished(context, result, nullptr);
|
||||||
|
json_decref(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_lookup, finished_fail_invalid_inode_type)
|
||||||
|
{
|
||||||
|
FuseMock fuse;
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_open(_,_)).Times(0);
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_err(_, ENOENT)).Times(1).WillOnce(Return(0));
|
||||||
|
|
||||||
|
json_t * result = json_object();
|
||||||
|
json_object_set_new(result, "inode", json_string("42"));
|
||||||
|
json_object_set_new(result, "mode", json_string("0755"));
|
||||||
|
json_object_set_new(result, "type", json_string("file"));
|
||||||
|
|
||||||
|
auto * context = reinterpret_cast<wf_impl_operation_lookup_context*>(malloc(sizeof(wf_impl_operation_lookup_context)));
|
||||||
|
context->timeout = 1.0;
|
||||||
|
context->gid = 0;
|
||||||
|
context->uid = 0;
|
||||||
|
wf_impl_operation_lookup_finished(context, result, nullptr);
|
||||||
|
json_decref(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_lookup, finished_fail_missing_mode)
|
||||||
|
{
|
||||||
|
FuseMock fuse;
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_open(_,_)).Times(0);
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_err(_, ENOENT)).Times(1).WillOnce(Return(0));
|
||||||
|
|
||||||
|
json_t * result = json_object();
|
||||||
|
json_object_set_new(result, "inode", json_integer(42));
|
||||||
|
json_object_set_new(result, "type", json_string("file"));
|
||||||
|
|
||||||
|
auto * context = reinterpret_cast<wf_impl_operation_lookup_context*>(malloc(sizeof(wf_impl_operation_lookup_context)));
|
||||||
|
context->timeout = 1.0;
|
||||||
|
context->gid = 0;
|
||||||
|
context->uid = 0;
|
||||||
|
wf_impl_operation_lookup_finished(context, result, nullptr);
|
||||||
|
json_decref(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_lookup, finished_fail_invalid_mode_type)
|
||||||
|
{
|
||||||
|
FuseMock fuse;
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_open(_,_)).Times(0);
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_err(_, ENOENT)).Times(1).WillOnce(Return(0));
|
||||||
|
|
||||||
|
json_t * result = json_object();
|
||||||
|
json_object_set_new(result, "inode", json_integer(42));
|
||||||
|
json_object_set_new(result, "mode", json_string("0755"));
|
||||||
|
json_object_set_new(result, "type", json_string("file"));
|
||||||
|
|
||||||
|
auto * context = reinterpret_cast<wf_impl_operation_lookup_context*>(malloc(sizeof(wf_impl_operation_lookup_context)));
|
||||||
|
context->timeout = 1.0;
|
||||||
|
context->gid = 0;
|
||||||
|
context->uid = 0;
|
||||||
|
wf_impl_operation_lookup_finished(context, result, nullptr);
|
||||||
|
json_decref(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_lookup, finished_fail_type_mode)
|
||||||
|
{
|
||||||
|
FuseMock fuse;
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_open(_,_)).Times(0);
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_err(_, ENOENT)).Times(1).WillOnce(Return(0));
|
||||||
|
|
||||||
|
json_t * result = json_object();
|
||||||
|
json_object_set_new(result, "inode", json_integer(42));
|
||||||
|
json_object_set_new(result, "mode", json_integer(0755));
|
||||||
|
|
||||||
|
auto * context = reinterpret_cast<wf_impl_operation_lookup_context*>(malloc(sizeof(wf_impl_operation_lookup_context)));
|
||||||
|
context->timeout = 1.0;
|
||||||
|
context->gid = 0;
|
||||||
|
context->uid = 0;
|
||||||
|
wf_impl_operation_lookup_finished(context, result, nullptr);
|
||||||
|
json_decref(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_lookup, finished_fail_invalid_type_type)
|
||||||
|
{
|
||||||
|
FuseMock fuse;
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_open(_,_)).Times(0);
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_err(_, ENOENT)).Times(1).WillOnce(Return(0));
|
||||||
|
|
||||||
|
json_t * result = json_object();
|
||||||
|
json_object_set_new(result, "inode", json_integer(42));
|
||||||
|
json_object_set_new(result, "mode", json_integer(0755));
|
||||||
|
json_object_set_new(result, "type", json_integer(42));
|
||||||
|
|
||||||
|
auto * context = reinterpret_cast<wf_impl_operation_lookup_context*>(malloc(sizeof(wf_impl_operation_lookup_context)));
|
||||||
|
context->timeout = 1.0;
|
||||||
|
context->gid = 0;
|
||||||
|
context->uid = 0;
|
||||||
|
wf_impl_operation_lookup_finished(context, result, nullptr);
|
||||||
|
json_decref(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_lookup, finished_error)
|
||||||
|
{
|
||||||
|
FuseMock fuse;
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_open(_,_)).Times(0);
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_err(_, ENOENT)).Times(1).WillOnce(Return(0));
|
||||||
|
|
||||||
|
json_t * error = json_object();
|
||||||
|
json_object_set_new(error, "code", json_integer(WF_BAD));
|
||||||
|
|
||||||
|
auto * context = reinterpret_cast<wf_impl_operation_lookup_context*>(malloc(sizeof(wf_impl_operation_lookup_context)));
|
||||||
|
context->timeout = 1.0;
|
||||||
|
context->gid = 0;
|
||||||
|
context->uid = 0;
|
||||||
|
wf_impl_operation_lookup_finished(context, nullptr, error);
|
||||||
|
json_decref(error);
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
#include "webfuse/adapter/impl/operation/open.h"
|
#include "webfuse/adapter/impl/operation/open.h"
|
||||||
#include "webfuse/adapter/impl/operations.h"
|
|
||||||
|
|
||||||
#include "webfuse/core/status.h"
|
#include "webfuse/core/status.h"
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "webfuse/adapter/impl/operation/read.h"
|
#include "webfuse/adapter/impl/operation/read.h"
|
||||||
#include "webfuse/adapter/impl/operations.h"
|
|
||||||
|
|
||||||
#include "webfuse/mocks/mock_fuse.hpp"
|
#include "webfuse/mocks/mock_fuse.hpp"
|
||||||
#include "webfuse/mocks/mock_operations_context.hpp"
|
#include "webfuse/mocks/mock_operations_context.hpp"
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "webfuse/adapter/impl/operation/readdir.h"
|
#include "webfuse/adapter/impl/operation/readdir.h"
|
||||||
#include "webfuse/adapter/impl/operations.h"
|
|
||||||
|
|
||||||
#include "webfuse/core/status.h"
|
#include "webfuse/core/status.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user