| 36 | }; |
| 37 | |
| 38 | TEST_F(ApiDumpTests, init_layer) { |
| 39 | TEST_DESCRIPTION("Test Creating a Vulkan Instance with a layer"); |
| 40 | |
| 41 | VkBool32 use_file = VK_TRUE; |
| 42 | const char* filename_string = "api_dump_output.html"; |
| 43 | const char* output_format = "html"; |
| 44 | |
| 45 | const std::vector<VkLayerSettingEXT> settings = { |
| 46 | {kLayerName, "file", VK_LAYER_SETTING_TYPE_BOOL32_EXT, 1, &use_file}, |
| 47 | {kLayerName, "log_filename", VK_LAYER_SETTING_TYPE_STRING_EXT, 1, &filename_string}, |
| 48 | {kLayerName, "output_format", VK_LAYER_SETTING_TYPE_STRING_EXT, 1, &output_format}}; |
| 49 | |
| 50 | layer_test::VulkanInstanceBuilder inst_builder; |
| 51 | VkResult err = inst_builder.Init(settings); |
| 52 | EXPECT_EQ(err, VK_SUCCESS); |
| 53 | |
| 54 | // check the output file is generated |
| 55 | const std::filesystem::path path = std::filesystem::current_path() / std::filesystem::path(filename_string); |
| 56 | FILE* file = fopen(path.string().c_str(), "r"); |
| 57 | ASSERT_TRUE(file != NULL); |
| 58 | |
| 59 | const char* file_start_content_expected = "<!doctype html>"; |
| 60 | std::string file_start_content_read; |
| 61 | file_start_content_read.resize(std::strlen(file_start_content_expected)); |
| 62 | |
| 63 | size_t fread_return = fread(&file_start_content_read[0], 1, file_start_content_read.size(), file); |
| 64 | EXPECT_EQ(fread_return, file_start_content_read.size()); |
| 65 | fclose(file); |
| 66 | |
| 67 | EXPECT_STREQ(file_start_content_read.c_str(), file_start_content_expected); |
| 68 | } |