From e42f0da3067a1506b8bf4c065d936c1c745f720c Mon Sep 17 00:00:00 2001 From: Mark Young Date: Tue, 22 Nov 2016 15:01:32 -0700 Subject: [PATCH] via: Fix missing items on Linux VIA was failing because it was missing a few linux search paths. Also, it would fail incorrectly if the top-level test folder wasn't there instead of sending back a no-exist flag. Change-Id: I83cff1b921c5986c3eaf073c7658eca75221f378 --- via/via.cpp | 223 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 155 insertions(+), 68 deletions(-) diff --git a/via/via.cpp b/via/via.cpp index 3c273f1af5..dc109a0ab3 100644 --- a/via/via.cpp +++ b/via/via.cpp @@ -347,6 +347,11 @@ void StartOutput(std::string output) { << " font-size: 25px;" << std::endl << " color: #FFFFFF;" << std::endl << " }" << std::endl + << " h2.note {" << std::endl + << " font-family: sans-serif;" << std::endl + << " font-size: 22px;" << std::endl + << " color: #FFFFFF;" << std::endl + << " }" << std::endl << " table {" << std::endl << " min-width: 600px;" << std::endl << " width: 70%;" << std::endl @@ -410,8 +415,11 @@ void StartOutput(std::string output) { } global_items.html_file_stream << APP_VERSION << "" << std::endl - << "
" << std::endl << "
" << std::endl; + + global_items.html_file_stream << APP_VERSION << "

< NOTE: Click on section name to expand table >

