Skip to content

Commit 66ecb57

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 66ecb57

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
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-android-tests.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ if [[ "${GITHUB_ACTIONS}" == "true" ]]; then
66
sh ./setup-android-emulator.sh
77
fi
88

9-
./start-android-emulator.sh
9+
eval "$(./start-android-emulator.sh | grep '^ADB_DEVICE=')"
1010

1111
cleanup() {
1212
echo "Shutting down Android emulator via adb"
13-
adb_device=emulator-$((27000 + $(id -u)))
14-
$ANDROID_HOME/platform-tools/adb -s $adb_device emu kill
13+
$ANDROID_HOME/platform-tools/adb -s "$ADB_DEVICE" emu kill
1514
}
1615

1716
trap cleanup EXIT

scripts/run-interop-test.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ cleanup() {
1414
fi
1515

1616
echo "Shutting down Android emulator via adb"
17-
adb_device=emulator-$((27000 + $(id -u)))
18-
adb -s $adb_device emu kill
17+
adb -s $ADB_DEVICE emu kill
1918
}
2019

2120
trap cleanup EXIT
@@ -37,7 +36,7 @@ if [ "$OS" = "Darwin" ]; then
3736
cd $scripts
3837
fi
3938

40-
./start-android-emulator.sh
39+
eval "$(./start-android-emulator.sh | grep '^ADB_DEVICE=')"
4140

4241
cd ../interop/src/clients
4342

scripts/start-android-emulator.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,5 @@ until adb -s $ADB_DEVICE shell getprop sys.boot_completed | grep -qm 1 '1'; do
5656
done
5757

5858
echo "Emulator started. PID: $EMULATOR_PID"
59+
60+
echo "ADB_DEVICE=$ADB_DEVICE"

0 commit comments

Comments
 (0)