tests: Add LVTs for MapMemRange device limits
authorMark Lobodzinski <mark@lunarg.com>
Tue, 15 Nov 2016 16:38:51 +0000 (09:38 -0700)
committerMark Lobodzinski <mark@lunarg.com>
Wed, 16 Nov 2016 21:02:20 +0000 (14:02 -0700)
Tacked them onto InvalidMemoryMapping test.

Change-Id: I62a094461730bcac14649a2ad6adf5cfdd0f2c58

tests/layer_validation_tests.cpp

index d10b5cf..97a8008 100644 (file)
@@ -1484,6 +1484,29 @@ TEST_F(VkLayerTest, InvalidMemoryMapping) {
     vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr);
     m_errorMonitor->VerifyFound();
 
+    // Some platforms have an atomsize of 1 which makes the test meaningless
+    if (atom_size > 3) {
+        // Now with an offset NOT a multiple of the device limit
+        vkUnmapMemory(m_device->device(), mem);
+        err = vkMapMemory(m_device->device(), mem, 0, 4 * atom_size, 0, (void **)&pData);
+        ASSERT_VK_SUCCESS(err);
+        mmr.offset = 3;    // Not a multiple of atom_size
+        mmr.size = VK_WHOLE_SIZE;
+        m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_00644);
+        vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr);
+        m_errorMonitor->VerifyFound();
+
+        // Now with a size NOT a multiple of the device limit
+        vkUnmapMemory(m_device->device(), mem);
+        err = vkMapMemory(m_device->device(), mem, 0, 4 * atom_size, 0, (void **)&pData);
+        ASSERT_VK_SUCCESS(err);
+        mmr.offset = atom_size;
+        mmr.size = 2 * atom_size + 1;    // Not a multiple of atom_size
+        m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_00645);
+        vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr);
+        m_errorMonitor->VerifyFound();
+    }
+
     pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                                            VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
     if (!pass) {