Skip to content

Commit

Permalink
RDKB-51761 : Test Suite Enhancements (#175)
Browse files Browse the repository at this point in the history
* RDKB-51761 Test scenario to cover multiple rbus_open() call

Reason for change: Need to cover test app and unit test to have a test cases which covers multiple rbus_open() with same component name without rbus_close() call.
The test scenario should also cover regDataElements, rbus_set, rbus_get, addrow and methodinvoke after doing multiple rbus_open() function call
Test Procedure: Start rtrouted and ./rbus_test.sh
Risks: Medium
Priority: P1

Signed-off-by: Deepak_m <[email protected]>

* RDKB-51761 Test scenario to cover multiple rbus_open() call

Reason for change: Need to cover test app and unit test to have a test cases which covers multiple rbus_open() with same component name without rbus_close() call.
The test scenario should also cover regDataElements, rbus_set, rbus_get, addrow and methodinvoke after doing multiple rbus_open() function call
Test Procedure: Start rtrouted and ./rbus_test.sh
Risks: Medium
Priority: P1

Signed-off-by: Deepak_m <[email protected]>

* RDKB-51761 Test scenario to cover multiple rbus_open() call

Reason for change: Need to cover test app and unit test to have a test cases which covers multiple rbus_open() with same component name without rbus_close() call.
The test scenario should also cover regDataElements, rbus_set, rbus_get, addrow and methodinvoke after doing multiple rbus_open() function call
Test Procedure: Start rtrouted and ./rbus_test.sh
Risks: Medium
Priority: P1

Signed-off-by: Deepak_m <[email protected]>

* RDKB-51761 Test scenario to cover multiple rbus_open() call

Reason for change: Need to cover test app and unit test to have a test cases which covers multiple rbus_open() with same component name without rbus_close() call.
The test scenario should also cover regDataElements, rbus_set, rbus_get, addrow and methodinvoke after doing multiple rbus_open() function call
Test Procedure: Start rtrouted and ./rbus_test.sh
Risks: Medium
Priority: P1

Signed-off-by: Deepak_m <[email protected]>

* Update unit_tests.yml

RDKB-51761 Test scenario to cover multiple rbus_open() call

Reason for change: added unit tests verified on GitHub yml
Test Procedure: very unit_tests.yml success
Risks: Medium
Priority: P1

---------

Signed-off-by: Deepak_m <[email protected]>
  • Loading branch information
dm097 authored Nov 8, 2023
1 parent 277dc6b commit a23316a
Show file tree
Hide file tree
Showing 18 changed files with 1,691 additions and 12 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@ jobs:
export LD_LIBRARY_PATH=$PREFIX/lib
nohup ./bin/rbusTestProvider >/tmp/plog.txt &
./bin/rbusTestConsumer -a
- name: Run multiRbusOpenSubscribe Unit test
run: |
cd install/usr
export PREFIX=$PWD
export LD_LIBRARY_PATH=$PREFIX/lib
nohup ./bin/multiRbusOpenProvider >/tmp/log_multiRbusOpenProvider.txt &
./bin/multiRbusOpenConsumer
- name: Run multiRbusOpenGet Unit test
run: |
cd install/usr
export PREFIX=$PWD
export LD_LIBRARY_PATH=$PREFIX/lib
nohup ./bin/multiRbusOpenRbusGetProvider >/tmp/log_multiRbusOpenRbusGetProvider.txt &
./bin/multiRbusOpenRbusGetConsumer
- name: Run multiRbusOpenSet Unit test
run: |
cd install/usr
export PREFIX=$PWD
export LD_LIBRARY_PATH=$PREFIX/lib
nohup ./bin/multiRbusOpenRbusGetProvider >/tmp/log_multiRbusOpenRbusSetProvider.txt &
./bin/multiRbusOpenRbusSetConsumer
- name: Stop rtrouted
run: |
killall -9 rtrouted
Expand Down
10 changes: 0 additions & 10 deletions sampleapps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ add_executable(rbusOpenTelemetry consumer/rbusOpenTelemetry.c)
add_dependencies(rbusOpenTelemetry rbus)
target_link_libraries(rbusOpenTelemetry rbus)

add_executable(rbusThreadProvider provider/rbusThreadProvider.c)
add_dependencies(rbusThreadProvider rbus)
target_link_libraries(rbusThreadProvider rbus)

add_executable(rbusThreadConsumer consumer/rbusThreadConsumer.c)
add_dependencies(rbusThreadConsumer rbus)
target_link_libraries(rbusThreadConsumer rbus)

add_executable(rbusRawDataProvider provider/rbusRawDataProvider.c)
add_dependencies(rbusRawDataProvider rbus)
target_link_libraries(rbusRawDataProvider rbus)
Expand All @@ -159,8 +151,6 @@ install (TARGETS
rbusCSIProvider
rbusCSIConsumer
rbusDirectConsumer
rbusThreadProvider
rbusThreadConsumer
rbusRawDataProvider
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

Expand Down
22 changes: 22 additions & 0 deletions src/rbus/rbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@
} \
}

