Skip to content

Commit

Permalink
RDKB-51761 : Test Suite Enhancements (#181)
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 OR verify with unit_test.yml
Risks: Medium
Priority: P1
Signed-off-by: Deepak_m <[email protected]>

RDKB-51761 : Test Suite Enhancements  (#175)

* 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]>

RDKB-51761 : Test Suite Enhancements (#179)

* 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 OR verify with unit_test.yml
Risks: Medium
Priority: P1

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

RDKB-51761 : Test Suite Enhancements (#184)

* 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 OR verify with unit_test.yml
Risks: Medium
Priority: P1

RDKB-52662 Update the multi rbusopen Tests (#188)

Reason for change: Fix for multiRbusOpenRbusGetProvider crash on device
Test Procedure: Start rtrouted and ./rbus_test.sh OR verify with unit_test.yml
Risks: Medium
Priority: P1

Signed-off-by: Deepak_m <[email protected]>
  • Loading branch information
dm097 authored and karuna2git committed Dec 26, 2023
1 parent 7e4f0be commit bd340c3
Show file tree
Hide file tree
Showing 19 changed files with 1,699 additions and 20 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,34 @@ jobs:
export LD_LIBRARY_PATH=$PREFIX/lib
nohup ./bin/rbusTestProvider >/tmp/plog.txt &
./bin/rbusTestConsumer -a
- name: Run multiRbusOpenMethod Unit Test
run: |
cd install/usr
export PREFIX=$PWD
export LD_LIBRARY_PATH=$PREFIX/lib
./bin/multiRbusOpenMethodProvider &
./bin/multiRbusOpenMethodConsumer &
- 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
5 changes: 3 additions & 2 deletions include/rbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ typedef enum _rbusError
RBUS_ERROR_INVALID_METHOD, /**< Invalid Method */
RBUS_ERROR_NOSUBSCRIBERS, /**< No subscribers present */
RBUS_ERROR_SUBSCRIPTION_ALREADY_EXIST, /**< The subscription already exists*/
RBUS_ERROR_INVALID_NAMESPACE /**< Invalid namespace as per standard */
RBUS_ERROR_INVALID_NAMESPACE /**< Invalid namespace as per standard */
} rbusError_t;


Expand Down Expand Up @@ -1713,8 +1713,9 @@ rbusError_t rbusEvent_PublishRawData(
provider is responsible in sending the errorcode and error string.
other error like no method/handling issues, internal err
will be taken care by rbus.
consumer side errors returning (RBUS_ERROR_INVALID_HANDLE and RBUS_ERROR_INVALID_INPUT) will not contain outparams for input validation.
* @return RBus error code as defined by rbusError_t.
* Possible values are: RBUS_ERROR_SUCCESS, RBUS_ERROR_BUS_ERROR, RBUS_ERROR_INVALID_INPUT
* Possible values are: RBUS_ERROR_SUCCESS, RBUS_ERROR_BUS_ERROR, RBUS_ERROR_INVALID_INPUT, RBUS_ERROR_TIMEOUT, RBUS_ERROR_INVALID_METHOD, RBUS_ERROR_INVALID_HANDLE
* @ingroup Methods
*/
rbusError_t rbusMethod_Invoke(
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
33 changes: 27 additions & 6 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,9 +5579,10 @@ rbusError_t rbusMethod_Invoke(
rbusObject_t inParams,
rbusObject_t* outParams)
{
struct _rbusHandle* handleInfo = (struct _rbusHandle*)handle;
VERIFY_NULL(handle);
VERIFY_HANDLE(handle);
VERIFY_NULL(methodName);

struct _rbusHandle* handleInfo = (struct _rbusHandle*)handle;

if (handleInfo->m_handleType != RBUS_HWDL_TYPE_REGULAR)
return RBUS_ERROR_INVALID_HANDLE;
Expand Down Expand Up @@ -5610,15 +5631,15 @@ rbusError_t rbusMethod_InvokeAsync(
rbusMethodAsyncRespHandler_t callback,
int timeout)
{
VERIFY_HANDLE(handle);
VERIFY_NULL(methodName);
VERIFY_NULL(callback);

struct _rbusHandle* handleInfo = (struct _rbusHandle*)handle;
pthread_t pid;
rbusMethodInvokeAsyncData_t* data;
int err = 0;

VERIFY_NULL(handle);
VERIFY_NULL(methodName);
VERIFY_NULL(callback);

if (handleInfo->m_handleType != RBUS_HWDL_TYPE_REGULAR)
return RBUS_ERROR_INVALID_HANDLE;

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
Loading

0 comments on commit bd340c3

Please sign in to comment.