mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
added unit tests for close operation (adapter)
This commit is contained in:
parent
77a870b9b7
commit
289264e269
@ -49,6 +49,7 @@ add_executable(alltests
|
||||
test/webfuse/tests/adapter/test_mountpoint.cc
|
||||
test/webfuse/tests/adapter/test_fuse_req.cc
|
||||
test/webfuse/tests/adapter/operation/test_open.cc
|
||||
test/webfuse/tests/adapter/operation/test_close.cc
|
||||
test/webfuse/tests/provider/test_url.cc
|
||||
test/webfuse/tests/provider/test_client_protocol.cc
|
||||
test/webfuse/tests/provider/operation/test_close.cc
|
||||
@ -73,6 +74,7 @@ target_link_libraries(alltests PUBLIC
|
||||
-Wl,--wrap=wf_timer_cancel
|
||||
-Wl,--wrap=wf_impl_operations_context_get_proxy
|
||||
-Wl,--wrap=wf_jsonrpc_proxy_vinvoke
|
||||
-Wl,--wrap=wf_jsonrpc_proxy_vnotify
|
||||
-Wl,--wrap=fuse_req_userdata
|
||||
-Wl,--wrap=fuse_reply_open
|
||||
-Wl,--wrap=fuse_reply_err
|
||||
|
@ -13,7 +13,7 @@ add_library(webfuse-core STATIC
|
||||
lib/webfuse/core/timer/timepoint.c
|
||||
lib/webfuse/core/timer/timer.c
|
||||
lib/webfuse/core/jsonrpc/proxy.c
|
||||
lib/webfuse/core/jsonrpc/proxy_invoke.c
|
||||
lib/webfuse/core/jsonrpc/proxy_variadic.c
|
||||
lib/webfuse/core/jsonrpc/server.c
|
||||
lib/webfuse/core/jsonrpc/method.c
|
||||
lib/webfuse/core/jsonrpc/request.c
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "webfuse/adapter/impl/filesystem.h"
|
||||
#include "webfuse/adapter/impl/operations.h"
|
||||
#include "webfuse/adapter/impl/operation/open.h"
|
||||
#include "webfuse/adapter/impl/operation/close.h"
|
||||
#include "webfuse/adapter/impl/session.h"
|
||||
#include "webfuse/adapter/impl/mountpoint.h"
|
||||
|
||||
|
20
lib/webfuse/adapter/impl/operation/close.h
Normal file
20
lib/webfuse/adapter/impl/operation/close.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef WF_ADAPTER_IMPL_OPERATION_CLOSE_H
|
||||
#define WF_ADAPTER_IMPL_OPERATION_CLOSE_H
|
||||
|
||||
#include "webfuse/adapter/impl/fuse_wrapper.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void wf_impl_operation_close(
|
||||
fuse_req_t request,
|
||||
fuse_ino_t inode,
|
||||
struct fuse_file_info * file_info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -34,11 +34,6 @@ extern void wf_impl_operation_readdir (
|
||||
off_t offset,
|
||||
struct fuse_file_info *file_info);
|
||||
|
||||
extern void wf_impl_operation_close(
|
||||
fuse_req_t request,
|
||||
fuse_ino_t inode,
|
||||
struct fuse_file_info * file_info);
|
||||
|
||||
extern void wf_impl_operation_read(
|
||||
fuse_req_t request,
|
||||
fuse_ino_t ino, size_t size, off_t off,
|
||||
|
@ -174,17 +174,13 @@ void wf_jsonrpc_proxy_vinvoke(
|
||||
}
|
||||
}
|
||||
|
||||
extern void wf_jsonrpc_proxy_notify(
|
||||
extern void wf_jsonrpc_proxy_vnotify(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
char const * method_name,
|
||||
char const * param_info,
|
||||
...
|
||||
)
|
||||
va_list args)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, param_info);
|
||||
json_t * request = wf_jsonrpc_request_create(method_name, 0, param_info, args);
|
||||
va_end(args);
|
||||
|
||||
if (NULL != request)
|
||||
{
|
||||
|
@ -49,6 +49,12 @@ extern void wf_jsonrpc_proxy_vinvoke(
|
||||
char const * param_info,
|
||||
va_list args);
|
||||
|
||||
extern void wf_jsonrpc_proxy_vnotify(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
char const * method_name,
|
||||
char const * param_info,
|
||||
va_list args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -13,3 +13,16 @@ void wf_jsonrpc_proxy_invoke(
|
||||
wf_jsonrpc_proxy_vinvoke(proxy, finished, user_data, method_name, param_info, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
extern void wf_jsonrpc_proxy_notify(
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
char const * method_name,
|
||||
char const * param_info,
|
||||
...
|
||||
)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, param_info);
|
||||
wf_jsonrpc_proxy_vnotify(proxy, method_name, param_info, args);
|
||||
va_end(args);
|
||||
}
|
@ -12,6 +12,12 @@ WF_WRAP_FUNC6(webfuse_test_MockJsonRpcProxy, void, wf_jsonrpc_proxy_vinvoke,
|
||||
char const *,
|
||||
char const *,
|
||||
va_list);
|
||||
|
||||
WF_WRAP_FUNC4(webfuse_test_MockJsonRpcProxy, void, wf_jsonrpc_proxy_vnotify,
|
||||
struct wf_jsonrpc_proxy *,
|
||||
char const *,
|
||||
char const *,
|
||||
va_list);
|
||||
}
|
||||
|
||||
namespace webfuse_test
|
||||
|
@ -19,6 +19,11 @@ public:
|
||||
char const * method_name,
|
||||
char const * param_info,
|
||||
va_list args));
|
||||
MOCK_METHOD4(wf_jsonrpc_proxy_vnotify, void (
|
||||
struct wf_jsonrpc_proxy * proxy,
|
||||
char const * method_name,
|
||||
char const * param_info,
|
||||
va_list args));
|
||||
|
||||
};
|
||||
|
||||
|
56
test/webfuse/tests/adapter/operation/test_close.cc
Normal file
56
test/webfuse/tests/adapter/operation/test_close.cc
Normal file
@ -0,0 +1,56 @@
|
||||
#include "webfuse/adapter/impl/operation/close.h"
|
||||
#include <gtest/gtest.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::StrEq;
|
||||
|
||||
TEST(wf_impl_operation_close, notify_proxy)
|
||||
{
|
||||
MockJsonRpcProxy proxy;
|
||||
EXPECT_CALL(proxy, wf_jsonrpc_proxy_vnotify(_,StrEq("close"),StrEq("siii"),_)).Times(1);
|
||||
|
||||
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;
|
||||
FuseMock fuse;
|
||||
EXPECT_CALL(fuse, fuse_req_userdata(_)).Times(1).WillOnce(Return(&op_context));
|
||||
EXPECT_CALL(fuse, fuse_reply_err(_, 0)).Times(1).WillOnce(Return(0));
|
||||
|
||||
fuse_req_t request = nullptr;
|
||||
fuse_ino_t inode = 1;
|
||||
fuse_file_info file_info;
|
||||
file_info.flags = 0;
|
||||
wf_impl_operation_close(request, inode, &file_info);
|
||||
}
|
||||
|
||||
TEST(wf_impl_operation_close, fail_rpc_null)
|
||||
{
|
||||
MockJsonRpcProxy proxy;
|
||||
EXPECT_CALL(proxy, wf_jsonrpc_proxy_vnotify(_,_,_,_)).Times(0);
|
||||
|
||||
MockOperationsContext context;
|
||||
EXPECT_CALL(context, wf_impl_operations_context_get_proxy(_)).Times(1)
|
||||
.WillOnce(Return(nullptr));
|
||||
|
||||
FuseMock fuse;
|
||||
EXPECT_CALL(fuse, fuse_req_userdata(_)).Times(1).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(fuse, fuse_reply_err(_, 0)).Times(1).WillOnce(Return(0));
|
||||
|
||||
fuse_req_t request = nullptr;
|
||||
fuse_ino_t inode = 1;
|
||||
fuse_file_info * file_info = nullptr;
|
||||
wf_impl_operation_close(request, inode, file_info);
|
||||
}
|
Loading…
Reference in New Issue
Block a user