Skip to content

Commit db7a64f

Browse files
committed
Address feedback: CTS environment error handling.
1 parent f8d6182 commit db7a64f

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

test/conformance/source/environment.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,20 @@ uur::PlatformEnvironment::PlatformEnvironment(int argc, char **argv)
4545
instance = this;
4646

4747
ur_loader_config_handle_t config;
48-
urLoaderConfigCreate(&config);
49-
urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION");
48+
if (urLoaderConfigCreate(&config) == UR_RESULT_SUCCESS) {
49+
if (urLoaderConfigEnableLayer(config, "UR_LAYER_FULL_VALIDATION")) {
50+
error = "Failed to enable validation layer";
51+
return;
52+
}
53+
} else {
54+
error = "Failed to create loader config handle";
55+
return;
56+
}
5057

5158
ur_device_init_flags_t device_flags = 0;
52-
switch (urInit(device_flags, config)) {
59+
auto initResult = urInit(device_flags, config);
60+
auto configReleaseResult = urLoaderConfigRelease(config);
61+
switch (initResult) {
5362
case UR_RESULT_SUCCESS:
5463
break;
5564
case UR_RESULT_ERROR_UNINITIALIZED:
@@ -59,7 +68,11 @@ uur::PlatformEnvironment::PlatformEnvironment(int argc, char **argv)
5968
error = "urInit() failed";
6069
return;
6170
}
62-
urLoaderConfigRelease(config);
71+
72+
if (configReleaseResult) {
73+
error = "Failed to destroy loader config handle";
74+
return;
75+
}
6376

6477
uint32_t count = 0;
6578
if (urPlatformGet(0, nullptr, &count)) {

0 commit comments

Comments
 (0)