tests: Add Device init that takes list of layers to enable

Call it from the layer validation test
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index 451a883..8d62a93 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -66,6 +66,30 @@
         ErrorMonitor               *m_errorMonitor;
 
     virtual void SetUp() {
+        const char *layer_names[] = {"MemTracker", "ObjectTracker"};
+        const std::vector<const char *> layers(layer_names, layer_names + 2);
+
+        size_t extSize = sizeof(uint32_t);
+        uint32_t extCount = 0;
+        VkResult err;
+        err = vkGetGlobalExtensionInfo(VK_EXTENSION_INFO_TYPE_COUNT, 0, &extSize, &extCount);
+        assert(!err);
+
+        VkExtensionProperties extProp;
+        extSize = sizeof(VkExtensionProperties);
+        bool32_t extFound;
+
+        for (uint32_t i = 0; i < layers.size(); i++) {
+            extFound = 0;
+            for (uint32_t j = 0; j < extCount; j++) {
+                err = vkGetGlobalExtensionInfo(VK_EXTENSION_INFO_TYPE_PROPERTIES, j, &extSize, &extProp);
+                if (!strcmp(layers[i], extProp.extName)) {
+                   extFound = 1;
+                   break;
+                }
+            }
+            ASSERT_EQ(extFound, 1) << "ERROR: Cannot find extension named " << layers[i] << " which is necessary to pass this test";
+        }
 
         this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
         this->app_info.pNext = NULL;
@@ -75,7 +99,7 @@
         this->app_info.engineVersion = 1;
         this->app_info.apiVersion = VK_API_VERSION;
 
-        InitFramework();
+        InitFramework(layers);
         m_errorMonitor = new ErrorMonitor(inst);
     }
 
diff --git a/tests/run_all_tests_with_layers.sh b/tests/run_all_tests_with_layers.sh
index 269106d..87f3845 100755
--- a/tests/run_all_tests_with_layers.sh
+++ b/tests/run_all_tests_with_layers.sh
@@ -37,6 +37,8 @@
 # a saved "golden" image and will report an error if there is any difference
 ./vk_render_tests --compare-images
 
+./vk_layer_validation_tests
+
 if [ "$RESTORE_SETTINGS" = "true" ]; then
     echo Restore $SETTINGS_NAME from $TMP_SETTINGS_NAME
     mv $TMP_SETTINGS_NAME $SETTINGS_NAME
diff --git a/tests/vkrenderframework.cpp b/tests/vkrenderframework.cpp
index 4f670c6..d67a700 100644
--- a/tests/vkrenderframework.cpp
+++ b/tests/vkrenderframework.cpp
@@ -60,6 +60,12 @@
 
 void VkRenderFramework::InitFramework()
 {
+     const std::vector<const char *> layers;
+     InitFramework(layers);
+}
+
+void VkRenderFramework::InitFramework(const std::vector<const char *> &layers)
+{
     VkResult err;
     VkInstanceCreateInfo instInfo = {};
     instInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
@@ -77,7 +83,7 @@
     ASSERT_VK_SUCCESS(err);
     ASSERT_GE(this->gpu_count, 1) << "No GPU available";
 
-    m_device = new VkDeviceObj(0, objs[0]);
+    m_device = new VkDeviceObj(0, objs[0], layers);
     m_device->get_device_queue();
 
     m_depthStencil = new VkDepthStencilObj();
@@ -265,6 +271,15 @@
     queue_props = &gpu().queue_properties()[0];
 }
 
+VkDeviceObj::VkDeviceObj(uint32_t id, VkPhysicalDevice obj, const std::vector<const char *> &layers) :
+    vk_testing::Device(obj), id(id)
+{
+    init(layers);
+
+    props = gpu().properties();
+    queue_props = &gpu().queue_properties()[0];
+}
+
 void VkDeviceObj::get_device_queue()
 {
     ASSERT_NE(true, graphics_queues().empty());
diff --git a/tests/vkrenderframework.h b/tests/vkrenderframework.h
index 9a6f59e..4d2e561 100644
--- a/tests/vkrenderframework.h
+++ b/tests/vkrenderframework.h
@@ -35,6 +35,7 @@
 {
 public:
     VkDeviceObj(uint32_t id, VkPhysicalDevice obj);
+    VkDeviceObj(uint32_t id, VkPhysicalDevice obj, const std::vector<const char *> &layers);
 
     VkDevice device() { return obj(); }
     void get_device_queue();
@@ -93,6 +94,7 @@
     void InitRenderTarget(VkDepthStencilBindInfo *dsBinding);
     void InitRenderTarget(uint32_t targets, VkDepthStencilBindInfo *dsBinding);
     void InitFramework();
+    void InitFramework(const std::vector<const char *> &layers);
     void ShutdownFramework();
     void InitState();
 
diff --git a/tests/vktestbinding.cpp b/tests/vktestbinding.cpp
index f084662..0190ee8 100644
--- a/tests/vktestbinding.cpp
+++ b/tests/vktestbinding.cpp
@@ -401,6 +401,43 @@
 
     init(dev_info);
 }
+void Device::init(const std::vector<const char *> &layers)
+{
+    const char *ext_names[] = {
+        "VK_WSI_LunarG",
+    };
+
+    // request all queues
+    const std::vector<VkPhysicalDeviceQueueProperties> queue_props = gpu_.queue_properties();
+    std::vector<VkDeviceQueueCreateInfo> queue_info;
+    queue_info.reserve(queue_props.size());
+    for (int i = 0; i < queue_props.size(); i++) {
+        VkDeviceQueueCreateInfo qi = {};
+        qi.queueNodeIndex = i;
+        qi.queueCount = queue_props[i].queueCount;
+        if (queue_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
+            graphics_queue_node_index_ = i;
+        }
+        queue_info.push_back(qi);
+    }
+    VkLayerCreateInfo layer_info = {};
+    if (layers.size()) {
+        layer_info.sType = VK_STRUCTURE_TYPE_LAYER_CREATE_INFO;
+        layer_info.layerCount = layers.size();
+        layer_info.ppActiveLayerNames = &layers[0];
+    }
+
+    VkDeviceCreateInfo dev_info = {};
+    dev_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
+    dev_info.pNext = (layers.size()) ? static_cast<void *>(&layer_info) : NULL;
+    dev_info.queueRecordCount = queue_info.size();
+    dev_info.pRequestedQueues = &queue_info[0];
+    dev_info.extensionCount = 1;
+    dev_info.ppEnabledExtensionNames = ext_names;
+    dev_info.flags = VK_DEVICE_CREATE_VALIDATION_BIT;
+
+    init(dev_info);
+}
 
 void Device::init(const VkDeviceCreateInfo &info)
 {
diff --git a/tests/vktestbinding.h b/tests/vktestbinding.h
index ca37380..0ad984f 100644
--- a/tests/vktestbinding.h
+++ b/tests/vktestbinding.h
@@ -214,6 +214,7 @@
     // vkCreateDevice()
     void init(const VkDeviceCreateInfo &info);
     void init(bool enable_layers); // all queues, all extensions, etc
+    void init(const std::vector<const char *> &layers);
     void init() { init(false); };
 
     const PhysicalGpu &gpu() const { return gpu_; }