Skip to content

Commit

Permalink
ci: run on Android API Level 25
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden authored and djc committed Dec 17, 2024
1 parent cb0b59d commit a83c6e4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust-android-run-tests-on-emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ any_failures=0
for test in $(find target/$TARGET/debug/deps/ -type f -executable ! -name "*.so" -name "*-*"); do
adb push "$test" /data/local/tmp/
adb shell chmod +x /data/local/tmp/$(basename "$test")
adb shell /data/local/tmp/$(basename "$test") || any_failures=1
adb shell API_LEVEL=$API_LEVEL /data/local/tmp/$(basename "$test") || any_failures=1
done

exit $any_failures
16 changes: 9 additions & 7 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,19 @@ jobs:

strategy:
matrix:
include:
target: [x86_64-linux-android, i686-linux-android]
emulator-arch: [x86_64, x86]
api-level: [26, 25]
exclude:
- target: x86_64-linux-android
emulator-arch: x86_64
# Note that x86_64 image is only available for API 21+. See
# https://github.com/ReactiveCircus/android-emulator-runner?tab=readme-ov-file#configurations.
api-level: 26
- target: i686-linux-android
emulator-arch: x86
api-level: 26
- target: i686-linux-android
emulator-arch: x86_64

steps:
- name: Set API level environment variable
run: echo "API_LEVEL=${{ matrix.api-level }}" >> $GITHUB_ENV

- name: Checkout code
uses: actions/checkout@v4

Expand Down
4 changes: 2 additions & 2 deletions quinn-udp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ pub struct RecvMeta {
pub ecn: Option<EcnCodepoint>,
/// The destination IP address which was encoded in this datagram
///
/// Populated on platforms: Windows, Linux, Android, FreeBSD, OpenBSD, NetBSD, macOS,
/// and iOS.
/// Populated on platforms: Windows, Linux, Android (API level > 25),
/// FreeBSD, OpenBSD, NetBSD, macOS, and iOS.
pub dst_ip: Option<IpAddr>,
}

Expand Down
27 changes: 23 additions & 4 deletions quinn-udp/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,12 @@ fn test_send_recv(send: &Socket, recv: &Socket, transmit: Transmit) {
);
let send_v6 = send.local_addr().unwrap().as_socket().unwrap().is_ipv6();
let recv_v6 = recv.local_addr().unwrap().as_socket().unwrap().is_ipv6();
let src = meta.addr.ip();
let dst = meta.dst_ip.unwrap();
for addr in [src, dst] {
let mut addresses = vec![meta.addr.ip()];
// Not populated on every OS. See `RecvMeta::dst_ip` for details.
if let Some(addr) = meta.dst_ip {
addresses.push(addr);
}
for addr in addresses {
match (send_v6, recv_v6) {
(_, false) => assert_eq!(addr, Ipv4Addr::LOCALHOST),
// Windows gives us real IPv4 addrs, whereas *nix use IPv6-mapped IPv4
Expand All @@ -240,7 +243,23 @@ fn test_send_recv(send: &Socket, recv: &Socket, transmit: Transmit) {
),
}
}
assert_eq!(meta.ecn, transmit.ecn);

if match transmit.destination.ip() {
IpAddr::V4(_) => true,
IpAddr::V6(a) => a.to_ipv4_mapped().is_some(),
} && cfg!(target_os = "android")
&& std::env::var("API_LEVEL")
.ok()
.and_then(|v| v.parse::<u32>().ok())
.expect("API_LEVEL environment variable to be set on Android")
<= 25
{
// On Android API level <= 25 the IPv4 `IP_TOS` control message is
// not supported and thus ECN bits can not be received.
assert_eq!(meta.ecn, None);
} else {
assert_eq!(meta.ecn, transmit.ecn);
}
}
assert_eq!(datagrams, expected_datagrams);
}
Expand Down

0 comments on commit a83c6e4

Please sign in to comment.