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:
@@ -10,9 +10,9 @@
|
||||
#include "webfuse/provider/impl/client_protocol.h"
|
||||
#include "webfuse/provider/impl/client_config.h"
|
||||
#include "webfuse/provider/impl/url.h"
|
||||
#include "webfuse/core/lws_log.h"
|
||||
|
||||
#define WFP_PROTOCOL ("fs")
|
||||
#define WFP_DISABLE_LWS_LOG 0
|
||||
#define WFP_CLIENT_PROTOCOL_COUNT 2
|
||||
|
||||
struct wfp_client
|
||||
@@ -29,7 +29,7 @@ struct wfp_client
|
||||
struct wfp_client * wfp_impl_client_create(
|
||||
struct wfp_client_config * config)
|
||||
{
|
||||
lws_set_log_level(WFP_DISABLE_LWS_LOG, NULL);
|
||||
wf_lwslog_disable();
|
||||
|
||||
struct wfp_client * client = malloc(sizeof(struct wfp_client));
|
||||
if (NULL != client)
|
||||
@@ -99,6 +99,12 @@ void wfp_impl_client_disconnect(
|
||||
// ToDo: implement me
|
||||
}
|
||||
|
||||
bool wfp_impl_client_is_connected(
|
||||
struct wfp_client * client)
|
||||
{
|
||||
return client->protocol.is_connected;
|
||||
}
|
||||
|
||||
void wfp_impl_client_service(
|
||||
struct wfp_client * client,
|
||||
int timeout_ms)
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#ifndef WF_PROVIDER_IMPL_CLIENT_H
|
||||
#define WF_PROVIDER_IMPL_CLIENT_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
@@ -27,13 +31,12 @@ extern void wfp_impl_client_connect(
|
||||
extern void wfp_impl_client_disconnect(
|
||||
struct wfp_client * client);
|
||||
|
||||
extern void wfp_impl_client_settimeout(
|
||||
struct wfp_client * client,
|
||||
unsigned int timepoint);
|
||||
|
||||
extern void wfp_impl_client_dispose(
|
||||
struct wfp_client * client);
|
||||
|
||||
extern bool wfp_impl_client_is_connected(
|
||||
struct wfp_client * client);
|
||||
|
||||
extern void wfp_impl_client_service(
|
||||
struct wfp_client * client,
|
||||
int timeout_ms);
|
||||
|
||||
@@ -35,6 +35,15 @@ static void wfp_impl_client_protocol_process_request(
|
||||
json_t * request = json_loadb(message, length, 0, NULL);
|
||||
if (NULL != request)
|
||||
{
|
||||
// FIXME: is_connected should be invoked, when filesystem added
|
||||
if ((!protocol->is_connected) && (NULL != json_object_get(request, "result")))
|
||||
{
|
||||
protocol->is_connected = true;
|
||||
protocol->provider.connected(protocol->user_data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct wfp_impl_invokation_context context =
|
||||
{
|
||||
.provider = &protocol->provider,
|
||||
@@ -84,13 +93,15 @@ static int wfp_impl_client_protocol_callback(
|
||||
{
|
||||
case LWS_CALLBACK_CLIENT_ESTABLISHED:
|
||||
wfp_impl_client_protocol_add_filesystem(protocol);
|
||||
protocol->provider.connected(protocol->user_data);
|
||||
// Defer is_connected until response received
|
||||
break;
|
||||
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
|
||||
protocol->is_connected = false;
|
||||
protocol->provider.disconnected(protocol->user_data);
|
||||
break;
|
||||
case LWS_CALLBACK_CLIENT_CLOSED:
|
||||
protocol->provider.connected(protocol->user_data);
|
||||
protocol->is_connected = false;
|
||||
protocol->provider.disconnected(protocol->user_data);
|
||||
break;
|
||||
case LWS_CALLBACK_CLIENT_RECEIVE:
|
||||
wfp_impl_client_protocol_process_request(protocol, in, len);
|
||||
@@ -126,6 +137,7 @@ void wfp_impl_client_protocol_init(
|
||||
struct wfp_provider const * provider,
|
||||
void * user_data)
|
||||
{
|
||||
protocol->is_connected = false;
|
||||
wf_slist_init(&protocol->messages);
|
||||
|
||||
protocol->wsi = NULL;
|
||||
|
||||
@@ -16,6 +16,7 @@ struct lws_protocols;
|
||||
|
||||
struct wfp_client_protocol
|
||||
{
|
||||
bool is_connected;
|
||||
struct wfp_request request;
|
||||
struct wfp_provider provider;
|
||||
void * user_data;
|
||||
|
||||
Reference in New Issue
Block a user