diff --git a/opencl/test/unit_test/aub_tests/command_queue/enqueue_write_buffer_rect_aub_tests.cpp b/opencl/test/unit_test/aub_tests/command_queue/enqueue_write_buffer_rect_aub_tests.cpp index 4e19b7a701..f50b6cd1f4 100644 --- a/opencl/test/unit_test/aub_tests/command_queue/enqueue_write_buffer_rect_aub_tests.cpp +++ b/opencl/test/unit_test/aub_tests/command_queue/enqueue_write_buffer_rect_aub_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -31,29 +31,30 @@ struct WriteBufferRectHw } }; -typedef WriteBufferRectHw AUBWriteBufferRect; -static const size_t width = 10; +using AUBWriteBufferRect = WriteBufferRectHw; HWTEST_P(AUBWriteBufferRect, Given3dWhenWritingBufferThenExpectationsAreMet) { + MockContext context(this->pClDevice); + const size_t width = 10; size_t rowPitch = width; size_t slicePitch = rowPitch * rowPitch; size_t bufferSizeBuff = rowPitch * rowPitch * rowPitch; size_t bufferSize = alignUp(bufferSizeBuff, 4096); - size_t zHostOffs; - size_t zBuffOffs; - std::tie(zBuffOffs, zHostOffs) = GetParam(); + auto [zBuffOffs, zHostOffs] = GetParam(); ASSERT_LT(zBuffOffs, width); ASSERT_LT(zHostOffs, width); - uint8_t *srcMemory = (uint8_t *)::alignedMalloc(bufferSize, 4096); - uint8_t *destMemory = (uint8_t *)::alignedMalloc(bufferSize, 4096); + auto srcMemory = static_cast(::alignedMalloc(bufferSize, 4096)); + auto destMemory = static_cast(::alignedMalloc(bufferSize, 4096)); - for (unsigned int i = 0; i < bufferSize; i++) - srcMemory[i] = i; + for (unsigned int i = 0; i < bufferSize; i++) { + auto oneBytePattern = static_cast(i & 0xff); + srcMemory[i] = oneBytePattern; + } memset(destMemory, 0x00, bufferSize); @@ -91,17 +92,15 @@ HWTEST_P(AUBWriteBufferRect, Given3dWhenWritingBufferThenExpectationsAreMet) { EXPECT_EQ(CL_SUCCESS, retVal); - char *ptr = new char[slicePitch]; - memset(ptr, 0, slicePitch); + std::vector ptr(slicePitch, 0); for (unsigned int i = 0; i < rowPitch; i++) { - //one slice will be copied from src. all others should be zeros + // one slice will be copied from src. all others should be zeros if (i == zBuffOffs) { AUBCommandStreamFixture::expectMemory(pDestMemory + slicePitch * i, srcMemory + slicePitch * zHostOffs, slicePitch); } else { - AUBCommandStreamFixture::expectMemory(pDestMemory + slicePitch * i, ptr, slicePitch); + AUBCommandStreamFixture::expectMemory(pDestMemory + slicePitch * i, ptr.data(), slicePitch); } } - delete[] ptr; ::alignedFree(srcMemory); ::alignedFree(destMemory); @@ -109,8 +108,8 @@ HWTEST_P(AUBWriteBufferRect, Given3dWhenWritingBufferThenExpectationsAreMet) { INSTANTIATE_TEST_CASE_P(AUBWriteBufferRect_simple, AUBWriteBufferRect, ::testing::Combine( - ::testing::Values(0, 1, 2, 3, 4), - ::testing::Values(0, 1, 2, 3, 4))); + ::testing::Values(0u, 1u, 2u, 3u, 4u), + ::testing::Values(0u, 1u, 2u, 3u, 4u))); struct AUBWriteBufferRectUnaligned : public CommandEnqueueAUBFixture, diff --git a/shared/test/common/test_macros/test.h b/shared/test/common/test_macros/test.h index 5e2d2f8524..473e332905 100644 --- a/shared/test/common/test_macros/test.h +++ b/shared/test/common/test_macros/test.h @@ -412,7 +412,20 @@ extern GFXCORE_FAMILY renderCoreFamily; void testBodyHw(); \ \ void TestBody() override { \ - FAMILY_SELECTOR(::renderCoreFamily, testBodyHw) \ + if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \ + FAMILY_SELECTOR(::renderCoreFamily, testBodyHw) \ + } \ + } \ + void SetUp() override { \ + if (IS_TEST_EXCLUDED(test_suite_name, test_name)) { \ + GTEST_SKIP(); \ + } \ + test_suite_name::SetUp(); \ + } \ + void TearDown() override { \ + if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \ + test_suite_name::TearDown(); \ + } \ } \ \ private: \