From: Cordell Bloor <cgmb@slerp.xyz>
Date: Tue, 11 Jul 2023 01:57:48 -0600
Subject: move rocsblas test data to share

The rocblas_test.data file is a binary file containing arguments to
test with rocblas functions (e.g., various combinations of matrix
sizes and other similar options). It is created by rocblas_gentest.py
and is architecture-independent (as it always uses network byte order).

Forwarded: not-needed
---
 clients/gtest/rocblas_gtest_main.cpp | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/clients/gtest/rocblas_gtest_main.cpp b/clients/gtest/rocblas_gtest_main.cpp
index 4fb7606..6264aa7 100644
--- a/clients/gtest/rocblas_gtest_main.cpp
+++ b/clients/gtest/rocblas_gtest_main.cpp
@@ -20,6 +20,7 @@
  *
  * ************************************************************************ */
 
+#include <unistd.h>
 #include <string>
 
 #include "rocblas_data.hpp"
@@ -28,6 +29,13 @@
 #include "test_cleanup.hpp"
 #include "utility.hpp"
 
+#define TO_STR2(x) #x
+#define TO_STR(x) TO_STR2(x)
+#define ROCBLAS_VERSION_STRING \
+        TO_STR(ROCBLAS_VERSION_MAJOR) "." \
+        TO_STR(ROCBLAS_VERSION_MINOR) "." \
+        TO_STR(ROCBLAS_VERSION_PATCH)
+
 using namespace testing;
 
 class ConfigurableEventListener : public TestEventListener
@@ -258,7 +266,20 @@ int main(int argc, char** argv)
     rocblas_print_usage_warning();
 
     // Set data file path
-    rocblas_parse_data(argc, argv, rocblas_exepath() + "rocblas_gtest.data");
+    std::string exe_path = rocblas_exepath();
+    std::vector<std::string> candidates;
+    candidates.push_back(exe_path + "rocblas_gtest.data");
+    candidates.push_back("/usr/share/rocblas/" ROCBLAS_VERSION_STRING "/test/rocblas_gtest.data");
+    size_t idx;
+    for(idx = 0; idx < candidates.size(); ++idx)
+        if(access(candidates[idx].c_str(), F_OK) == 0)
+            break;
+    if(idx == candidates.size())
+    {
+        rocblas_cerr << "Error: rocblas_gtest.data not found" << std::endl;
+        return -1;
+    }
+    rocblas_parse_data(argc, argv, candidates[idx]);
 
     // Initialize Google Tests
     testing::InitGoogleTest(&argc, argv);
