From 45eb52b8edb5bcda515a2610dfd8cefe7c7a7107 Mon Sep 17 00:00:00 2001 From: yalue Date: Tue, 17 Feb 2026 09:32:16 -0500 Subject: [PATCH] Remove amd64 darwin from onnxruntime_test.go - Even though the amd64 darwin .dylib file was removed from test_data, onnxruntime_test.go still would attempt to set a path for it. This change cleans up the code to clarify the three libraries that are included in test_data, and fails if no library is loaded. --- CONTRIBUTING.md | 7 +++---- README.md | 2 +- onnxruntime_test.go | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dc31c92..66bc84e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,8 +49,7 @@ Tests - No tests should panic. Always check errors and fail rather than allowing tests to panic. - - Every change must ensure that `go test -v -bench=.` passes on every - supported platform. + - Every change must ensure that `go test -v -bench=.` passes. - Every test failure should be accompanied by a message containing the reason, either using `t.Logf()`, `t.Errorf()`, or `t.Fatalf()`. @@ -74,8 +73,8 @@ Adding New Files these files are updated. The libraries that are included were only intended to allow a majority of users to run `go test -v -bench=.` without further setup or modification. Currently: amd64 Windows, arm64 Linux (I wish I - hadn't included this!), arm64 osx, and amd64 osx. All other users must set - the `ONNXRUNTIME_SHARED_LIBRARY_PATH` environment variable to a valid path + hadn't included this!), and arm64 osx. All other users must set the + `ONNXRUNTIME_SHARED_LIBRARY_PATH` environment variable to a valid path to the correct `onnxruntime` shared library file prior to running tests. - If you need to add a .onnx file for a test, place both the .onnx file diff --git a/README.md b/README.md index e4f37d4..1438b96 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ download from the releases page in the for the release you want to use, and extract it. The header files are located in the "include" subdirectory, and the shared library will be located in the "lib" subdirectory. (On Linux systems, you'll need the version of the .so with -the appended version numbers, e.g., `libonnxruntime.so.1.23.2`, and _not_ the +the appended version numbers, e.g., `libonnxruntime.so.1.24.1`, and _not_ the `libonnxruntime.so`, which is just a symbolic link.) The archive will contain several other files containing C++ headers, debug symbols, and so on, but you shouldn't need anything other than the single onnxruntime shared library and diff --git a/onnxruntime_test.go b/onnxruntime_test.go index 01922ad..c0301a7 100644 --- a/onnxruntime_test.go +++ b/onnxruntime_test.go @@ -24,19 +24,20 @@ func getTestSharedLibraryPath(t testing.TB) string { if toReturn != "" { return toReturn } - if runtime.GOOS == "windows" { + if (runtime.GOOS == "windows") && (runtime.GOARCH == "amd64") { return "test_data/onnxruntime.dll" } - if runtime.GOARCH == "arm64" { - if runtime.GOOS == "darwin" { - return "test_data/onnxruntime_arm64.dylib" - } + if (runtime.GOOS == "darwin") && (runtime.GOARCH == "arm64") { + return "test_data/onnxruntime_arm64.dylib" + } + if (runtime.GOOS == "linux") && (runtime.GOARCH == "arm64") { return "test_data/onnxruntime_arm64.so" } - if runtime.GOARCH == "amd64" && runtime.GOOS == "darwin" { - return "test_data/onnxruntime_amd64.dylib" - } - return "test_data/onnxruntime.so" + t.Fatalf("Unable to find an onnxruntime shared library for GOOS %s and "+ + "GOARCH %s. Set the ONNXRUNTIME_SHARED_LIBRARY_PATH environment "+ + "variable to run tests on your system.\n", runtime.GOOS, + runtime.GOARCH) + return fmt.Sprintf("onnxruntime_%s_%s.so", runtime.GOOS, runtime.GOARCH) } // This must be called prior to running each test.