Skip to content

Commit 6d5358e

Browse files
committed
update tests: set x86_64 as default architecture in Android setup and emulator tests, align with config changes and validation steps
1 parent 73b6baa commit 6d5358e

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

tests/cli/test_setup_android_config.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,20 @@ class TestSetupAndroidWithConfig:
1515

1616
def test_setup_android_reads_config(self, tmp_path):
1717
"""Test that setup-android reads SDK location from config."""
18-
# Create a test config
18+
# Create a test config with x86_64 architecture
1919
config_data = {
2020
"project": {
2121
"name": "test",
2222
"run_id": "test_001",
2323
"cache_dir": str(tmp_path / "test_cache"),
2424
},
25-
"openvino": {"mode": "build"},
25+
"openvino": {
26+
"mode": "build",
27+
"toolchain": {
28+
"abi": "x86_64", # Specify architecture to match what we check
29+
"api_level": 30,
30+
},
31+
},
2632
"device": {"kind": "android", "serials": []},
2733
"models": [{"name": "model1", "path": "model1.xml"}],
2834
"report": {"sinks": [{"type": "json", "path": "results.json"}]},
@@ -34,11 +40,11 @@ def test_setup_android_reads_config(self, tmp_path):
3440

3541
with patch("ovmobilebench.android.installer.api.verify_installation") as mock_verify:
3642
with patch("ovmobilebench.android.installer.api.ensure_android_tools") as mock_ensure:
37-
# Mock verification to say everything is installed
43+
# Mock verification to say everything is installed (with x86_64)
3844
mock_verify.return_value = {
3945
"platform_tools": True,
4046
"emulator": True,
41-
"system_images": ["system-images;android-30;google_apis;arm64-v8a"],
47+
"system_images": ["system-images;android-30;google_apis;x86_64"],
4248
"ndk_versions": ["27.2.12479018"],
4349
}
4450

@@ -56,14 +62,20 @@ def test_setup_android_reads_config(self, tmp_path):
5662

5763
def test_setup_android_installs_missing_components(self, tmp_path):
5864
"""Test that setup-android installs only missing components."""
59-
# Create a test config
65+
# Create a test config with x86_64 architecture
6066
config_data = {
6167
"project": {
6268
"name": "test",
6369
"run_id": "test_001",
6470
"cache_dir": str(tmp_path / "test_cache"),
6571
},
66-
"openvino": {"mode": "build"},
72+
"openvino": {
73+
"mode": "build",
74+
"toolchain": {
75+
"abi": "x86_64",
76+
"api_level": 30,
77+
},
78+
},
6779
"device": {"kind": "android", "serials": []},
6880
"models": [{"name": "model1", "path": "model1.xml"}],
6981
"report": {"sinks": [{"type": "json", "path": "results.json"}]},
@@ -79,11 +91,16 @@ def test_setup_android_installs_missing_components(self, tmp_path):
7991
mock_verify.return_value = {
8092
"platform_tools": True,
8193
"emulator": True,
82-
"system_images": ["system-images;android-30;google_apis;arm64-v8a"],
94+
"system_images": ["system-images;android-30;google_apis;x86_64"],
8395
"ndk_versions": [], # NDK missing
8496
}
8597

86-
mock_ensure.return_value = MagicMock(returncode=0)
98+
mock_ensure.return_value = {
99+
"sdk_root": str(tmp_path / "test_cache" / "android-sdk"),
100+
"ndk_path": str(
101+
tmp_path / "test_cache" / "android-sdk" / "ndk" / "27.2.12479018"
102+
),
103+
}
87104

88105
result = runner.invoke(
89106
app,

tests/helpers/test_emulator_helper.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,14 @@ def test_wait_for_boot_success(self):
151151
with patch("pathlib.Path.exists", return_value=True):
152152
# Mock subprocess.run to simulate successful boot
153153
with patch("subprocess.run") as mock_run:
154-
# First call: wait-for-device succeeds
155-
# Second call: getprop returns "1" (booted)
154+
# Our new implementation makes these calls:
155+
# 1. adb devices (initial check)
156+
# 2. adb wait-for-device
157+
# 3. adb shell getprop sys.boot_completed
156158
mock_run.side_effect = [
159+
Mock(
160+
returncode=0, stdout="List of devices attached\nemulator-5554\tdevice\n"
161+
), # adb devices
157162
Mock(returncode=0), # wait-for-device
158163
Mock(returncode=0, stdout="1\n"), # getprop sys.boot_completed
159164
]
@@ -162,8 +167,8 @@ def test_wait_for_boot_success(self):
162167
result = wait_for_boot(timeout=10)
163168

164169
assert result is True
165-
# Should have called adb at least twice
166-
assert mock_run.call_count >= 2
170+
# Should have called adb at least 3 times
171+
assert mock_run.call_count >= 3
167172

168173
def test_wait_for_boot_timeout(self):
169174
"""Test emulator boot timeout."""

0 commit comments

Comments
 (0)