Skip to content

Commit 67a35f9

Browse files
chore: interop: allow concurrent runs on the same machine
Before we hadn't provided a concrete device name, so adb couldn't figure out which one to use in case there were multiple.
1 parent a5c1339 commit 67a35f9

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

interop/src/clients/corecrypto/android.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,10 @@ impl CoreCryptoAndroidClient {
196196
let client_id_base64 = general_purpose::STANDARD.encode(client_id_str.as_str());
197197
let ciphersuite = CIPHERSUITE_IN_USE as u16;
198198

199-
let output = Command::new("adb")
200-
.args(["get-serialno"])
201-
.output()
202-
.expect("Failed to get connected android device");
203-
204-
let device = String::from_utf8(output.stdout)
205-
.expect("output is not valid utf8")
206-
.trim()
207-
.to_string();
199+
let device = std::env::var_os("ADB_DEVICE")
200+
.expect("ADB_DEVICE must be set")
201+
.into_string()
202+
.expect("ADB_DEVICE must have valid string encoding");
208203
let driver = SimulatorDriver::new(device, "com.wire.androidinterop".into());
209204
log::info!("initialising core crypto with ciphersuite {ciphersuite}");
210205
driver

scripts/run-interop-test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ cd $scripts
55

66
TARGET_NAME=$1
77

8+
export ADB_DEVICE_PORT=$((27000 + $(id -u)))
9+
export ADB_DEVICE=emulator-$ADB_DEVICE_PORT
10+
811
OS="$(uname -s)"
912

1013
cleanup() {

scripts/start-android-emulator.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ AVD_NAME=test-phone
99
# multiple jobs running at the same time, all using the same adb server, and
1010
# therefore seeing the same emulator devices. To avoid that, just pick a port
1111
# based on current user's ID.
12-
PORT=$((27000 + $(id -u)))
13-
ADB_DEVICE=emulator-$PORT
1412

1513
# PATH updates
1614
export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$PATH
@@ -44,7 +42,7 @@ fi
4442
# not be running on our self-hosted runners.
4543
adb start-server
4644

47-
emulator -avd $AVD_NAME -port $PORT -no-window -gpu swiftshader_indirect \
45+
emulator -avd $AVD_NAME -port $ADB_DEVICE_PORT -no-window -gpu swiftshader_indirect \
4846
-no-snapshot -noaudio -no-boot-anim -no-metrics >$logfile &
4947
EMULATOR_PID=$!
5048

0 commit comments

Comments
 (0)