tests: GH428 Addition of tests for sync validation cases

This branch adds tests that challenge the validation layer on
various synchronization validation cases including:

1) INVALID_CB_SIMULTANEOUS_USE - 2 additional test conditions
    related to VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT
    SimultaneousUse

Change-Id: I821784cffebbc36ca4cd01d15f446db331820f54
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index 09ae44c..5ec12d2 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -13665,6 +13665,74 @@
     vkDestroyRenderPass(m_device->device(), rp, NULL);
 }
 
+TEST_F(VkLayerTest, SimultaneousUse) {
+    TEST_DESCRIPTION("Use vkCmdExecuteCommands with invalid state "
+                     "in primary and secondary command buffers.");
+
+    ASSERT_NO_FATAL_FAILURE(InitState());
+    ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
+
+    const char *simultaneous_use_message1 =
+            "does not have VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT set and "
+            "will cause primary command buffer";
+    const char *simultaneous_use_message2 =
+            "w/o VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT set!";
+
+    VkCommandBufferAllocateInfo command_buffer_allocate_info = {};
+    command_buffer_allocate_info.sType =
+            VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
+    command_buffer_allocate_info.commandPool = m_commandPool;
+    command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
+    command_buffer_allocate_info.commandBufferCount = 1;
+
+    VkCommandBuffer secondary_command_buffer;
+    ASSERT_VK_SUCCESS(vkAllocateCommandBuffers(m_device->device(),
+                                               &command_buffer_allocate_info,
+                                               &secondary_command_buffer));
+    VkCommandBufferBeginInfo command_buffer_begin_info = {};
+    VkCommandBufferInheritanceInfo command_buffer_inheritance_info = {};
+    command_buffer_inheritance_info.sType =
+            VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO;
+    command_buffer_inheritance_info.renderPass = m_renderPass;
+    command_buffer_inheritance_info.framebuffer = m_framebuffer;
+    command_buffer_begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+    command_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT |
+                 VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
+    command_buffer_begin_info.pInheritanceInfo = &command_buffer_inheritance_info;
+
+    vkBeginCommandBuffer(secondary_command_buffer, &command_buffer_begin_info);
+    vkEndCommandBuffer(secondary_command_buffer);
+
+    command_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
+    vkBeginCommandBuffer(m_commandBuffer->handle(), &command_buffer_begin_info);
+
+    vkEndCommandBuffer(m_commandBuffer->handle());
+
+    VkSubmitInfo submit_info = {};
+    submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+    submit_info.commandBufferCount = 1;
+    submit_info.pCommandBuffers =&m_commandBuffer->handle();
+
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT,
+                                         simultaneous_use_message1);
+    vkCmdExecuteCommands(m_commandBuffer->handle(), 1,
+                         &secondary_command_buffer);
+    m_errorMonitor->VerifyFound();
+
+    m_errorMonitor->SetDesiredFailureMsg(0, "");
+    vkResetCommandBuffer(m_commandBuffer->handle(), 0);
+
+    submit_info.pCommandBuffers = &secondary_command_buffer;
+    vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
+
+    vkBeginCommandBuffer(m_commandBuffer->handle(), &command_buffer_begin_info);
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         simultaneous_use_message2);
+    vkCmdExecuteCommands(m_commandBuffer->handle(), 1,
+                         &secondary_command_buffer);
+    m_errorMonitor->VerifyFound();
+}
+
 TEST_F(VkLayerTest, FramebufferIncompatible) {
     TEST_DESCRIPTION("Bind a secondary command buffer with with a framebuffer "
                      "that does not match the framebuffer for the active "