Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 39ee4cf

Browse files
[SYCL] Update allowlist and select_device tests (#304)
This patch adds checking of new exception messages for SYCL_DEVICE_ALLOWLIST. Old messages wasn't removed here for compatibility reasons, and should be removed in separate PR merged after PR intel/llvm:3826.
1 parent e572f6e commit 39ee4cf

File tree

2 files changed

+67
-23
lines changed

2 files changed

+67
-23
lines changed

SYCL/Config/allowlist.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,22 @@ int main() {
9393
try {
9494
sycl::platform::get_platforms();
9595
} catch (sycl::runtime_error &E) {
96-
const std::string ExpectedMsg("Unrecognized key in device allowlist");
96+
// Workaround to make CI pass.
97+
// TODO: after the submission of PR intel/llvm:3826, create PR to
98+
// intel/llvm-test-suite with removal of 1st parameter of the vector,
99+
// and transformation of std::vector<std::string> to std::string
100+
const std::vector<std::string> ExpectedMsgs{
101+
"Unrecognized key in device allowlist",
102+
"Unrecognized key in SYCL_DEVICE_ALLOWLIST"};
97103
const std::string GotMessage(E.what());
98-
const bool CorrectMeg = GotMessage.find(ExpectedMsg) != std::string::npos;
99-
return CorrectMeg ? 0 : 1;
104+
bool CorrectMsg = false;
105+
for (const auto &ExpectedMsg : ExpectedMsgs) {
106+
if (GotMessage.find(ExpectedMsg) != std::string::npos) {
107+
CorrectMsg = true;
108+
break;
109+
}
110+
}
111+
return CorrectMsg ? 0 : 1;
100112
}
101113
}
102114

SYCL/Config/select_device.cpp

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -682,12 +682,20 @@ int main() {
682682
device dev = deviceQueue.get_device();
683683
const auto &plt = dev.get_platform();
684684
} catch (sycl::runtime_error &E) {
685-
const std::string expectedMsg(
686-
"Malformed syntax in SYCL_DEVICE_ALLOWLIST");
685+
// Workaround to make CI pass.
686+
// TODO: after the submission of PR intel/llvm:3826, create PR to
687+
// intel/llvm-test-suite with removal of 1st parameter of the vector,
688+
// and transformation of std::vector<std::string> to std::string
689+
const std::vector<std::string> expectedMsgs{
690+
"Malformed syntax in SYCL_DEVICE_ALLOWLIST",
691+
"Key DeviceName of SYCL_DEVICE_ALLOWLIST should have value which "
692+
"starts with {{"};
687693
const std::string gotMessage(E.what());
688-
if (gotMessage.find(expectedMsg) != std::string::npos) {
689-
passed = true;
690-
} else {
694+
for (const auto &expectedMsg : expectedMsgs) {
695+
if (gotMessage.find(expectedMsg) != std::string::npos) {
696+
passed = true;
697+
break;
698+
}
691699
passed = false;
692700
}
693701
}
@@ -733,12 +741,20 @@ int main() {
733741
device dev = deviceQueue.get_device();
734742
const auto &plt = dev.get_platform();
735743
} catch (sycl::runtime_error &E) {
736-
const std::string expectedMsg(
737-
"Malformed syntax in SYCL_DEVICE_ALLOWLIST");
744+
// Workaround to make CI pass.
745+
// TODO: after the submission of PR intel/llvm:3826, create PR to
746+
// intel/llvm-test-suite with removal of 1st parameter of the vector,
747+
// and transformation of std::vector<std::string> to std::string
748+
const std::vector<std::string> expectedMsgs{
749+
"Malformed syntax in SYCL_DEVICE_ALLOWLIST",
750+
"Key PlatformName of SYCL_DEVICE_ALLOWLIST should have value "
751+
"which starts with {{"};
738752
const std::string gotMessage(E.what());
739-
if (gotMessage.find(expectedMsg) != std::string::npos) {
740-
passed = true;
741-
} else {
753+
for (const auto &expectedMsg : expectedMsgs) {
754+
if (gotMessage.find(expectedMsg) != std::string::npos) {
755+
passed = true;
756+
break;
757+
}
742758
passed = false;
743759
}
744760
}
@@ -790,12 +806,20 @@ int main() {
790806
device dev = deviceQueue.get_device();
791807
const auto &plt = dev.get_platform();
792808
} catch (sycl::runtime_error &E) {
793-
const std::string expectedMsg(
794-
"Malformed syntax in SYCL_DEVICE_ALLOWLIST");
809+
// Workaround to make CI pass.
810+
// TODO: after the submission of PR intel/llvm:3826, create PR to
811+
// intel/llvm-test-suite with removal of 1st parameter of the vector,
812+
// and transformation of std::vector<std::string> to std::string
813+
const std::vector<std::string> expectedMsgs{
814+
"Malformed syntax in SYCL_DEVICE_ALLOWLIST",
815+
"Key DriverVersion of SYCL_DEVICE_ALLOWLIST should have value "
816+
"which starts with {{"};
795817
const std::string gotMessage(E.what());
796-
if (gotMessage.find(expectedMsg) != std::string::npos) {
797-
passed = true;
798-
} else {
818+
for (const auto &expectedMsg : expectedMsgs) {
819+
if (gotMessage.find(expectedMsg) != std::string::npos) {
820+
passed = true;
821+
break;
822+
}
799823
passed = false;
800824
}
801825
}
@@ -843,12 +867,20 @@ int main() {
843867
device dev = deviceQueue.get_device();
844868
const auto &plt = dev.get_platform();
845869
} catch (sycl::runtime_error &E) {
846-
const std::string expectedMsg(
847-
"Malformed syntax in SYCL_DEVICE_ALLOWLIST");
870+
// Workaround to make CI pass.
871+
// TODO: after the submission of PR intel/llvm:3826, create PR to
872+
// intel/llvm-test-suite with removal of 1st parameter of the vector,
873+
// and transformation of std::vector<std::string> to std::string
874+
const std::vector<std::string> expectedMsgs{
875+
"Malformed syntax in SYCL_DEVICE_ALLOWLIST",
876+
"Key PlatformVersion of SYCL_DEVICE_ALLOWLIST should have value "
877+
"which starts with {{"};
848878
const std::string gotMessage(E.what());
849-
if (gotMessage.find(expectedMsg) != std::string::npos) {
850-
passed = true;
851-
} else {
879+
for (const auto &expectedMsg : expectedMsgs) {
880+
if (gotMessage.find(expectedMsg) != std::string::npos) {
881+
passed = true;
882+
break;
883+
}
852884
passed = false;
853885
}
854886
}

0 commit comments

Comments
 (0)