Skip to content

Commit

Permalink
test now running, one remaining issue with the test_util and dangling…
Browse files Browse the repository at this point in the history
… ref count in the test read-only param and child objects

Signed-off-by: raphacan <[email protected]>
  • Loading branch information
raphacan committed Apr 8, 2024
1 parent bc18079 commit 8c59240
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 32 deletions.
39 changes: 10 additions & 29 deletions conformance_tests/test_tiovx/test_ext_supplementary_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -813,44 +813,27 @@ void testParentAndChild(vx_reference parent, vx_reference child, const char * ms
EXPECT_NE_VX_STATUS(VX_SUCCESS, vxCopyUserDataObject(child_data, 0, sizeof(test2), &test2, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST));
/* return parent to original data */
EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxCopyUserDataObject(parent_data, 0, sizeof(orig), &orig, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST));

/* read again the original state*/
EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxCopyUserDataObject(parent_data, 0, sizeof(test2), &test2, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxCopyUserDataObject(parent_data, 0, sizeof(test1), &test1, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
//tivx_obj_desc_user_data_object_t *obj_desc_before;// = (tivx_obj_desc_user_data_object_t *)parent_data->base.obj_desc;

EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxCopyUserDataObject(parent_data, 0, sizeof(orig), &orig, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxCopyUserDataObject(child_data, 0, sizeof(orig), &orig, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
/* Now actually set the child user data object & re-get the supplementary data */
EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxSetSupplementaryUserDataObject(child, child_data));
EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxReleaseUserDataObject(&child_data));
child_data = vxGetSupplementaryUserDataObject(child, "user_data_t", &status);
EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxReleaseUserDataObject(&parent_data));
parent_data = vxGetSupplementaryUserDataObject(parent, "user_data_t", &status);
//tivx_obj_desc_user_data_object_t *obj_desc_after = (tivx_obj_desc_user_data_object_t *)parent_data->base.obj_desc;
/* read again the original state*/
EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxCopyUserDataObject(parent_data, 0, sizeof(test2), &test2, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST));
EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxCopyUserDataObject(parent_data, 0, sizeof(test1), &test1, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));

EXPECT_EQ_VX_STATUS(VX_SUCCESS, status);

