Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/app/test/app_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2963,6 +2963,43 @@ void RegisterAppTests(ImGuiTestEngine* e)
IM_CHECK(still_missing);
};

// AIPROFVIS-703: a .rpv whose compare_files holds a non-string entry used to abort
// the app inside jt::Json::getString(). It must fail as a corrupted project.
t = IM_REGISTER_TEST(e, "app", "sys_project_malformed_compare_files_error");
t->TestFunc = [](ImGuiTestContext* ctx)
{
namespace fs = std::filesystem;

AppWindow* app = AppWindow::GetInstance();
IM_CHECK(app != nullptr);
if (app == nullptr) return;

const fs::path rpv_path =
fs::temp_directory_path() / "rocprofvis_malformed_compare_files.rpv";
{
std::ofstream out(rpv_path);
IM_CHECK(out.is_open());
if (!out.is_open()) return;
out << "{\"general\": {\"version\": \"1.0\", \"compare_files\": [1, 2]}}";
}

Project proj;
std::string path = rpv_path.string();
const Project::OpenResult result = proj.Open(path);
const std::string message = ProjectTestPeer{proj}.OpenErrorMessage();

std::error_code ec;
fs::remove(rpv_path, ec);

// Close the queued error dialog so it doesn't block later tests.
ctx->Yield(2);
ctx->PopupCloseAll();
ctx->Yield(2);

IM_CHECK(result == Project::OpenResult::Failed);
IM_CHECK(message.find("invalid or corrupted") != std::string::npos);
};

// AIPROFVIS-81: Event Details dropped the argument list for HIP API events.
// Presence/shape only -- the args come back asynchronously through the
// controller, with no single table to build a value oracle from.
Expand Down
18 changes: 15 additions & 3 deletions src/view/src/rocprofvis_project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,21 @@ Project::OpenCompare(const std::string& project_id,
bool
Project::JsonValidForLoad(jt::Json& json)
{
jt::Json& general = json[JSON_KEY_GROUP_GENERAL];
return general[JSON_KEY_GENERAL_TRACE_PATH].isString() ||
general[JSON_KEY_GENERAL_COMPARE_FILES].isArray();
jt::Json& general = json[JSON_KEY_GROUP_GENERAL];
jt::Json& compare_files = general[JSON_KEY_GENERAL_COMPARE_FILES];
if(compare_files.isArray())
{
// jt getters abort on a type mismatch, so reject non-string entries here.
for(jt::Json& entry : compare_files.getArray())
{
if(!entry.isString())
{
return false;
}
}
return true;
}
return general[JSON_KEY_GENERAL_TRACE_PATH].isString();
}

void
Expand Down
Loading