This is a test plan for the APIs described in SYCL 2020 section 4.13.2. "Exception class interface"
Every method should be checked for accordance to spec:
-
Member function existence
-
Const correctness
-
Type of result
-
Result for
noexcept()
operator
For every errc
value check that:
-
Result of the call should be equal to
std::error_code(errc)
-
error_code::value
is equal to errc value passed -
error_code::category
is equal to sycl_category() -
error_code::default_error_condition()
is equal tostd::error_condition(errc, sycl::sycl_category())
For each of the following use-cases:
-
using reference of
error_category
retrieved at the function scope -
using construction of some object instance at global static scope to run checks and save their results for later check in
TEST_NAME::run()
provide checks under a separate test name:
-
error_category::name()
should return "sycl" -
For
sycl::errc::success
and any other oneerrc
valueerror_category::default_error_condition(errc)
is equal tostd::err_condition(errc, sycl::sycl_category())
-
For FULL conformance - same as bullet above but for all
errc
values
-
Check that function template exists.
If SYCL_BACKEND_OPENCL
is defined run same checks as for sycl_category
, but:
-
error_category::name()
should return "opencl" -
for
value = static_cast<sycl::errc_for<sycl::backend::opencl>>(0)
error_category_for<>::default_error_condition(value)
should be equal tostd::error_condition(value, sycl::error_category_for<sycl::backend::opencl>())
For all values of the enum class sycl::errc
:
-
runtime
-
kernel
-
accessor
-
nd_range
-
event
-
kernel_argument
-
build
-
invalid
-
memory_allocation
-
platform
-
profiling
-
feature_not_supported
-
kernel_not_supported
-
backend_mismatch
check that:
-
they exist
-
that all values are different
Special cases:
-
Check that
std::is_error_code_enum
istrue
forsycl::errc
-
Check that
std::is_error_condition_enum
should befalse
forsycl::errc
-
Check that enum class template exists
If SYCL_BACKEND_OPENCL is defined check that
-
enum class with
b == sycl::backend::opencl
exists and is a scoped enum -
std::is_error_code_enum
istrue
-
std::is_error_condition_enum
isfalse
-
for
value = static_cast<sycl::errc_for<sycl::backend::opencl>>(0)
forstd::error_code(value, sycl::eror_category_for<sycl::backend::opencl>())
error_code::default_error_condition()
is equal tostd::error_condition(value, sycl::error_category_for<sycl::backend::opencl>())
-
Check that class is derived from
std::exception
For sycl::errc::success
and any other value
(for FULL conformance - for all errc
values) check:
-
exception::code()
returns value passed -
exception::category()
returns sycl_category -
exception::what()
returns null-terminated string -
exception::has_context()
returns false -
exception::get_context()
throws witherrc::invalid
If SYCL_BACKEND_OPENCL defined
for value = static_cast<sycl::errc_for<sycl::backend::opencl>>(0)
for error_code = std::error_code(value, sycl::eror_category_for<sycl::backend::opencl>())
for exception(error_code) check same as above.
For sycl::errc::success
and any other value
for ev = static_cast<int>(value)
and for cat = sycl_category()
check that exception(ev, cat) is same as exception(std::error_code ec)
-
exception::code()
returns value passed -
exception::category()
returns sycl_category -
exception::what()
returns null-terminated string -
exception::has_context()
returns false -
exception::get_context()
throws witherrc::invalid
If SYCL_BACKEND_OPENCL defined
for ev = 0
and for cat = sycl::eror_category_for<sycl::backend::opencl>()
check that exception(ev, cat) is same as exception(std::error_code ec)
Same as exception(std::error_code)
, but:
-
exception::has_context()
should return true -
exception::get_context()
should return the ctx passed
Same as exception(int ev, const std::error_category& cat)
, but:
-
exception::has_context()
should return true -
exception::get_context()
should return the ctx passed
Same as exception(std::error_code)
, but:
-
for non-empty
what_arg
exception::what()
should containwhat_arg
as substring -
for empty
what_arg
exception::what()
should return null-terminated string
Same as exception(std::error_code ec, const std::string& what_arg)
.
Same as exception(int ev, const std::error_category& cat)
, but
same checks for what_arg
as for
exception(std::error_code ec, const std::string& what_arg)
Same as exception(int ev, const std::error_category& cat, const std::string& what_arg)
Same as exception(context ctx, std::error_code ec)
, but:
same checks for what_arg
as for
exception(std::error_code ec, const std::string& what_arg)
Same as exception(context ctx, std::error_code ec, const std::string& what_arg)
Same as exception(context ctx, int ev, const std::error_category& cat)
, but:
same checks for what_arg
as for
exception(std::error_code ec, const std::string& what_arg)
Same as exception(context ctx, int ev, const std::error_category& cat, const std::string& what_arg)
For any constructor from 12 constructors above make same checks as for the original constructor
Verify that:
-
value_type
std::is_same
withstd::exception_ptr
-
reference
std::is_same
withvalue_type&
-
const_reference
std::is_same
withconst value_type&
-
size_type
std::is_same
withstd::size_t
-
iterator
satisfiesLegacyForwardIterator
-
const_iterator
satisfiesLegacyForwardIterator
For default-constructed exception_list
check that:
-
exception_list::size()
is zero -
exception_list::begin()
is equal toexception_list::end()
Check that sycl::async_handler
std::is_same
with std::function<void(sycl::exception_list)>
For cases:
-
queue::wait_and_throw()
-
queue::throw_asynchronous()
-
event::wait_and_throw()
-
on queue destruction
-
on context destruction
-
on buffer destruction
check that when there are no exceptions expected then the async handler is not invoked.
Create 2 user defined async handlers, first changes global variable to 1, second changes global variable to 2.
Both checks that exceptions that passed via exception_list parameter have error code errc::accessor
or errc::nd_range
.
To check that queue’s handler will be used first:
-
Create context with first user defined async_handler
-
Create queue with context, cts_selector and second user defined async_handler
-
Submit host_task to the queue that throws an
exception(errc::accessor)
-
Submit host_task to the queue that throws an
exception(errc::nd_range)
-
Call
queue::wait_and_throw()
-
Check that global variable changed to 2 as async_handler for the queue were called
-
Check that 2 async exceptions were handled
To check that context’s handler will be used if queue doesn’t have one:
-
Create context with first user defined async_handler
-
Create queue with context and cts_selector without user defined async_handler
-
Submit host_task to the queue that throws an
exception(errc::accessor)
-
Submit host_task to the queue that throws an
exception(errc::nd_range)
-
Call
queue::wait_and_throw()
-
Check that global variable changed to 1 as async_handler for the context were called
-
Check that 2 async exceptions were handled