-
Notifications
You must be signed in to change notification settings - Fork 115
Description
See this search query: https://github.com/search?q=repo%3AROCm%2Frocm-libraries+%2Fexepath.*_gentest.py%2F&type=code, with these current results:
rocm-libraries/projects/hipblas/clients/common/hipblas_parse_data.cpp
Lines 36 to 40 in c340dae
static std::string hipblas_parse_yaml(const std::string& yaml) { std::string tmp = hipblas_tempname(); auto exepath = hipblas_exepath(); auto cmd = exepath + "hipblas_gentest.py --template " + exepath + "hipblas_template.yaml -o " rocm-libraries/projects/rocblas/clients/common/rocblas_parse_data.cpp
Lines 50 to 51 in c340dae
auto cmd = exepath + "rocblas_gentest.py --template " + exepath + "rocblas_template.yaml -o " + tmp + " " + yaml_path; auto exepath = hipblaslt_exepath(); auto cmd = exepath + "hipblaslt_gentest.py --template " + exepath + "hipblaslt_template.yaml -o " + tmp + " " + yaml; rocm-libraries/projects/hipsparselt/clients/common/hipsparselt_parse_data.cpp
Lines 53 to 55 in c340dae
auto exepath = hipsparselt_exepath(); auto cmd = exepath + "hipsparselt_gentest.py --template " + exepath + "hipsparselt_template.yaml -o " + tmp + " " + yaml; auto cmd = exepath + "rocsparse_gentest.py ";
These translate to calls like system("/path/to/directory/foo_gentest.py --template ...)"
, which treat the .py
files as executables. On Linux, the shebangs in the scripts handle running under the python interpreter (usually the system interpreter, so this may escape venv sandboxes?). On Windows, this relies on file associations for the .py extension.
On my developer machine, I have .py files associated with Visual Studio Code, rather than the python interpreter:

This results in running test commands like rocblas-test.exe --yaml rocblas_smoke.yaml
pausing during execution to open the gentest file in my editor, instead of running it.
One way to make this more robust is adding python
to the command strings. I had a patch for that on ROCm/TheRock#783, like so:
clients/common/rocblas_parse_data.cpp | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/clients/common/rocblas_parse_data.cpp b/clients/common/rocblas_parse_data.cpp
index 83039751..399a709f 100644
--- a/clients/common/rocblas_parse_data.cpp
+++ b/clients/common/rocblas_parse_data.cpp
@@ -47,15 +47,20 @@ static std::string rocblas_parse_yaml(const std::string& yaml)
yaml_path = yaml;
}
- auto cmd = exepath + "rocblas_gentest.py --template " + exepath + "rocblas_template.yaml -o "
+#ifdef WIN32
+ // Windows prefers to only run certain file extensions as executables, so run under 'python'.
+ auto cmd = "python " + exepath + "rocblas_gentest.py --template " + exepath + "rocblas_template.yaml -o "
+ tmp + " " + yaml_path;
rocblas_cerr << cmd << std::endl;
-
-#ifdef WIN32
int status = std::system(cmd.c_str());
if(status == -1)
exit(EXIT_FAILURE);
#else
+ // Linux can run the python script directly thanks to the `#!/usr/bin/env python3` shebang.
+ // If we ran 'python' as above, we might fail unless python-is-python3 (or equivalent) is configured.
+ auto cmd = exepath + "rocblas_gentest.py --template " + exepath + "rocblas_template.yaml -o "
+ + tmp + " " + yaml_path;
+ rocblas_cerr << cmd << std::endl;
int status = system(cmd.c_str());
if(status == -1 || !WIFEXITED(status) || WEXITSTATUS(status))
exit(EXIT_FAILURE);
--