test2.numbers[2] = 45;
EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxCopyUserDataObject(child_data, 0, sizeof(test2), &test2, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
if (test1.numbers[2] == test2.numbers[2])
if (orig.numbers[2] != test2.numbers[2])
{
printf("Can not read data back correctly for %s \n", msg);
status = (vx_enum) VX_FAILURE;
}
EXPECT_EQ_VX_STATUS(VX_SUCCESS, status);

/* Should be able to copy to it now */
status = vxCopyUserDataObject(child_data, 0, sizeof(test1), &test1, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
if ((vx_enum)VX_SUCCESS != status)
{
printf("Can not write to the new supplementary data object for %s \n", msg);
}
EXPECT_EQ_VX_STATUS(VX_SUCCESS, status);

EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxCopyUserDataObject(child_data, 0, sizeof(test1), &test1, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST));
test2.numbers[2] = 45;
status = vxCopyUserDataObject(child_data, 0, sizeof(test2), &test2, VX_READ_ONLY, VX_MEMORY_TYPE_HOST);
EXPECT_EQ_VX_STATUS(VX_SUCCESS, status);
EXPECT_EQ_VX_STATUS(VX_SUCCESS,vxCopyUserDataObject(child_data, 0, sizeof(test2), &test2, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
if (test1.numbers[2] != test2.numbers[2])
{
printf("Can not read changed data back correctly for %s \n", msg);
Expand All @@ -859,14 +842,12 @@ void testParentAndChild(vx_reference parent, vx_reference child, const char * ms
EXPECT_EQ_VX_STATUS(VX_SUCCESS, status);

test2.numbers[2] = 45;
#if 1
EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxCopyUserDataObject(parent_data, 0, sizeof(test2), &test2, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
if (orig.numbers[2] == test2.numbers[2])
if (orig.numbers[2] != test2.numbers[2])
{
printf("changed data does affect parent for%s \n", msg);
status = (vx_enum) VX_FAILURE;
}
#endif
EXPECT_EQ_VX_STATUS(VX_SUCCESS, status);
VX_CALL(vxReleaseUserDataObject(&child_data));
VX_CALL(vxReleaseUserDataObject(&parent_data));
Expand All @@ -892,7 +873,7 @@ TEST(supplementary_data, testChildren)
//EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxSetSupplementaryUserDataObject((vx_reference)tensor, exemplar));
EXPECT_EQ_VX_STATUS(VX_SUCCESS, vxSetSupplementaryUserDataObject((vx_reference)image, exemplar));
/* Now all children and grand children should have read-only supplementary data from the parent, check it all */
//testParentAndChild((vx_reference)image, (vx_reference)grandchildImageFromImage, "image created from child of image");
testParentAndChild((vx_reference)image, (vx_reference)grandchildImageFromImage, "image created from child of image");
testParentAndChild((vx_reference)image, (vx_reference)imageFromROI, "image created from image");
VX_CALL(vxReleaseUserDataObject(&exemplar));
VX_CALL(vxReleaseImage(&image));
Expand Down Expand Up @@ -1220,10 +1201,10 @@ TEST(supplementary_data, testCopySwapMove)
ERROR_CHECK_VX_SUCCESS(status, "Supplementary data of array element swapped when object arrays swapped");

/* now check the supplementary data of a level of a pyramid in the array */
vx_reference ref3 = (vx_reference)(vxGetPyramidLevel((vx_pyramid)(ref1, &status), 2));
vx_reference ref4 = (vx_reference)(vxGetPyramidLevel((vx_pyramid)(ref2, &status), 2));
ERROR_CHECK_VX_SUCCESS(vxReleaseUserDataObject(&supp1), NULL);
ERROR_CHECK_VX_SUCCESS(vxReleaseUserDataObject(&supp2), NULL);
vx_reference ref3 = (vx_reference)(vxGetPyramidLevel((vx_pyramid)ref1, 2));
vx_reference ref4 = (vx_reference)(vxGetPyramidLevel((vx_pyramid)ref2, 2));
status = VX_SUCCESS;
supp1 = vxGetSupplementaryUserDataObject(ref3, NULL, &status);
supp2 = vxGetSupplementaryUserDataObject(ref4, NULL, &status);
Expand Down
4 changes: 2 additions & 2 deletions source/framework/vx_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -1275,8 +1275,8 @@ VX_API_ENTRY vx_image VX_API_CALL vxCreateImageFromROI(vx_image image, const vx_
obj_desc = (tivx_obj_desc_image_t *)image->base.obj_desc;

if ((NULL == rect) ||
(rect->start_x > rect->end_x) ||
(rect->start_y > rect->end_y) ||
(rect->start_x >= rect->end_x) ||
(rect->start_y >= rect->end_y) ||
(rect->end_x > obj_desc->width) ||
(rect->end_y > obj_desc->height))
{
Expand Down
14 changes: 13 additions & 1 deletion source/framework/vx_reference.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,19 @@ vx_status ownReleaseReferenceInt(vx_reference *pref,

if (ownIsValidSpecificReference(ref, ref_type) == (vx_bool)vx_true_e)
{
//if there is a parent then decrement the parent itself
if ((vx_enum) VX_TYPE_USER_DATA_OBJECT == ref_type)
{
//cast to user object data
vx_user_data_object ref_user = (vx_user_data_object)ref;
//check if there is a parent
if (ref_user->parent != NULL)
{
//if yes replease the ref to decrement
ref = (vx_reference)ref_user->parent;
}
}

if (ownDecrementReference(ref, reftype) == 0U)
{
tivx_reference_callback_f destructor = special_destructor;
Expand All @@ -640,7 +653,6 @@ vx_status ownReleaseReferenceInt(vx_reference *pref,
{
destructor = ref->destructor_callback;
}

/* if there is a destructor, call it. */
if (destructor != NULL)
{
Expand Down

0 comments on commit 8c59240

Please sign in to comment.