Skip to content

Commit d78e055

Browse files
[SYCL] Fix PersistentDeviceCodeCache unittests (#6266)
#6256 changed the binary format used by the PersistentDeviceCodeCache tests to be a parameter, however the tests would be setting the format after the image had been initialized, which causes the image to think it is still the old format after changing the binary format of the PI image to the format read from the GTest parameter. With these changes the format will be set immediately from the parameter rather than deferring it to during setup. Additionally it fixes the SetUp and TearDown overrides. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 9c54241 commit d78e055

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

sycl/unittests/kernel-and-program/PersistentDeviceCodeCache.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,13 @@ class PersistentDeviceCodeCache
120120
SYCLCachePersistentChanged = true;
121121
}
122122

123-
virtual void SetUp() {
123+
void SetUp() override {
124124
EXPECT_NE(getenv("SYCL_CACHE_DIR"), nullptr)
125125
<< "Please set SYCL_CACHE_DIR environment variable pointing to cache "
126126
"location.";
127-
// Set binary format from parameter.
128-
BinStruct.Format = GetParam();
129127
}
130128

131-
virtual void TearDown() {
129+
void TearDown() override {
132130
// If we changed the cache, set it back to the old value.
133131
if (SYCLCachePersistentChanged)
134132
SetSYCLCachePersistentEnv(SYCLCachePersistentBefore
@@ -202,10 +200,9 @@ class PersistentDeviceCodeCache
202200
detail::OSModuleHandle ModuleHandle = detail::OSUtil::ExeModuleHandle;
203201
platform Plt;
204202
device Dev;
205-
// NOTE: Format is a parameter of the test so use none and set in SetUp.
206203
pi_device_binary_struct BinStruct{/*Version*/ 1,
207204
/*Kind*/ 4,
208-
/*Format*/ PI_DEVICE_BINARY_TYPE_NONE,
205+
/*Format*/ GetParam(),
209206
/*DeviceTargetSpec*/ nullptr,
210207
/*CompileOptions*/ nullptr,
211208
/*LinkOptions*/ nullptr,

0 commit comments

Comments
 (0)