From 51a30993e7b1c4184f24044bf84fb71d394b1a97 Mon Sep 17 00:00:00 2001 From: Pyry Haulos Date: Tue, 10 Nov 2015 13:48:58 -0800 Subject: [PATCH] Clean up result code checking in api.device_init tests Change-Id: Ic1df446fd88934fca3b620a67f39292a853fd594 --- .../vulkan/api/vktApiDeviceInitializationTests.cpp | 85 ++++++++++++++-------- 1 file changed, 56 insertions(+), 29 deletions(-) diff --git a/external/vulkancts/modules/vulkan/api/vktApiDeviceInitializationTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiDeviceInitializationTests.cpp index 63d0159..fa5eb94 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiDeviceInitializationTests.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiDeviceInitializationTests.cpp @@ -222,15 +222,24 @@ tcu::TestStatus createInstanceWithInvalidApiVersionTest (Context& context) << ", api version used to create instance: " << invalidApiVersions[apiVersionNdx] << TestLog::EndMessage; - try { - const Unique instance(createInstance(platformInterface, &instanceCreateInfo)); + VkInstance instance = (VkInstance)0; + const VkResult result = platformInterface.createInstance(&instanceCreateInfo, &instance); + const bool gotInstance = !!instance; - resultCollector.fail("Fail, instance creation with invalid apiVersion is not rejected"); - } - catch (const tcu::NotSupportedError&) - { - log << TestLog::Message << "Pass, instance creation with invalid apiVersion is rejected" << TestLog::EndMessage; + if (instance) + { + const InstanceDriver instanceIface (platformInterface, instance); + instanceIface.destroyInstance(instance); + } + + if (result == VK_UNSUPPORTED || result == VK_ERROR_INCOMPATIBLE_DRIVER) + { + TCU_CHECK(!gotInstance); + log << TestLog::Message << "Pass, instance creation with invalid apiVersion is rejected" << TestLog::EndMessage; + } + else + resultCollector.fail("Fail, instance creation with invalid apiVersion is not rejected"); } } @@ -264,20 +273,29 @@ tcu::TestStatus createInstanceWithUnsupportedExtensionsTest (Context& context) enabledExtensions, // const char*const* ppEnabledExtensionNames; }; - try - { - Unique instance(createInstance(platformInterface, &instanceCreateInfo)); - - log << TestLog::Message << "Enabled extensions are: " << TestLog::EndMessage; + log << TestLog::Message << "Enabled extensions are: " << TestLog::EndMessage; - for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(enabledExtensions); ndx++) - log << TestLog::Message << enabledExtensions[ndx] << TestLog::EndMessage; + for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(enabledExtensions); ndx++) + log << TestLog::Message << enabledExtensions[ndx] << TestLog::EndMessage; - return tcu::TestStatus::fail("Fail, creating instance with unsupported extensions succeeded."); - } - catch (const tcu::NotSupportedError&) { - return tcu::TestStatus::pass("Pass, creating instance with unsupported extension was rejected."); + VkInstance instance = (VkInstance)0; + const VkResult result = platformInterface.createInstance(&instanceCreateInfo, &instance); + const bool gotInstance = !!instance; + + if (instance) + { + const InstanceDriver instanceIface (platformInterface, instance); + instanceIface.destroyInstance(instance); + } + + if (result == VK_UNSUPPORTED || result == VK_ERROR_EXTENSION_NOT_PRESENT) + { + TCU_CHECK(!gotInstance); + return tcu::TestStatus::pass("Pass, creating instance with unsupported extension was rejected."); + } + else + return tcu::TestStatus::fail("Fail, creating instance with unsupported extensions succeeded."); } } @@ -433,20 +451,29 @@ tcu::TestStatus createDeviceWithUnsupportedExtensionsTest (Context& context) DE_NULL, //pEnabledFeatures; }; - try - { - Unique device(createDevice(instanceDriver, physicalDevice, &deviceCreateInfo)); - - log << TestLog::Message << "Enabled extensions are: " << TestLog::EndMessage; + log << TestLog::Message << "Enabled extensions are: " << TestLog::EndMessage; - for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(enabledExtensions); ndx++) - log << TestLog::Message << enabledExtensions[ndx] << TestLog::EndMessage; + for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(enabledExtensions); ndx++) + log << TestLog::Message << enabledExtensions[ndx] << TestLog::EndMessage; - return tcu::TestStatus::fail("Fail, create device with unsupported extension but succeed."); - } - catch (const tcu::NotSupportedError&) { - return tcu::TestStatus::pass("Pass, create device with unsupported extension is rejected."); + VkDevice device = (VkDevice)0; + const VkResult result = instanceDriver.createDevice(physicalDevice, &deviceCreateInfo, &device); + const bool gotDevice = !!device; + + if (device) + { + const DeviceDriver deviceIface (instanceDriver, device); + deviceIface.destroyDevice(device); + } + + if (result == VK_UNSUPPORTED || result == VK_ERROR_EXTENSION_NOT_PRESENT) + { + TCU_CHECK(!gotDevice); + return tcu::TestStatus::pass("Pass, create device with unsupported extension is rejected."); + } + else + return tcu::TestStatus::fail("Fail, create device with unsupported extension but succeed."); } } -- 2.7.4