@@ -17,7 +17,14 @@ stages:
1717 clean : all
1818 ${{ if eq(parameters.OS, 'MacOS') }} :
1919 pool :
20- vmImage : ' macOS-15'
20+ # Use PoolName if provided, otherwise fallback to macOS-15
21+ ${{ if ne(parameters.PoolName, '') }} :
22+ ${{ if contains(parameters.PoolName, '-') }} :
23+ vmImage : ${{ parameters.PoolName }}
24+ ${{ else }} :
25+ name : ${{ parameters.PoolName }}
26+ ${{ else }} :
27+ vmImage : ' macOS-15'
2128 ${{ if eq(parameters.OS, 'Linux') }} :
2229 pool :
2330 name : ${{ parameters.PoolName }}
@@ -80,6 +87,14 @@ stages:
8087 cd ..
8188 mkdir tests
8289 cd tests
90+ # 1. Diagnostics
91+ echo "System Info:"
92+ uname -a
93+ if [[ "$(uname)" == "Darwin" ]]; then arch; fi
94+ echo "Java Version"
95+ java -version
96+
97+ # 2. Extract
8398 jar xf $(Pipeline.Workspace)/build/onnxruntime-java/testing.jar
8499 rm -f $(Pipeline.Workspace)/build/onnxruntime-java/testing.jar
85100
@@ -93,29 +108,33 @@ stages:
93108 java -version
94109
95110
96- # Set the correct library path based on the OS
111+ # 3. Find with robustness
97112 os_name=$(uname)
98-
99- # Find the directory containing the native library (libonnxruntime.so or libonnxruntime.dylib)
100- # The jar extraction puts them in ai/onnxruntime/native/...
101- if [[ "$os_name" == "Linux" ]]; then
102- # Find the directory containing the native library (libonnxruntime.so)
103- NATIVE_LIB_DIR=$(find $(pwd) -name "libonnxruntime.so" | head -n 1 | xargs dirname)
104- echo "Found Linux native lib dir: $NATIVE_LIB_DIR"
105-
106- echo "Platform: Linux. Setting LD_LIBRARY_PATH."
107- export LD_LIBRARY_PATH="$NATIVE_LIB_DIR:$(pwd):$LD_LIBRARY_PATH"
108- java -cp '$(Pipeline.Workspace)/build/tests:$(Pipeline.Workspace)/build/onnxruntime-java/*' org.junit.platform.console.ConsoleLauncher --scan-classpath=$(Pipeline.Workspace)/build/tests \
109- --fail-if-no-tests --disable-banner --reports-dir "$(Build.ArtifactStagingDirectory)/TestResults"
110- elif [[ "$os_name" == "Darwin" ]]; then
111- # Find the directory containing the native library (libonnxruntime.dylib)
112- NATIVE_LIB_DIR=$(find $(pwd) -name "libonnxruntime.dylib" | head -n 1 | xargs dirname)
113- echo "Found macOS native lib dir: $NATIVE_LIB_DIR"
114-
115- echo "Platform: macOS. Setting DYLD_LIBRARY_PATH."
116- export DYLD_LIBRARY_PATH="$NATIVE_LIB_DIR:$(pwd):$DYLD_LIBRARY_PATH"
117- java -DUSE_WEBGPU=1 -DUSE_COREML=1 -cp '$(Pipeline.Workspace)/build/tests:$(Pipeline.Workspace)/build/onnxruntime-java/*' org.junit.platform.console.ConsoleLauncher --scan-classpath=$(Pipeline.Workspace)/build/tests \
118- --fail-if-no-tests --disable-banner --reports-dir "$(Build.ArtifactStagingDirectory)/TestResults"
113+ if [[ "$os_name" == "Linux" ]]; then S_FILE="libonnxruntime.so"; else S_FILE="libonnxruntime.dylib"; fi
114+
115+ echo "Searching for $S_FILE in $(pwd)..."
116+ # Exclude .dSYM paths and find actual file
117+ NATIVE_LIB_PATH=$(find $(pwd) -name "$S_FILE" -not -path "*.dSYM*" -type f | head -n 1)
118+
119+ if [[ -n "$NATIVE_LIB_PATH" ]]; then
120+ NATIVE_LIB_DIR=$(dirname "$NATIVE_LIB_PATH")
121+ echo "Found native lib dir: $NATIVE_LIB_DIR"
122+
123+ if [[ "$os_name" == "Linux" ]]; then
124+ echo "Platform: Linux. Setting LD_LIBRARY_PATH."
125+ export LD_LIBRARY_PATH="$NATIVE_LIB_DIR:$(pwd):$LD_LIBRARY_PATH"
126+ java -cp '$(Pipeline.Workspace)/build/tests:$(Pipeline.Workspace)/build/onnxruntime-java/*' org.junit.platform.console.ConsoleLauncher --scan-classpath=$(Pipeline.Workspace)/build/tests \
127+ --fail-if-no-tests --disable-banner --reports-dir "$(Build.ArtifactStagingDirectory)/TestResults"
128+ elif [[ "$os_name" == "Darwin" ]]; then
129+ echo "Platform: macOS. Setting DYLD_LIBRARY_PATH."
130+ export DYLD_LIBRARY_PATH="$NATIVE_LIB_DIR:$(pwd):$DYLD_LIBRARY_PATH"
131+ java -DUSE_WEBGPU=1 -DUSE_COREML=1 -cp '$(Pipeline.Workspace)/build/tests:$(Pipeline.Workspace)/build/onnxruntime-java/*' org.junit.platform.console.ConsoleLauncher --scan-classpath=$(Pipeline.Workspace)/build/tests \
132+ --fail-if-no-tests --disable-banner --reports-dir "$(Build.ArtifactStagingDirectory)/TestResults"
133+ fi
134+ else
135+ echo "Error: $S_FILE not found!"
136+ ls -R ai
137+ exit 1
119138 fi
120139
121140
0 commit comments