Skip to content

Commit e4437fc

Browse files
Add exclude support for hwtest_p tests
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
1 parent 8f38f4e commit e4437fc

File tree

2 files changed

+30
-18
lines changed

2 files changed

+30
-18
lines changed

opencl/test/unit_test/aub_tests/command_queue/enqueue_write_buffer_rect_aub_tests.cpp

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2021 Intel Corporation
2+
* Copyright (C) 2018-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -31,29 +31,30 @@ struct WriteBufferRectHw
3131
}
3232
};
3333

34-
typedef WriteBufferRectHw AUBWriteBufferRect;
35-
static const size_t width = 10;
34+
using AUBWriteBufferRect = WriteBufferRectHw;
3635

3736
HWTEST_P(AUBWriteBufferRect, Given3dWhenWritingBufferThenExpectationsAreMet) {
37+
3838
MockContext context(this->pClDevice);
39+
const size_t width = 10;
3940
size_t rowPitch = width;
4041
size_t slicePitch = rowPitch * rowPitch;
4142

4243
size_t bufferSizeBuff = rowPitch * rowPitch * rowPitch;
4344
size_t bufferSize = alignUp(bufferSizeBuff, 4096);
4445

45-
size_t zHostOffs;
46-
size_t zBuffOffs;
47-
std::tie(zBuffOffs, zHostOffs) = GetParam();
46+
auto [zBuffOffs, zHostOffs] = GetParam();
4847

4948
ASSERT_LT(zBuffOffs, width);
5049
ASSERT_LT(zHostOffs, width);
5150

52-
uint8_t *srcMemory = (uint8_t *)::alignedMalloc(bufferSize, 4096);
53-
uint8_t *destMemory = (uint8_t *)::alignedMalloc(bufferSize, 4096);
51+
auto srcMemory = static_cast<uint8_t *>(::alignedMalloc(bufferSize, 4096));
52+
auto destMemory = static_cast<uint8_t *>(::alignedMalloc(bufferSize, 4096));
5453

55-
for (unsigned int i = 0; i < bufferSize; i++)
56-
srcMemory[i] = i;
54+
for (unsigned int i = 0; i < bufferSize; i++) {
55+
auto oneBytePattern = static_cast<uint8_t>(i & 0xff);
56+
srcMemory[i] = oneBytePattern;
57+
}
5758

5859
memset(destMemory, 0x00, bufferSize);
5960

@@ -91,26 +92,24 @@ HWTEST_P(AUBWriteBufferRect, Given3dWhenWritingBufferThenExpectationsAreMet) {
9192

9293
EXPECT_EQ(CL_SUCCESS, retVal);
9394

94-
char *ptr = new char[slicePitch];
95-
memset(ptr, 0, slicePitch);
95+
std::vector<uint8_t> ptr(slicePitch, 0);
9696
for (unsigned int i = 0; i < rowPitch; i++) {
97-
//one slice will be copied from src. all others should be zeros
97+
// one slice will be copied from src. all others should be zeros
9898
if (i == zBuffOffs) {
9999
AUBCommandStreamFixture::expectMemory<FamilyType>(pDestMemory + slicePitch * i, srcMemory + slicePitch * zHostOffs, slicePitch);
100100
} else {
101-
AUBCommandStreamFixture::expectMemory<FamilyType>(pDestMemory + slicePitch * i, ptr, slicePitch);
101+
AUBCommandStreamFixture::expectMemory<FamilyType>(pDestMemory + slicePitch * i, ptr.data(), slicePitch);
102102
}
103103
}
104-
delete[] ptr;
105104

106105
::alignedFree(srcMemory);
107106
::alignedFree(destMemory);
108107
}
109108
INSTANTIATE_TEST_CASE_P(AUBWriteBufferRect_simple,
110109
AUBWriteBufferRect,
111110
::testing::Combine(
112-
::testing::Values(0, 1, 2, 3, 4),
113-
::testing::Values(0, 1, 2, 3, 4)));
111+
::testing::Values(0u, 1u, 2u, 3u, 4u),
112+
::testing::Values(0u, 1u, 2u, 3u, 4u)));
114113

115114
struct AUBWriteBufferRectUnaligned
116115
: public CommandEnqueueAUBFixture,

shared/test/common/test_macros/test.h

+14-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,20 @@ extern GFXCORE_FAMILY renderCoreFamily;
412412
void testBodyHw(); \
413413
\
414414
void TestBody() override { \
415-
FAMILY_SELECTOR(::renderCoreFamily, testBodyHw) \
415+
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
416+
FAMILY_SELECTOR(::renderCoreFamily, testBodyHw) \
417+
} \
418+
} \
419+
void SetUp() override { \
420+
if (IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
421+
GTEST_SKIP(); \
422+
} \
423+
test_suite_name::SetUp(); \
424+
} \
425+
void TearDown() override { \
426+
if (!IS_TEST_EXCLUDED(test_suite_name, test_name)) { \
427+
test_suite_name::TearDown(); \
428+
} \
416429
} \
417430
\
418431
private: \

0 commit comments

Comments
 (0)