diff --git a/SYCL/Regression/stream_exception_no_alloc.cpp b/SYCL/Regression/stream_exception_no_alloc.cpp new file mode 100644 index 0000000000..550f6bf0a0 --- /dev/null +++ b/SYCL/Regression/stream_exception_no_alloc.cpp @@ -0,0 +1,30 @@ +// RUN: %clangxx -fsycl %s -o %t.out +// RUN: env SYCL_PI_TRACE=2 %CPU_RUN_PLACEHOLDER %t.out 2>&1 %CPU_CHECK_PLACEHOLDER +// RUN: env SYCL_PI_TRACE=2 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER +// RUN: env SYCL_PI_TRACE=2 %ACC_RUN_PLACEHOLDER %t.out 2>&1 %ACC_CHECK_PLACEHOLDER + +// NOTE: This test checks that sycl::stream does not allocate memory if it fails +// during construction. + +#include + +#include + +int main() { + sycl::queue q; + q.submit([&](sycl::handler &cgh) { + try { + // Try to create stream with invalid workItemBufferSize parameter. + sycl::stream invalidStream{256, std::numeric_limits::max(), cgh}; + assert(false && "No exception was thrown."); + } catch (const sycl::invalid_parameter_error &) { + // Expected exception + } catch (...) { + assert(false && "Unexpected exception was thrown."); + } + + cgh.single_task([=]() {}); + }); +} + +// CHECK-NOT:---> piMemBufferCreate