Skip to content

Commit

Permalink
Merge branch 'main' into Opendirect_rawdata
Browse files Browse the repository at this point in the history
  • Loading branch information
karuna2git authored Nov 21, 2023
2 parents d391638 + 14f505c commit 865de81
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 53 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ jobs:
export LD_LIBRARY_PATH=$PREFIX/lib
nohup ./bin/rbusTestProvider >/tmp/plog.txt &
./bin/rbusTestConsumer -a
- name: Run multiRbusOpenMethod Unit test
- name: Run multiRbusOpenMethod Unit Test
run: |
cd install/usr
export PREFIX=$PWD
export LD_LIBRARY_PATH=$PREFIX/lib
nohup ./bin/multiRbusOpenMethodProvider >/tmp/log_multiRbusOpenMethodProvider.txt &
./bin/multiRbusOpenMethodConsumer
./bin/multiRbusOpenMethodProvider &
./bin/multiRbusOpenMethodConsumer &
- name: Run multiRbusOpenSubscribe Unit test
run: |
cd install/usr
Expand Down
3 changes: 2 additions & 1 deletion include/rbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -1714,8 +1714,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
11 changes: 5 additions & 6 deletions src/rbus/rbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -5920,9 +5920,9 @@ rbusError_t rbusMethod_Invoke(
rbusObject_t* outParams)
{
VERIFY_HANDLE(handle);
struct _rbusHandle* handleInfo = (struct _rbusHandle*)handle;
VERIFY_NULL(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 @@ -5972,15 +5972,14 @@ rbusError_t rbusMethod_InvokeAsync(
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
2 changes: 2 additions & 0 deletions src/rtmessage/rtHashMap.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ struct _rtHashMap

static rtVector rtHashMap_GetBucket(rtHashMap hashmap, const void* key)
{
if(!rtVector_Size(hashmap->buckets))
return NULL;
uint32_t hash = hashmap->key_hasher(hashmap, key);
if(rtVector_Size(hashmap->buckets) > (size_t)hash)
return rtVector_At(hashmap->buckets, hash);
Expand Down
82 changes: 39 additions & 43 deletions test/rbus/multiRbusOpenMethodConsumer/multiRbusOpenMethodConsumer.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,59 +100,51 @@ int main(int argc, char *argv[])
rbusValue_Release(value2);

rc1 = rbusMethod_Invoke(handle1, "Device.Methods.SimpleMethod()", inParams1, &outParams1);
rbusObject_Release(inParams1);
if(rc1 != RBUS_ERROR_INVALID_HANDLE)
{
printf("multiRbusOpenMethodConsumer: rbusMethod_Invoke(Device.Methods.SimpleMethod()) using handle1 return err:%d\n", rc1);
rbusObject_fwrite(outParams1, 1, stdout);
rbusObject_Release(outParams1);
exit(EXIT_FAILURE);
}

rc2 = rbusMethod_Invoke(handle2, "Device.Methods.SimpleMethod()", inParams2, &outParams2);
rbusObject_fwrite(outParams2, 1, stdout);
rbusObject_Release(outParams2);
rbusObject_Release(inParams2);
if(rc2 != RBUS_ERROR_SUCCESS)
{
printf("multiRbusOpenMethodConsumer: rbusMethod_Invoke(Device.Methods.SimpleMethod()) using handle2 return err:%d\n", rc2);
exit(EXIT_FAILURE);
}

if(rc1 == RBUS_ERROR_SUCCESS)
{
rbusObject_fwrite(outParams1, 1, stdout);
rbusObject_Release(outParams1);
}
if(rc2 == RBUS_ERROR_SUCCESS)
{
rbusObject_fwrite(outParams2, 1, stdout);
rbusObject_Release(outParams2);
}
rbusObject_Release(inParams1);
rbusObject_Release(inParams2);

/*Test to check the Outparams error msg handling
This testcase reads the provider specific error code and prints it.
This test is expected to return error */

printf("\n This is a negative test to check the error values generated by the Provider \n");
rc1 = rbusMethod_Invoke(handle1, "Device.Methods.SimpleMethod1()", NULL, &outParams1);

if(rc1 != RBUS_ERROR_INVALID_HANDLE)
{
printf("multiRbusOpenMethodConsumer: rbusMethod_Invoke(Device.Methods.SimpleMethod1()) using handle1 return err:%d\n", rc1);
rbusObject_fwrite(outParams1, 1, stdout);
rbusObject_Release(outParams1);
exit(EXIT_FAILURE);
}

rc2 = rbusMethod_Invoke(handle2, "Device.Methods.SimpleMethod1()", NULL, &outParams2);
if(rc2 != RBUS_ERROR_SUCCESS)

rbusObject_fwrite(outParams2, 1, stdout);
rbusObject_Release(outParams2);
if(rc2 != RBUS_ERROR_INVALID_METHOD)
{
printf("multiRbusOpenMethodConsumer: rbusMethod_Invoke(Device.Methods.SimpleMethod1()) using handle2 %s:%d\n",
rc2 == RBUS_ERROR_SUCCESS ? "success" : "fail",rc2);
rc2 == RBUS_ERROR_INVALID_METHOD ? "success" : "fail",rc2);
exit(EXIT_FAILURE);
}

if(rc1 != RBUS_ERROR_INVALID_HANDLE && rc1 != RBUS_ERROR_SUCCESS)
{
rbusObject_fwrite(outParams1, 1, stdout);
rbusObject_Release(outParams1);
}

if(rc2 != RBUS_ERROR_SUCCESS)
{
rbusObject_fwrite(outParams2, 1, stdout);
rbusObject_Release(outParams2);
}

printf("\n\n");
rbusObject_Init(&inParams1, NULL);

Expand Down Expand Up @@ -180,22 +172,27 @@ int main(int argc, char *argv[])
rbusValue_Release(value2);

rc1 = rbusMethod_InvokeAsync(handle1, "Device.Methods.AsyncMethod()", inParams1, asyncMethodHandler, 0);


printf("multiRbusOpenMethodConsumer: rbusMethod_InvokeAsync(Device.Methods.AsyncMethod()) for handle1 %s with err :%d\n", rc1 == RBUS_ERROR_INVALID_HANDLE ? "success" : "fail",rc1);

rbusObject_Release(inParams1);
if(rc1 != RBUS_ERROR_INVALID_HANDLE)
{
printf("multiRbusOpenMethodConsumer: rbusMethod_InvokeAsync(Device.Methods.AsyncMethod()) for handle1 failed, err:%d\n", rc1);
exit(EXIT_FAILURE);
}
rc2 = rbusMethod_InvokeAsync(handle2, "Device.Methods.AsyncMethod()", inParams2, asyncMethodHandler, 0);
printf("multiRbusOpenMethodConsumer: rbusMethod_InvokeAsync(Device.Methods.AsyncMethod()) for handle2 %s:%d\n",
rc2 == RBUS_ERROR_SUCCESS ? "success" : "fail",rc2);

if(rc2 != RBUS_ERROR_SUCCESS)
{
printf("multiRbusOpenMethodConsumer: rbusMethod_InvokeAsync(Device.Methods.AsyncMethod()) for handle2 failed, err:%d\n", rc2);
exit(EXIT_FAILURE);
}

rc2 = rbusMethod_Invoke(handle2, "Device.Methods.AsyncMethod()", inParams2, &outParams2);
printf("multiRbusOpenMethodConsumer negative Test: rbusMethod_Invoke(Device.Methods.AsyncMethod()) using handle2 %s with return:%d\n", rc2 == RBUS_ERROR_SUCCESS ? "success" : "fail",rc2);

if(rc2 == RBUS_ERROR_SUCCESS)
{
rbusObject_fwrite(outParams2, 1, stdout);
rbusObject_Release(outParams2);
rbusObject_fwrite(outParams2, 1, stdout);
rbusObject_Release(outParams2);
rbusObject_Release(inParams2);
if(rc2 != RBUS_ERROR_TIMEOUT)
{
printf("multiRbusOpenMethodConsumer negative Test: rbusMethod_Invoke(Device.Methods.AsyncMethod()) using handle2 failed, err:%d\n", rc2);
exit(EXIT_FAILURE);
}

sleep(10);
Expand All @@ -204,18 +201,17 @@ int main(int argc, char *argv[])
if(rc2 != RBUS_ERROR_SUCCESS)
{
printf("multiRbusOpenMethodConsumer: rbus_close handle2 failed: %d\n", rc2);
exit(EXIT_FAILURE);
}

exit2:
rc1 = rbus_close(handle1);
if(rc1 != RBUS_ERROR_INVALID_HANDLE)
{
printf("multiRbusOpenMethodConsumer: rbus_close handle1 err: %d\n", rc1);
exit(EXIT_FAILURE);
}
exit1:
rbusObject_Release(inParams1);
rbusObject_Release(inParams2);

printf("multiRbusOpenMethodConsumer: exit\n");
return rc2;
}
Expand Down

0 comments on commit 865de81

Please sign in to comment.