-
Notifications
You must be signed in to change notification settings - Fork 221
Add negative tests for context API functions #2494
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
base: main
Are you sure you want to change the base?
Add negative tests for context API functions #2494
Conversation
9b2681e to
2147c7e
Compare
2147c7e to
d99404d
Compare
EwanC
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, but have a few minor comments
| TEST_FAIL); | ||
|
|
||
| cl_context_properties invalid_value{ -1 }; | ||
| props[0] = CL_CONTEXT_INTEROP_USER_SYNC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could enter this control flow if get_device_cl_version(device) returns Version(1,1) but CL_CONTEXT_INTEROP_USER_SYNC isn't added to the spec until version 1.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the branch condition to >= Version(1, 2).
| "not one of the supported values\"", | ||
| TEST_FAIL); | ||
|
|
||
| err = clGetContextInfo(context, CL_CONTEXT_REFERENCE_COUNT, 0, ¶m_value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using a non-zero value, e.g sizeof(cl_uint) - 1 would be a marginally stronger test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| ctx = clCreateContext(props, 1, &device, nullptr, nullptr, &err); | ||
| test_object_failure_ret( | ||
| ctx, err, CL_INVALID_PROPERTY, | ||
| "clCreateContext should return CL_INVALID_PROPERTY when: \"the " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this provide extra coverage that the first check for this case on line 41 doesn't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's been removed.
This change adds negative tests to `cl_context`-related APIs: - clCreateContext - clCreateContextFromType - clRetainContext - clReleaseContext - clSetContextDestructorCallback It also adds a verification macro: `test_object_failure_ret`. It verifies that an expected error code is returned and the CL object is `NULL`. Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com>
d99404d to
536a8dd
Compare
This PR adds negative tests for the following API functions:
Also, define a new macro
test_object_failure_retto test for an expected error code and the returned object isNULLas a result of a failure.