mirror of
https://github.com/falk-werner/webfuse-provider
synced 2026-03-02 04:09:18 +00:00
chore(webfuse) Increase test coverage (#34)
* removes unnecessary code * adds test of wf_status * adds tests of wf_message * adds tests of wf_message_queue * changed branch of coverage badge to display correct results * moves core tests into separate subdirectory * increases coverage of timer test * moves adapter specific tests into separate directory * moves provider specific tests into separate directory * adds tests of jsonrpc utilities * adds tests of jsonrpc request * adds test of jsonrpc response * adds tests of jsonrpc server * adds tests of jsonrpc proxy * adds integration test (found some issues) * disables problematic tests * fixes resource leak: pending timer after cleanup proxy * fixes order of cleanup to prevent processing pending requests after filesystem shut down * fixes some memcheck and helgrind errors: initialization of lws_log; setup of client and server * disabled a test * fixes error in msleep utility * fixes deadlock at IntegrationTest using valgrind * removes unit test code from coverage report * adds some integration tests * makes badge show coverage of master * fixes some coding style issues * fixes eary trigger of is_connected (provider) * fixes read error in 32 bit environments\n\ninode is always 64 bit, but variadic wf_impl_jsonrpc_proxy_invoke expects int
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
|
||||
#include "webfuse/adapter/impl/jsonrpc/response.h"
|
||||
|
||||
#define WF_DEFAULT_TIMEOUT (10 * 1000)
|
||||
|
||||
static void wf_impl_jsonrpc_proxy_timeout(
|
||||
struct wf_impl_timer * timer)
|
||||
{
|
||||
@@ -53,8 +51,9 @@ static json_t * wf_impl_jsonrpc_request_create(
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "fatal: unknown param_type '%c'\n", *param_type);
|
||||
exit(EXIT_FAILURE);
|
||||
break;
|
||||
json_decref(params);
|
||||
json_decref(request);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,10 +70,12 @@ static json_t * wf_impl_jsonrpc_request_create(
|
||||
void wf_impl_jsonrpc_proxy_init(
|
||||
struct wf_impl_jsonrpc_proxy * proxy,
|
||||
struct wf_impl_timeout_manager * timeout_manager,
|
||||
int timeout,
|
||||
wf_impl_jsonrpc_send_fn * send,
|
||||
void * user_data)
|
||||
{
|
||||
proxy->send = send;
|
||||
proxy->timeout = timeout;
|
||||
proxy->user_data = user_data;
|
||||
proxy->request.is_pending = false;
|
||||
|
||||
@@ -84,13 +85,21 @@ void wf_impl_jsonrpc_proxy_init(
|
||||
void wf_impl_jsonrpc_proxy_cleanup(
|
||||
struct wf_impl_jsonrpc_proxy * proxy)
|
||||
{
|
||||
wf_impl_timer_cleanup(&proxy->request.timer);
|
||||
|
||||
if (proxy->request.is_pending)
|
||||
{
|
||||
proxy->request.finished(proxy->request.user_data, WF_BAD, NULL);
|
||||
void * user_data = proxy->request.user_data;
|
||||
wf_impl_jsonrpc_proxy_finished_fn * finished = proxy->request.finished;
|
||||
|
||||
proxy->request.is_pending = false;
|
||||
proxy->request.finished = NULL;
|
||||
proxy->request.user_data = NULL;
|
||||
proxy->request.id = 0;
|
||||
wf_impl_timer_cancel(&proxy->request.timer);
|
||||
|
||||
finished(user_data, WF_BAD, NULL);
|
||||
}
|
||||
|
||||
wf_impl_timer_cleanup(&proxy->request.timer);
|
||||
}
|
||||
|
||||
void wf_impl_jsonrpc_proxy_invoke(
|
||||
@@ -108,25 +117,29 @@ void wf_impl_jsonrpc_proxy_invoke(
|
||||
proxy->request.finished = finished;
|
||||
proxy->request.user_data = user_data;
|
||||
proxy->request.id = 42;
|
||||
wf_impl_timer_start(&proxy->request.timer, wf_impl_timepoint_in_msec(WF_DEFAULT_TIMEOUT),
|
||||
wf_impl_timer_start(&proxy->request.timer, wf_impl_timepoint_in_msec(proxy->timeout),
|
||||
&wf_impl_jsonrpc_proxy_timeout, proxy);
|
||||
|
||||
va_list args;
|
||||
va_start(args, param_info);
|
||||
json_t * request = wf_impl_jsonrpc_request_create(method_name, proxy->request.id, param_info, args);
|
||||
va_end(args);
|
||||
|
||||
bool const is_send = ((NULL != request) && (proxy->send(request, proxy->user_data)));
|
||||
if (!is_send)
|
||||
{
|
||||
proxy->request.is_pending = false;
|
||||
proxy->request.finished = NULL;
|
||||
proxy->request.user_data = NULL;
|
||||
proxy->request.id = 0;
|
||||
wf_impl_timer_cancel(&proxy->request.timer);
|
||||
|
||||
finished(user_data, WF_BAD, NULL);
|
||||
|
||||
}
|
||||
|
||||
if (NULL != request)
|
||||
{
|
||||
if (!proxy->send(request, proxy->user_data))
|
||||
{
|
||||
proxy->request.is_pending = false;
|
||||
proxy->request.finished = NULL;
|
||||
proxy->request.user_data = NULL;
|
||||
proxy->request.id = 0;
|
||||
wf_impl_timer_cancel(&proxy->request.timer);
|
||||
|
||||
finished(user_data, WF_BAD, NULL);
|
||||
}
|
||||
json_decref(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ struct wf_impl_jsonrpc_request
|
||||
struct wf_impl_jsonrpc_proxy
|
||||
{
|
||||
struct wf_impl_jsonrpc_request request;
|
||||
int timeout;
|
||||
wf_impl_jsonrpc_send_fn * send;
|
||||
void * user_data;
|
||||
};
|
||||
@@ -46,6 +47,7 @@ struct wf_impl_jsonrpc_proxy
|
||||
extern void wf_impl_jsonrpc_proxy_init(
|
||||
struct wf_impl_jsonrpc_proxy * proxy,
|
||||
struct wf_impl_timeout_manager * manager,
|
||||
int timeout,
|
||||
wf_impl_jsonrpc_send_fn * send,
|
||||
void * user_data);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user