dEQP-VK.api.info.device.properties struct offsets
authorMaciej Jesionowski <maciej.jesionowski@mobica.com>
Fri, 15 Apr 2016 08:53:41 +0000 (10:53 +0200)
committerPyry Haulos <phaulos@google.com>
Thu, 21 Apr 2016 18:21:56 +0000 (11:21 -0700)
Use correct offsets and comparison algorithm when checking
VkPhysicalDeviceProperties structure.

external/vulkancts/modules/vulkan/api/vktApiFeatureInfo.cpp
framework/delibs/debase/deString.c
framework/delibs/debase/deString.h

index 369745d..35c735f 100644 (file)
@@ -40,6 +40,7 @@
 #include "tcuResultCollector.hpp"
 
 #include "deUniquePtr.hpp"
+#include "deString.h"
 #include "deStringUtil.hpp"
 #include "deSTLUtil.hpp"
 #include "deMemory.h"
@@ -822,6 +823,13 @@ tcu::TestStatus deviceProperties (Context& context)
                return tcu::TestStatus::fail("deviceProperties incomplete initialization");
        }
 
+       // Check if deviceName string is properly terminated.
+       if (deStrnlen(props->deviceName, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE) == VK_MAX_PHYSICAL_DEVICE_NAME_SIZE)
+       {
+               log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties deviceName not properly initialized" << TestLog::EndMessage;
+               return tcu::TestStatus::fail("deviceProperties incomplete initialization");
+       }
+
        {
                const ApiVersion deviceVersion = unpackVersion(props->apiVersion);
                const ApiVersion deqpVersion = unpackVersion(VK_API_VERSION);
index f53657d..777d6a2 100644 (file)
@@ -180,4 +180,14 @@ char* deStrcat (char* s1, size_t size, const char* s2)
 #endif
 }
 
+size_t deStrnlen (const char* string, size_t maxSize)
+{
+#if ((DE_COMPILER == DE_COMPILER_MSC) && (DE_OS != DE_OS_WINCE)) || (__STDC_VERSION__ >= 201100L)
+       return strnlen_s(string, maxSize);
+#else
+       return strnlen(string, maxSize);
+#endif
+
+}
+
 DE_END_EXTERN_C
index 52e232a..cd45465 100644 (file)
@@ -43,6 +43,7 @@ deInt32               deVsprintf                              (char* string, size_t size, const char* format, va_list a
 deInt32                deSprintf                               (char* string, size_t size, const char* format, ...) DE_PRINTF_FUNC_ATTR(3, 4);
 char*          deStrcpy                                (char* dst, size_t size, const char* src);
 char*          deStrcat                                (char* s1, size_t size, const char* s2);
+size_t         deStrnlen                               (const char* string, size_t maxSize);
 
 DE_END_EXTERN_C