Add a simple unit test for hal::vulkan::dynamic_symbols.

Progress on #9

PiperOrigin-RevId: 274039569
diff --git a/iree/hal/vulkan/BUILD b/iree/hal/vulkan/BUILD
index 6fcca25..ea86e19 100644
--- a/iree/hal/vulkan/BUILD
+++ b/iree/hal/vulkan/BUILD
@@ -1,6 +1,6 @@
 # HAL implementation using Vulkan and (likely) SPIR-V executables.
 
-load("//iree:build_defs.bzl", "PLATFORM_VULKAN_LOADER_COPTS")
+load("//iree:build_defs.bzl", "PLATFORM_VULKAN_LOADER_COPTS", "PLATFORM_VULKAN_TEST_DEPS")
 
 package(
     default_visibility = ["//visibility:public"],
@@ -141,6 +141,15 @@
     ],
 )
 
+cc_test(
+    name = "dynamic_symbols_test",
+    srcs = ["dynamic_symbols_test.cc"],
+    deps = [
+        ":status_util",
+        ":dynamic_symbols",
+    ] + PLATFORM_VULKAN_TEST_DEPS,
+)
+
 cc_library(
     name = "extensibility_util",
     srcs = ["extensibility_util.cc"],
diff --git a/iree/hal/vulkan/dynamic_symbols_test.cc b/iree/hal/vulkan/dynamic_symbols_test.cc
new file mode 100644
index 0000000..7eb269a
--- /dev/null
+++ b/iree/hal/vulkan/dynamic_symbols_test.cc
@@ -0,0 +1,72 @@
+// Copyright 2019 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "iree/hal/vulkan/dynamic_symbols.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include "iree/hal/vulkan/status_util.h"
+
+namespace iree {
+namespace hal {
+namespace vulkan {
+namespace {
+
+VkApplicationInfo GetApplicationInfo() {
+  VkApplicationInfo app_info;
+  app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
+  app_info.pNext = nullptr;
+  app_info.pApplicationName = "IREE-ML-TEST";
+  app_info.applicationVersion = 0;
+  app_info.pEngineName = "IREE";
+  app_info.engineVersion = 0;
+  app_info.apiVersion = VK_API_VERSION_1_0;
+  return app_info;
+}
+
+VkInstanceCreateInfo GetInstanceCreateInfo(VkApplicationInfo* app_info) {
+  VkInstanceCreateInfo create_info;
+  create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
+  create_info.pNext = nullptr;
+  create_info.flags = 0;
+  create_info.pApplicationInfo = app_info;
+  create_info.enabledLayerCount = 0;
+  create_info.ppEnabledLayerNames = nullptr;
+  create_info.enabledExtensionCount = 0;
+  create_info.ppEnabledExtensionNames = nullptr;
+  return create_info;
+}
+
+TEST(DynamicSymbolsTest, CreateFromSystemLoader) {
+  auto status_or_syms = DynamicSymbols::CreateFromSystemLoader();
+  ASSERT_OK(status_or_syms);
+  ref_ptr<DynamicSymbols> syms = std::move(status_or_syms.ValueOrDie());
+
+  // Create and destroy a VkInstance using the symbols. This is mainly testing
+  // that the symbols were loaded successfully and are actually able to be used.
+  VkApplicationInfo app_info = GetApplicationInfo();
+  VkInstanceCreateInfo create_info = GetInstanceCreateInfo(&app_info);
+  VkInstance instance = VK_NULL_HANDLE;
+  VK_CHECK_OK(
+      syms->vkCreateInstance(&create_info, /*pAllocator=*/nullptr, &instance));
+
+  ASSERT_OK(syms->LoadFromInstance(instance));
+
+  syms->vkDestroyInstance(instance, /*pAllocator=*/nullptr);
+}
+
+}  // namespace
+}  // namespace vulkan
+}  // namespace hal
+}  // namespace iree