[hip-tests] Update API coverage report generator (#1932)

* [hip-tests] Update API coverage report generator

Updates the HIP API coverage tool. It now takes
extra arguments for the location of the catch test folder
and for the working directory. This avoids issues where the output
of the executable is dependent on the path where it is being
executed from.

Also updates CmakeLists.txt to integrate seamlessly with the
hip-tests project and avoid using commands which rely on
relative paths.

* Remove double new line

* Remove Cmake option to generate coverage

Removes Cmake option to generate coverage. Instead, explicitly removes
the gen_coverage target from all (this is already the default but
doing it explicitly prevents confusion).
Šī revīzija ir iekļauta:
Fábio Mestre
2025-12-10 16:53:47 +00:00
revīziju iesūtīja GitHub
vecāks 0c1f87a7f6
revīzija d4fe3f1cc3
9 mainīti faili ar 64 papildinājumiem un 40 dzēšanām
@@ -23,14 +23,33 @@ THE SOFTWARE.
#include "reportGenerators.h"
int main(int argc, char** argv) {
if (argc != 2) {
std::cout << "Please provide the path to the cloned HIP/include/ directory as an argument! "
"Only one argument supported."
if (argc == 2 && std::string(argv[1]) == "--help") {
std::cout << "Usage: " << argv[0] << " <hip-include-dir> <catch-test-dir> [work-dir]\n\n"
<< "Arguments:\n\n"
<< " hip-include-dir Path to the directory containing HIP headers.\n"
<< " Example: <project-root>/projects/hip/include\n"
<< " catch-test-dir Path to the directory containing HIP Catch2 tests.\n"
<< " Example: <project-root>/projects/hip-tests/catch2\n"
<< " work-dir (Optional) Path to the working directory.\n"
<< " Defaults to the current directory.\n"
<< std::endl;
std::cout << "\tExample: ./generateHipAPICoverage /workspace/user1/HIP/include/" << std::endl;
return -1;
return 0;
}
if (argc < 3 || argc > 4) {
std::cerr << "Error: Invalid number of arguments. Use --help for usage information.\n";
return 1;
}
std::string hip_include_path = argv[1];
std::string tests_root_directory{argv[2]};
std::string work_directory = ".";
if (argc == 4) {
work_directory = argv[3];
}
/*
Relative paths to all needed files, as it is expected that the application
is called from the HIP/tests/catch/coverage directory.
@@ -38,7 +57,7 @@ int main(int argc, char** argv) {
std::string hip_api_header_file{
findAbsolutePathOfFile(hip_include_path + "/hip/hip_runtime_api.h")};
std::string hip_rtc_header_file{findAbsolutePathOfFile(hip_include_path + "/hip/hiprtc.h")};
std::string tests_root_directory{findAbsolutePathOfFile("../../catch")};
std::string device_api_file{"device_api_list.txt"};
std::vector<std::string> api_group_names;
@@ -79,10 +98,10 @@ int main(int argc, char** argv) {
}
std::cout << "Generating XML report files." << std::endl;
generateXMLReportFiles(hip_apis, hip_api_groups);
generateXMLReportFiles(hip_apis, hip_api_groups, work_directory);
std::cout << "Generating HTML report files." << std::endl;
generateHTMLReportFiles(hip_apis, hip_api_groups, tests_root_directory, hip_api_header_file,
hip_rtc_header_file);
hip_rtc_header_file, work_directory);
return 0;
}