Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Unit test cases for webcfg events #202

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/webcfg_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,8 @@ int checkWebcfgTimer();
int addToEventQueue(char *buf);
void sendSuccessNotification(webconfig_tmp_data_t *subdoc_node, char *name, uint32_t version, uint16_t txid);
WEBCFG_STATUS startWebcfgTimer(expire_timer_t *timer_node, char *name, uint16_t transID, uint32_t timeout);
WEBCFG_STATUS stopWebcfgTimer(expire_timer_t *temp, char *name, uint16_t trans_id);
int checkTimerExpired (char **exp_doc);
void createTimerExpiryEvent(char *docName, uint16_t transid);
WEBCFG_STATUS updateTimerList(expire_timer_t *temp, int status, char *docname, uint16_t transid, uint32_t timeout);
WEBCFG_STATUS deleteFromTimerList(char* doc_name);
WEBCFG_STATUS checkDBVersion(char *docname, uint32_t version);
WEBCFG_STATUS validateEvent(webconfig_tmp_data_t *temp, char *docname, uint16_t txid);
expire_timer_t * getTimerNode(char *docname);
void handleConnectedClientNotify(char *status);
Expand Down Expand Up @@ -98,6 +94,17 @@ expire_timer_t * get_global_timer_node(void)
tmp = g_timer_head;
pthread_mutex_unlock (&expire_timer_mut);
return tmp;
}
void set_numOfEvents(int num)
{
numOfEvents = num;
}

void set_global_timer_node(expire_timer_t * new)
{
pthread_mutex_lock (&expire_timer_mut);
g_timer_head = new;
pthread_mutex_unlock (&expire_timer_mut);
}

void free_event_params_struct(event_params_t *param)
Expand Down Expand Up @@ -797,12 +804,6 @@ WEBCFG_STATUS updateTimerList(expire_timer_t *temp, int status, char *docname, u
temp->running = status;
temp->txid = transid;
temp->timeout = timeout;
if(strcmp(temp->subdoc_name, docname) !=0)
{
WEBCFG_FREE(temp->subdoc_name);
temp->subdoc_name = NULL;
temp->subdoc_name = strdup(docname);
}
WebcfgInfo("doc timer %s is updated with txid %lu timeout %lu\n", docname, (long)temp->txid, (long)temp->timeout);
pthread_mutex_unlock (&expire_timer_mut);
return WEBCFG_SUCCESS;
Expand Down
8 changes: 7 additions & 1 deletion src/webcfg_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,11 @@ pthread_t get_global_process_threadid();
pthread_cond_t *get_global_event_con(void);
pthread_mutex_t *get_global_event_mut(void);
int checkTmpNACKstatus(webconfig_tmp_data_t *temp, char *docname);

WEBCFG_STATUS checkDBVersion(char *docname, uint32_t version);
WEBCFG_STATUS updateTimerList(expire_timer_t *temp, int status, char *docname, uint16_t transid, uint32_t timeout);
WEBCFG_STATUS deleteFromTimerList(char* doc_name);
expire_timer_t * get_global_timer_node(void);
void set_global_timer_node(expire_timer_t * new);
void set_numOfEvents(int num);
WEBCFG_STATUS stopWebcfgTimer(expire_timer_t *temp, char *name, uint16_t trans_id);
#endif
30 changes: 30 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,36 @@ target_link_libraries (test_events_supp -llibparodus -lnanomsg)
endif (FEATURE_SUPPORT_AKER)

target_link_libraries (test_events_supp gcov -Wl,--no-as-needed )


#-------------------------------------------------------------------------------
# test_webcfgevents
#-------------------------------------------------------------------------------
add_test(NAME test_webcfgevents COMMAND ${MEMORY_CHECK} ./test_webcfgevents)
set(SOURCES test_webcfgevents.c ../src/webcfg_param.c ../src/webcfg_multipart.c ../src/webcfg_helpers.c ../src/webcfg.c ../src/webcfg_auth.c ../src/webcfg_notify.c ../src/webcfg_db.c ../src/webcfg_pack.c ../src/webcfg_blob.c ../src/webcfg_event.c ../src/webcfg_generic_pc.c ../src/webcfg_metadata.c ../src/webcfg_timer.c )

if (WEBCONFIG_BIN_SUPPORT)
set(SOURCES ${SOURCES} ../src/webcfg_rbus.c)
endif (WEBCONFIG_BIN_SUPPORT)

if (FEATURE_SUPPORT_AKER)
set(SOURCES ${SOURCES} ../src/webcfg_client.c ../src/webcfg_aker.c)
endif (FEATURE_SUPPORT_AKER)

add_executable(test_webcfgevents ${SOURCES})

target_link_libraries (test_webcfgevents -lcunit -lmsgpackc -lcurl -lpthread -lm -luuid -ltrower-base64 -lwdmp-c -lcimplog -lcjson -lwrp-c)

if (WEBCONFIG_BIN_SUPPORT)
target_link_libraries (test_webcfgevents -lrbus)
endif (WEBCONFIG_BIN_SUPPORT)

if (FEATURE_SUPPORT_AKER)
target_link_libraries (test_webcfgevents -llibparodus -lnanomsg)
endif (FEATURE_SUPPORT_AKER)

target_link_libraries (test_webcfgevents gcov -Wl,--no-as-needed )

#-------------------------------------------------------------------------------
# test_metadata
#-------------------------------------------------------------------------------
Expand Down
Loading
Loading