From d8d649a6db459a79a8ac8e1244eeda74c7028cf2 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Tue, 7 Jun 2022 15:40:10 -0700 Subject: [PATCH] [SYCL] Fix PersistentDeviceCodeCache unittests https://github.com/intel/llvm/pull/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 --- .../kernel-and-program/PersistentDeviceCodeCache.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sycl/unittests/kernel-and-program/PersistentDeviceCodeCache.cpp b/sycl/unittests/kernel-and-program/PersistentDeviceCodeCache.cpp index 83298f7923758..bf03b7471e76b 100644 --- a/sycl/unittests/kernel-and-program/PersistentDeviceCodeCache.cpp +++ b/sycl/unittests/kernel-and-program/PersistentDeviceCodeCache.cpp @@ -120,15 +120,13 @@ class PersistentDeviceCodeCache SYCLCachePersistentChanged = true; } - virtual void SetUp() { + void SetUp() override { EXPECT_NE(getenv("SYCL_CACHE_DIR"), nullptr) << "Please set SYCL_CACHE_DIR environment variable pointing to cache " "location."; - // Set binary format from parameter. - BinStruct.Format = GetParam(); } - virtual void TearDown() { + void TearDown() override { // If we changed the cache, set it back to the old value. if (SYCLCachePersistentChanged) SetSYCLCachePersistentEnv(SYCLCachePersistentBefore @@ -202,10 +200,9 @@ class PersistentDeviceCodeCache detail::OSModuleHandle ModuleHandle = detail::OSUtil::ExeModuleHandle; platform Plt; device Dev; - // NOTE: Format is a parameter of the test so use none and set in SetUp. pi_device_binary_struct BinStruct{/*Version*/ 1, /*Kind*/ 4, - /*Format*/ PI_DEVICE_BINARY_TYPE_NONE, + /*Format*/ GetParam(), /*DeviceTargetSpec*/ nullptr, /*CompileOptions*/ nullptr, /*LinkOptions*/ nullptr,