Skip to content

Commit

Permalink
via: Fix missing items on Linux
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MarkY-LunarG committed Nov 22, 2016
1 parent cf91d4e commit e42f0da
Showing 1 changed file with 155 additions and 68 deletions.
223 changes: 155 additions & 68 deletions via/via.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -410,8 +415,11 @@ void StartOutput(std::string output) {
}
global_items.html_file_stream << APP_VERSION << "</center></h1>"
<< std::endl
<< " <BR />" << std::endl
<< " <BR />" << std::endl;

global_items.html_file_stream << APP_VERSION << "<center><h2 class=\"note\">< NOTE: Click on section name to expand table ></h2></center>"
<< std::endl
<< " <BR />" << std::endl;
}

// Close out writing to the HTML file.
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit e42f0da

Please sign in to comment.