diff --git a/onnxruntime/test/providers/cpu/model_tests.cc b/onnxruntime/test/providers/cpu/model_tests.cc index 5465f81270..09cea4f480 100644 --- a/onnxruntime/test/providers/cpu/model_tests.cc +++ b/onnxruntime/test/providers/cpu/model_tests.cc @@ -48,10 +48,15 @@ extern std::unique_ptr ort_env; -#define ASSERT_ORT_STATUS_OK(function) \ - do { \ - OrtStatus* _tmp_status = (function); \ - ASSERT_EQ(_tmp_status, nullptr) << OrtApis::GetErrorMessage(_tmp_status); \ +// asserts that the OrtStatus* result of `status_expr` does not indicate an error +// note: this takes ownership of the OrtStatus* result +#define ASSERT_ORT_STATUS_OK(status_expr) \ + do { \ + if (OrtStatus* _status = (status_expr); _status != nullptr) { \ + std::unique_ptr _rel_status{ \ + _status, &OrtApis::ReleaseStatus}; \ + FAIL() << "OrtStatus error: " << OrtApis::GetErrorMessage(_rel_status.get()); \ + } \ } while (false) using namespace onnxruntime::common; diff --git a/tools/ci_build/github/azure-pipelines/android-x86_64-crosscompile-ci-pipeline.yml b/tools/ci_build/github/azure-pipelines/android-x86_64-crosscompile-ci-pipeline.yml index 182413df4c..7e8c3cfe37 100644 --- a/tools/ci_build/github/azure-pipelines/android-x86_64-crosscompile-ci-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/android-x86_64-crosscompile-ci-pipeline.yml @@ -34,6 +34,13 @@ stages: inputs: versionSpec: $(pythonVersion) + - task: JavaToolInstaller@0 + displayName: Use jdk 11 + inputs: + versionSpec: '11' + jdkArchitectureOption: 'x64' + jdkSourceOption: 'PreInstalled' + - script: sudo apt-get update -y && sudo apt-get install -y coreutils ninja-build displayName: Install coreutils and ninja @@ -54,15 +61,6 @@ stages: env | grep ANDROID displayName: View Android ENVs - # Start switching to jdk 11 after the Android Emulator is started - # since Android SDK manager requires java 8 - - task: JavaToolInstaller@0 - displayName: Use jdk 11 - inputs: - versionSpec: '11' - jdkArchitectureOption: 'x64' - jdkSourceOption: 'PreInstalled' - - script: | python3 tools/ci_build/build.py \ --android \ @@ -121,6 +119,13 @@ stages: inputs: versionSpec: $(pythonVersion) + - task: JavaToolInstaller@0 + displayName: Use jdk 11 + inputs: + versionSpec: '11' + jdkArchitectureOption: 'x64' + jdkSourceOption: 'PreInstalled' + - script: sudo apt-get update -y && sudo apt-get install -y coreutils ninja-build displayName: Install coreutils and ninja @@ -141,14 +146,6 @@ stages: env | grep ANDROID displayName: View Android ENVs - # Start switching to jdk 11 after the Android Emulator is started since Android SDK manager requires java 8 - - task: JavaToolInstaller@0 - displayName: Use jdk 11 - inputs: - versionSpec: '11' - jdkArchitectureOption: 'x64' - jdkSourceOption: 'PreInstalled' - - script: | python3 tools/ci_build/build.py \ --android \ @@ -229,6 +226,13 @@ stages: inputs: versionSpec: $(pythonVersion) + - task: JavaToolInstaller@0 + displayName: Use jdk 11 + inputs: + versionSpec: '11' + jdkArchitectureOption: 'x64' + jdkSourceOption: 'PreInstalled' + - template: "templates/use-android-ndk.yml" - script: /bin/bash tools/ci_build/github/android/setup_gradle_wrapper.sh $(pwd) @@ -242,15 +246,6 @@ stages: --emulator-pid-file $(Build.BinariesDirectory)/emulator.pid displayName: Start Android emulator - # Start switching to jdk 11 after the Android Emulator is started - # since Android SDK manager requires java 8 - - task: JavaToolInstaller@0 - displayName: Use jdk 11 - inputs: - versionSpec: '11' - jdkArchitectureOption: 'x64' - jdkSourceOption: 'PreInstalled' - - script: | python3 tools/ci_build/build.py \ --android \ @@ -304,6 +299,13 @@ stages: inputs: versionSpec: $(pythonVersion) + - task: JavaToolInstaller@0 + displayName: Use jdk 11 + inputs: + versionSpec: '11' + jdkArchitectureOption: 'x64' + jdkSourceOption: 'PreInstalled' + - template: "templates/use-android-ndk.yml" - script: /bin/bash tools/ci_build/github/android/setup_gradle_wrapper.sh $(pwd) @@ -317,15 +319,6 @@ stages: --emulator-pid-file $(Build.BinariesDirectory)/emulator.pid displayName: Start Android emulator - # Start switching to jdk 11 after the Android Emulator is started - # since Android SDK manager requires java 8 - - task: JavaToolInstaller@0 - displayName: Use jdk 11 - inputs: - versionSpec: '11' - jdkArchitectureOption: 'x64' - jdkSourceOption: 'PreInstalled' - - script: | python3 tools/ci_build/build.py \ --android \ @@ -389,6 +382,13 @@ stages: inputs: versionSpec: $(pythonVersion) + - task: JavaToolInstaller@0 + displayName: Use jdk 11 + inputs: + versionSpec: '11' + jdkArchitectureOption: 'x64' + jdkSourceOption: 'PreInstalled' + - template: "templates/use-android-ndk.yml" - script: /bin/bash tools/ci_build/github/android/setup_gradle_wrapper.sh $(pwd) @@ -414,15 +414,6 @@ stages: --emulator-pid-file $(Build.BinariesDirectory)/emulator.pid displayName: Start Android emulator - # Start switching to jdk 11 after the Android Emulator is started - # since Android SDK manager requires java 8 - - task: JavaToolInstaller@0 - displayName: Use jdk 11 - inputs: - versionSpec: '11' - jdkArchitectureOption: 'x64' - jdkSourceOption: 'PreInstalled' - - script: | python3 tools/ci_build/build.py \ --android \ diff --git a/tools/python/util/android/android.py b/tools/python/util/android/android.py index 75d0f9cc5e..06922ed1df 100644 --- a/tools/python/util/android/android.py +++ b/tools/python/util/android/android.py @@ -35,18 +35,17 @@ def get_sdk_tool_paths(sdk_root: str): path = os.path.realpath(path) _log.debug("Found {} at {}".format(basename, path)) return path - _log.warning("Failed to resolve path for {}".format(basename)) - return None + raise FileNotFoundError("Failed to resolve path for {}".format(basename)) return SdkToolPaths( emulator=resolve_path([os.path.join(sdk_root, "emulator")], filename("emulator", "exe")), adb=resolve_path([os.path.join(sdk_root, "platform-tools")], filename("adb", "exe")), sdkmanager=resolve_path( - [os.path.join(sdk_root, "tools", "bin"), os.path.join(sdk_root, "cmdline-tools", "tools", "bin")], + [os.path.join(sdk_root, "cmdline-tools", "latest", "bin")], filename("sdkmanager", "bat"), ), avdmanager=resolve_path( - [os.path.join(sdk_root, "tools", "bin"), os.path.join(sdk_root, "cmdline-tools", "tools", "bin")], + [os.path.join(sdk_root, "cmdline-tools", "latest", "bin")], filename("avdmanager", "bat"), ), )