mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
added test for open (adapter)
This commit is contained in:
parent
48e3575d6d
commit
d56bbcbd39
@ -30,6 +30,7 @@ add_executable(alltests
|
|||||||
test/webfuse/mocks/mock_request.cc
|
test/webfuse/mocks/mock_request.cc
|
||||||
test/webfuse/mocks/mock_provider_client.cc
|
test/webfuse/mocks/mock_provider_client.cc
|
||||||
test/webfuse/mocks/mock_provider.cc
|
test/webfuse/mocks/mock_provider.cc
|
||||||
|
test/webfuse/mocks/mock_fuse.cc
|
||||||
test/webfuse//tests/core/test_util.cc
|
test/webfuse//tests/core/test_util.cc
|
||||||
test/webfuse/tests/core/test_container_of.cc
|
test/webfuse/tests/core/test_container_of.cc
|
||||||
test/webfuse/tests/core/test_string.cc
|
test/webfuse/tests/core/test_string.cc
|
||||||
@ -45,6 +46,7 @@ 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_open.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
|
||||||
@ -67,6 +69,9 @@ target_link_libraries(alltests PUBLIC
|
|||||||
-Wl,--wrap=wf_timer_dispose
|
-Wl,--wrap=wf_timer_dispose
|
||||||
-Wl,--wrap=wf_timer_start
|
-Wl,--wrap=wf_timer_start
|
||||||
-Wl,--wrap=wf_timer_cancel
|
-Wl,--wrap=wf_timer_cancel
|
||||||
|
-Wl,--wrap=fuse_req_userdata
|
||||||
|
-Wl,--wrap=fuse_reply_open
|
||||||
|
-Wl,--wrap=fuse_reply_err
|
||||||
|
|
||||||
webfuse-adapter-static
|
webfuse-adapter-static
|
||||||
webfuse-provider-static
|
webfuse-provider-static
|
||||||
|
@ -22,7 +22,7 @@ static void wf_impl_operation_open_finished(
|
|||||||
if (NULL != result)
|
if (NULL != result)
|
||||||
{
|
{
|
||||||
json_t * handle_holder = json_object_get(result, "handle");
|
json_t * handle_holder = json_object_get(result, "handle");
|
||||||
if ((NULL != handle_holder) && (json_is_integer(handle_holder)))
|
if (json_is_integer(handle_holder))
|
||||||
{
|
{
|
||||||
file_info.fh = json_integer_value(handle_holder);
|
file_info.fh = json_integer_value(handle_holder);
|
||||||
}
|
}
|
||||||
|
28
test/webfuse/mocks/mock_fuse.cc
Normal file
28
test/webfuse/mocks/mock_fuse.cc
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include "webfuse/mocks/mock_fuse.hpp"
|
||||||
|
#include "webfuse/utils/wrap.hpp"
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
static webfuse_test::FuseMock * webfuse_test_FuseMock = nullptr;
|
||||||
|
|
||||||
|
WF_WRAP_FUNC1(webfuse_test_FuseMock, void*, fuse_req_userdata, fuse_req_t);
|
||||||
|
WF_WRAP_FUNC2(webfuse_test_FuseMock, int, fuse_reply_open, fuse_req_t, const struct fuse_file_info *);
|
||||||
|
WF_WRAP_FUNC2(webfuse_test_FuseMock, int, fuse_reply_err, fuse_req_t, int);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace webfuse_test
|
||||||
|
{
|
||||||
|
|
||||||
|
FuseMock::FuseMock()
|
||||||
|
{
|
||||||
|
webfuse_test_FuseMock = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
FuseMock::~FuseMock()
|
||||||
|
{
|
||||||
|
webfuse_test_FuseMock = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
19
test/webfuse/mocks/mock_fuse.hpp
Normal file
19
test/webfuse/mocks/mock_fuse.hpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "webfuse/adapter/impl/fuse_wrapper.h"
|
||||||
|
#include <gmock/gmock.h>
|
||||||
|
|
||||||
|
namespace webfuse_test
|
||||||
|
{
|
||||||
|
|
||||||
|
class FuseMock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FuseMock();
|
||||||
|
virtual ~FuseMock();
|
||||||
|
|
||||||
|
MOCK_METHOD1(fuse_req_userdata, void *(fuse_req_t req));
|
||||||
|
MOCK_METHOD2(fuse_reply_open, int (fuse_req_t req, const struct fuse_file_info *fi));
|
||||||
|
MOCK_METHOD2(fuse_reply_err, int (fuse_req_t req, int err));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
28
test/webfuse/tests/adapter/operation/test_open.cc
Normal file
28
test/webfuse/tests/adapter/operation/test_open.cc
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include "webfuse/adapter/impl/operations.h"
|
||||||
|
#include "webfuse/mocks/mock_fuse.hpp"
|
||||||
|
#include "webfuse/adapter/impl/session.h"
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
using webfuse_test::FuseMock;
|
||||||
|
using testing::_;
|
||||||
|
using testing::Return;
|
||||||
|
|
||||||
|
TEST(wf_impl_operation_open, fail_rpc_null)
|
||||||
|
{
|
||||||
|
wf_impl_session session;
|
||||||
|
memset(&session, 0, sizeof(session));
|
||||||
|
wf_impl_operations_context context =
|
||||||
|
{&session, 1.0f, nullptr };
|
||||||
|
|
||||||
|
FuseMock fuse;
|
||||||
|
EXPECT_CALL(fuse, fuse_req_userdata(_)).Times(1)
|
||||||
|
.WillOnce(Return(reinterpret_cast<void*>(&context)));
|
||||||
|
EXPECT_CALL(fuse, fuse_reply_err(_, ENOENT)).Times(1)
|
||||||
|
.WillOnce(Return(0));
|
||||||
|
|
||||||
|
fuse_req_t request = nullptr;
|
||||||
|
fuse_ino_t inode = 1;
|
||||||
|
fuse_file_info * file_info = nullptr;
|
||||||
|
wf_impl_operation_open(request, inode, file_info);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user