#define VERIFY_HANDLE(HANDLE) \
{ \
VERIFY_NULL(HANDLE); \
rbusHandle_t pTmp = (rbusHandle_t) HANDLE; \
if (!rbusHandleList_IsValidHandle(pTmp)) \
{ \
RBUSLOG_ERROR("handle is invalid"); \
return RBUS_ERROR_INVALID_HANDLE; \
} \
}
//********************************************************************************//

//******************************* STRUCTURES *************************************//
Expand Down Expand Up @@ -2907,6 +2917,7 @@ rbusError_t rbus_closeDirect(rbusHandle_t handle)

rbusError_t rbus_close(rbusHandle_t handle)
{
VERIFY_HANDLE(handle);
rbusError_t ret = RBUS_ERROR_SUCCESS;
rbusCoreError_t err = RBUSCORE_SUCCESS;
struct _rbusHandle* handleInfo = (struct _rbusHandle*)handle;
Expand Down Expand Up @@ -3021,6 +3032,7 @@ rbusError_t rbus_regDataElements(
rbusDataElement_t *elements)
{
int i;
VERIFY_HANDLE(handle);
rbusError_t rc = RBUS_ERROR_SUCCESS;
rbusCoreError_t err = RBUSCORE_SUCCESS;
struct _rbusHandle* handleInfo = (struct _rbusHandle*)handle;
Expand Down Expand Up @@ -3120,6 +3132,7 @@ rbusError_t rbus_unregDataElements(
int numDataElements,
rbusDataElement_t *elements)
{
VERIFY_HANDLE(handle);
struct _rbusHandle* handleInfo = (struct _rbusHandle*)handle;
int i;

Expand Down Expand Up @@ -3207,6 +3220,7 @@ rbusError_t rbus_get(rbusHandle_t handle, char const* name, rbusValue_t* value)
{
rbusError_t errorcode = RBUS_ERROR_SUCCESS;
rbusCoreError_t err = RBUSCORE_SUCCESS;
VERIFY_HANDLE(handle);
rbusMessage request, response;
int ret = -1;
struct _rbusHandle* handleInfo = (struct _rbusHandle*) handle;
Expand Down Expand Up @@ -3674,6 +3688,7 @@ rbusError_t rbus_set(rbusHandle_t handle, char const* name,rbusValue_t value, rb
{
rbusError_t errorcode = RBUS_ERROR_INVALID_INPUT;
rbusCoreError_t err = RBUSCORE_SUCCESS;
VERIFY_HANDLE(handle);
rbusMessage setRequest, setResponse;
struct _rbusHandle* handleInfo = (struct _rbusHandle*) handle;

Expand Down Expand Up @@ -4830,6 +4845,7 @@ rbusError_t rbusEvent_Subscribe(
int timeout)
{
rbusError_t errorcode;
VERIFY_HANDLE(handle);
struct _rbusHandle* handleInfo = (struct _rbusHandle*)handle;

VERIFY_NULL(handle);
Expand All @@ -4855,6 +4871,7 @@ rbusError_t rbusEvent_SubscribeAsync(
int timeout)
{
rbusError_t errorcode;
VERIFY_HANDLE(handle);
struct _rbusHandle* handleInfo = (struct _rbusHandle*)handle;

VERIFY_NULL(handle);
Expand All @@ -4876,6 +4893,7 @@ rbusError_t rbusEvent_Unsubscribe(
rbusHandle_t handle,
char const* eventName)
{
VERIFY_HANDLE(handle);
struct _rbusHandle* handleInfo = (struct _rbusHandle*)handle;
rbusEventSubscriptionInternal_t* subInternal;

Expand Down Expand Up @@ -4942,6 +4960,7 @@ rbusError_t rbusEvent_UnsubscribeRawData(
rbusHandle_t handle,
char const* eventName)
{
VERIFY_HANDLE(handle);
struct _rbusHandle* handleInfo = (struct _rbusHandle*)handle;
char rawDataTopic[RBUS_MAX_NAME_LENGTH] = {0};
rbusEventSubscriptionInternal_t* subInternal;
Expand Down Expand Up @@ -4992,6 +5011,7 @@ rbusError_t rbusEvent_SubscribeEx(
int timeout)
{
rbusError_t errorcode = RBUS_ERROR_SUCCESS;
VERIFY_HANDLE(handle);
struct _rbusHandle* handleInfo = (struct _rbusHandle*)handle;
int i;

Expand Down Expand Up @@ -5559,6 +5579,7 @@ rbusError_t rbusMethod_Invoke(
rbusObject_t inParams,
rbusObject_t* outParams)
{
VERIFY_HANDLE(handle);
struct _rbusHandle* handleInfo = (struct _rbusHandle*)handle;
VERIFY_NULL(handle);
VERIFY_NULL(methodName);
Expand Down Expand Up @@ -5610,6 +5631,7 @@ rbusError_t rbusMethod_InvokeAsync(
rbusMethodAsyncRespHandler_t callback,
int timeout)
{
VERIFY_HANDLE(handle);
struct _rbusHandle* handleInfo = (struct _rbusHandle*)handle;
pthread_t pid;
rbusMethodInvokeAsyncData_t* data;
Expand Down
23 changes: 23 additions & 0 deletions src/rbus/rbus_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@ static rtVector gHandleList = NULL;

#define VERIFY_NULL(T,R) if(NULL == T){ RBUSLOG_ERROR(#T" is NULL"); R; }

bool rbusHandleList_IsValidHandle(struct _rbusHandle* handle)
{
struct _rbusHandle* tmphandle = NULL;
if (handle == NULL)
{
return false;
}
int i;
if(gHandleList)
{
int len = rtVector_Size(gHandleList);
for(i = 0; i < len; i++)
{
tmphandle = (struct _rbusHandle*)rtVector_At(gHandleList, i);
if(tmphandle == handle)
{
return true;
}
}
}
return false;
}

void rbusHandleList_Add(struct _rbusHandle* handle)
{
VERIFY_NULL(handle,return);
Expand Down
1 change: 1 addition & 0 deletions src/rbus/rbus_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct _rbusHandle
pthread_mutex_t handle_subsMutex;
};

bool rbusHandleList_IsValidHandle(struct _rbusHandle* handle);
void rbusHandleList_Add(struct _rbusHandle* handle);
void rbusHandleList_Remove(struct _rbusHandle* handle);
bool rbusHandleList_IsEmpty();
Expand Down
149 changes: 148 additions & 1 deletion test/rbus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/src/rtmessage)
include_directories(${PROJECT_SOURCE_DIR}/src/core)
include_directories(${PROJECT_SOURCE_DIR}/src/rbus)
include_directories(${PROJECT_SOURCE_DIR}/test/rbus/common)

add_executable(rbusTestProvider
provider/rbusTestProvider.c
Expand All @@ -29,6 +30,44 @@ add_executable(rbusTestProvider
add_dependencies(rbusTestProvider rbus)
target_link_libraries(rbusTestProvider rbus)

add_executable(multiRbusOpenProvider
multiRbusOpenProvider/multiRbusOpenProvider.c
common/runningParamHelper.c
common/testValueHelper.c)
add_dependencies(multiRbusOpenProvider rbus)
target_link_libraries(multiRbusOpenProvider rbus)

add_executable(multiRbusOpenMethodProvider
multiRbusOpenMethodProvider/multiRbusOpenMethodProvider.c
common/runningParamHelper.c
common/testValueHelper.c)
add_dependencies(multiRbusOpenMethodProvider rbus)
target_link_libraries(multiRbusOpenMethodProvider rbus)

add_executable(rbusOpenRegRbusOpenProvider
multiRbusOpenProvider/rbusOpenRegRbusOpenProvider.c
common/runningParamHelper.c
common/testValueHelper.c)
add_dependencies(rbusOpenRegRbusOpenProvider rbus)
target_link_libraries(rbusOpenRegRbusOpenProvider rbus)

add_executable(multiRbusOpenRbusGetProvider
multiRbusOpenRbusGetProvider/multiRbusOpenRbusGetProvider.c
common/runningParamHelper.c
common/testValueHelper.c)
add_dependencies(multiRbusOpenRbusGetProvider rbus)
target_link_libraries(multiRbusOpenRbusGetProvider rbus)

add_executable(multiProviderThreadsForSingleEvent
multiProviderThreadsForSingleEvent/multiProviderThreadsForSingleEvent.c)
add_dependencies(multiProviderThreadsForSingleEvent rbus)
target_link_libraries(multiProviderThreadsForSingleEvent rbus)

add_executable(multiConsumerThreadsForSingleEvent
multiConsumerThreadsForSingleEvent/multiConsumerThreadsForSingleEvent.c)
add_dependencies(multiConsumerThreadsForSingleEvent rbus)
target_link_libraries(multiConsumerThreadsForSingleEvent rbus)

add_executable(rbusTestConsumer
consumer/rbusTestConsumer.c
consumer/elementTree.c
Expand All @@ -48,9 +87,117 @@ add_executable(rbusTestConsumer
common/testValueHelper.c)
add_dependencies(rbusTestConsumer rbus)
target_link_libraries(rbusTestConsumer rbus)

add_executable(multiRbusOpenConsumer
multiRbusOpenConsumer/multiRbusOpenConsumer.c
consumer/elementTree.c
consumer/valueAPI.c
consumer/propertyAPI.c
consumer/objectAPI.c
consumer/value.c
consumer/valueChange.c
consumer/subscribe.c
consumer/subscribeEx.c
consumer/tables.c
consumer/events.c
consumer/methods.c
consumer/filter.c
consumer/partialPath.c
common/runningParamHelper.c
common/testValueHelper.c)
add_dependencies(multiRbusOpenConsumer rbus)
target_link_libraries(multiRbusOpenConsumer rbus)

add_executable(multiRbusOpenMethodConsumer
multiRbusOpenMethodConsumer/multiRbusOpenMethodConsumer.c
consumer/elementTree.c
consumer/valueAPI.c
consumer/propertyAPI.c
consumer/objectAPI.c
consumer/value.c
consumer/valueChange.c
consumer/subscribe.c
consumer/subscribeEx.c
consumer/tables.c
consumer/events.c
consumer/methods.c
consumer/filter.c
consumer/partialPath.c
common/runningParamHelper.c
common/testValueHelper.c)
add_dependencies(multiRbusOpenMethodConsumer rbus)
target_link_libraries(multiRbusOpenMethodConsumer rbus)

add_executable(rbusOpenSubRbusOpenConsumer
multiRbusOpenConsumer/rbusOpenSubRbusOpenConsumer.c
consumer/elementTree.c
consumer/valueAPI.c
consumer/propertyAPI.c
consumer/objectAPI.c
consumer/value.c
consumer/valueChange.c
consumer/subscribe.c
consumer/subscribeEx.c
consumer/tables.c
consumer/events.c
consumer/methods.c
consumer/filter.c
consumer/partialPath.c
common/runningParamHelper.c
common/testValueHelper.c)
add_dependencies(rbusOpenSubRbusOpenConsumer rbus)
target_link_libraries(rbusOpenSubRbusOpenConsumer rbus)

add_executable(multiRbusOpenRbusGetConsumer
multiRbusOpenRbusGetConsumer/multiRbusOpenRbusGetConsumer.c
consumer/elementTree.c
consumer/valueAPI.c
consumer/propertyAPI.c
consumer/objectAPI.c
consumer/value.c
consumer/valueChange.c
consumer/subscribe.c
consumer/subscribeEx.c
consumer/tables.c
consumer/events.c
consumer/methods.c
consumer/filter.c
consumer/partialPath.c
common/runningParamHelper.c
common/testValueHelper.c)
add_dependencies(multiRbusOpenRbusGetConsumer rbus)
target_link_libraries(multiRbusOpenRbusGetConsumer rbus)

add_executable(multiRbusOpenRbusSetConsumer
multiRbusOpenRbusSetConsumer/multiRbusOpenRbusSetConsumer.c
consumer/elementTree.c
consumer/valueAPI.c
consumer/propertyAPI.c
consumer/objectAPI.c
consumer/value.c
consumer/valueChange.c
consumer/subscribe.c
consumer/subscribeEx.c
consumer/tables.c
consumer/events.c
consumer/methods.c
consumer/filter.c
consumer/partialPath.c
common/runningParamHelper.c
common/testValueHelper.c)
add_dependencies(multiRbusOpenRbusSetConsumer rbus)
target_link_libraries(multiRbusOpenRbusSetConsumer rbus)


set (CMAKE_C_FLAGS "-Wno-overflow ${CMAKE_C_FLAGS}")

install (TARGETS rbusTestProvider rbusTestConsumer
install (TARGETS
multiRbusOpenConsumer multiRbusOpenProvider
multiRbusOpenMethodProvider multiRbusOpenMethodConsumer
multiRbusOpenRbusGetProvider multiRbusOpenRbusGetConsumer multiRbusOpenRbusSetConsumer
multiProviderThreadsForSingleEvent multiConsumerThreadsForSingleEvent
rbusOpenRegRbusOpenProvider rbusOpenSubRbusOpenConsumer
rbusTestProvider rbusTestConsumer
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

install(FILES rbus_test.sh
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit a23316a

Please sign in to comment.