" + << std::endl + << "
" << std::endl; } // Close out writing to the HTML file. @@ -796,9 +804,13 @@ int RunTestInDirectory(std::string path, std::string test, if (TRUE == PathFileExists(test.c_str())) { err_code = system(cmd_line.c_str()); } else { + // Path to specific exe doesn't exist err_code = 1; } SetCurrentDirectoryA(orig_dir); + } else { + // Path to test doesn't exist. + err_code = 1; } return err_code; } @@ -2534,12 +2546,13 @@ void PrintDriverInfo(void) { uint32_t j = 0; bool found_json = false; bool found_lib = false; + char *env_value = NULL; PrintBeginTable("Vulkan Driver Info", 3); - // There are three folders ICD JSONs could be in. So, - // try all three. - for (uint32_t dir = 0; dir < 5; dir++) { + // There are several folders ICD JSONs could be in. So, + // try all of them. + for (uint32_t dir = 0; dir < 6; dir++) { std::string cur_driver_path; std::string cur_driver_json; switch (dir) { @@ -2555,14 +2568,22 @@ void PrintDriverInfo(void) { case 3: cur_driver_path = "/usr/local/share/vulkan/icd.d"; break; - case 4: { - char *env_value = getenv("VK_DRIVERS_PATH"); + case 4: + env_value = getenv("HOME"); + if (NULL == env_value) { + cur_driver_path = "~/.local/share/vulkan/icd.d"; + } else { + cur_driver_path = env_value; + cur_driver_path += "/.local/share/vulkan/icd.d"; + } + break; + case 5: + env_value = getenv("VK_DRIVERS_PATH"); if (NULL == env_value) { continue; } cur_driver_path = env_value; break; - } default: continue; } @@ -3178,93 +3199,156 @@ void PrintLayerInfo(void) { char cur_vulkan_layer_json[MAX_STRING_LENGTH]; DIR *layer_dir; dirent *cur_ent; - const char implicit_layer_dir[] = "/etc/vulkan/implicit_layer.d"; - const char explicit_layer_dir[] = "/etc/vulkan/explicit_layer.d"; std::string layer_path; + char *env_value = NULL; // Dump out implicit layer information first PrintBeginTable("Implicit Layers", 3); - PrintBeginTableRow(); - PrintTableElement("Location"); - PrintTableElement(implicit_layer_dir); - PrintTableElement(""); - PrintEndTableRow(); - layer_dir = opendir(implicit_layer_dir); - if (NULL != layer_dir) { - while ((cur_ent = readdir(layer_dir)) != NULL) { - if (NULL != strstr(cur_ent->d_name, ".json")) { - snprintf(generic_string, MAX_STRING_LENGTH - 1, "[%d]", i++); - snprintf(cur_vulkan_layer_json, MAX_STRING_LENGTH - 1, "%s/%s", - implicit_layer_dir, cur_ent->d_name); + // There are several folders implicit layers could be in. So, + // try all of them. + for (uint32_t dir = 0; dir < 5; dir++) { + std::string cur_layer_path; + switch (dir) { + case 0: + cur_layer_path = "/etc/vulkan/implicit_layer.d"; + break; + case 1: + cur_layer_path = "/usr/share/vulkan/implicit_layer.d"; + break; + case 2: + cur_layer_path = "/usr/local/etc/vulkan/implicit_layer.d"; + break; + case 3: + cur_layer_path = "/usr/local/share/vulkan/implicit_layer.d"; + break; + case 4: + env_value = getenv("HOME"); + if (NULL == env_value) { + cur_layer_path = "~/.local/share/vulkan/implicit_layer.d"; + } else { + cur_layer_path = env_value; + cur_layer_path += "/.local/share/vulkan/implicit_layer.d"; + } + break; + default: + continue; + } - PrintBeginTableRow(); - PrintTableElement(generic_string, ALIGN_RIGHT); - PrintTableElement(cur_ent->d_name); - PrintTableElement(""); - PrintEndTableRow(); + PrintBeginTableRow(); + PrintTableElement(cur_layer_path); + PrintTableElement(""); + PrintTableElement(""); + PrintEndTableRow(); + + layer_dir = opendir(cur_layer_path.c_str()); + if (NULL != layer_dir) { + while ((cur_ent = readdir(layer_dir)) != NULL) { + if (NULL != strstr(cur_ent->d_name, ".json")) { + snprintf(generic_string, MAX_STRING_LENGTH - 1, "[%d]", i++); + snprintf(cur_vulkan_layer_json, MAX_STRING_LENGTH - 1, "%s/%s", + cur_layer_path.c_str(), cur_ent->d_name); - std::ifstream *stream = NULL; - stream = - new std::ifstream(cur_vulkan_layer_json, std::ifstream::in); - if (nullptr == stream || stream->fail()) { PrintBeginTableRow(); - PrintTableElement(""); - PrintTableElement("ERROR reading JSON file!"); + PrintTableElement(generic_string, ALIGN_RIGHT); + PrintTableElement(cur_ent->d_name); PrintTableElement(""); PrintEndTableRow(); - failed = true; - } else { - Json::Value root = Json::nullValue; - Json::Reader reader; - if (!reader.parse(*stream, root, false) || root.isNull()) { - // Report to the user the failure and their - // locations in the document. + + std::ifstream *stream = NULL; + stream = + new std::ifstream(cur_vulkan_layer_json, std::ifstream::in); + if (nullptr == stream || stream->fail()) { PrintBeginTableRow(); PrintTableElement(""); - PrintTableElement("ERROR parsing JSON file!"); - PrintTableElement(reader.getFormattedErrorMessages()); + PrintTableElement("ERROR reading JSON file!"); + PrintTableElement(""); PrintEndTableRow(); failed = true; } else { - PrintExplicitLayerJsonInfo(cur_vulkan_layer_json, root, - 3); - } + Json::Value root = Json::nullValue; + Json::Reader reader; + if (!reader.parse(*stream, root, false) || root.isNull()) { + // Report to the user the failure and their + // locations in the document. + PrintBeginTableRow(); + PrintTableElement(""); + PrintTableElement("ERROR parsing JSON file!"); + PrintTableElement(reader.getFormattedErrorMessages()); + PrintEndTableRow(); + failed = true; + } else { + PrintExplicitLayerJsonInfo(cur_vulkan_layer_json, root, + 3); + } - stream->close(); - delete stream; - stream = NULL; + stream->close(); + delete stream; + stream = NULL; + } } } + closedir(layer_dir); + } else { + PrintBeginTableRow(); + PrintTableElement(""); + PrintTableElement("Directory does not exist"); + PrintTableElement(""); + PrintEndTableRow(); } - closedir(layer_dir); - } else { - PrintBeginTableRow(); - PrintTableElement(""); - PrintTableElement("Directory does not exist"); - PrintTableElement(""); - PrintEndTableRow(); } PrintEndTable(); // Dump out any explicit layer information. PrintBeginTable("Explicit Layers", 3); - std::string explicit_layer_id = "Global path"; - std::string explicit_layer_path = explicit_layer_dir; - - if (!PrintExplicitLayersInFolder(explicit_layer_id, explicit_layer_path)) { - failed = true; - } - - explicit_layer_id = "VK_LAYER_PATH"; - char *env_value = getenv("VK_LAYER_PATH"); - if (NULL != env_value) { - explicit_layer_path = env_value; - if (!PrintExplicitLayersInFolder(explicit_layer_id, - explicit_layer_path)) { - failed = true; + // There are several folders explicit layers could be in. So, + // try all of them. + for (uint32_t dir = 0; dir < 6; dir++) { + std::string cur_layer_path; + std::string explicit_layer_id; + std::string explicit_layer_path = cur_layer_path; + char *env_value = NULL; + switch (dir) { + case 0: + cur_layer_path = "/etc/vulkan/explicit_layer.d"; + explicit_layer_id = "/etc/vulkan"; + break; + case 1: + cur_layer_path = "/usr/share/vulkan/explicit_layer.d"; + explicit_layer_id = "/usr/share/vulkan"; + break; + case 2: + cur_layer_path = "/usr/local/etc/vulkan/explicit_layer.d"; + explicit_layer_id = "/usr/local/etc/vulkan"; + break; + case 3: + cur_layer_path = "/usr/local/share/vulkan/explicit_layer.d"; + explicit_layer_id = "/usr/local/share/vulkan"; + break; + case 4: + explicit_layer_id = "$HOME/.local/share/vulkan/explicit_layer.d"; + env_value = getenv("HOME"); + if (NULL == env_value) { + cur_layer_path = "~/.local/share/vulkan/explicit_layer.d"; + } else { + cur_layer_path = env_value; + cur_layer_path += "/.local/share/vulkan/explicit_layer.d"; + } + break; + case 5: + explicit_layer_id = "VK_LAYER_PATH"; + env_value = getenv("VK_LAYER_PATH"); + if (NULL == env_value) { + continue; + } + cur_layer_path = env_value; + break; + default: + continue; } + + PrintExplicitLayersInFolder(explicit_layer_id, cur_layer_path); } PrintEndTable(); @@ -3294,6 +3378,9 @@ int RunTestInDirectory(std::string path, std::string test, // exe. So, just return a separate error code. err_code = 1; } + } else { + // Path doesn't exist at all + err_code = 1; } chdir(orig_dir); }