Free OrtStatus in ASSERT_ORT_STATUS_OK, make run_android_emulator.py work with newer JDK version (#14369)

- Free OrtStatus in ASSERT_ORT_STATUS_OK in model_tests.cc
- Make run_android_emulator.py work with newer JDK version
This commit is contained in:
Edward Chen 2023-01-20 09:27:47 -08:00 committed by GitHub
parent 22fdc31667
commit 3b382ea7e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 52 deletions

View file

@ -48,10 +48,15 @@
extern std::unique_ptr<Ort::Env> 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<OrtStatus, decltype(&OrtApis::ReleaseStatus)> _rel_status{ \
_status, &OrtApis::ReleaseStatus}; \
FAIL() << "OrtStatus error: " << OrtApis::GetErrorMessage(_rel_status.get()); \
} \
} while (false)
using namespace onnxruntime::common;

View file

@ -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 \

View file

@ -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"),
),
)