Skip to content

Commit a112526

Browse files
committed
testing suits for iOS
1 parent a0e6f18 commit a112526

File tree

6 files changed

+45
-7
lines changed

6 files changed

+45
-7
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,25 @@ jobs:
5555
path: target
5656
key: target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
5757
- run: cargo test --features vendored
58-
- run: cargo test --features vendored
58+
59+
build_n_test_ios:
60+
strategy:
61+
fail-fast: false
62+
runs-on: macos-latest
63+
steps:
64+
- uses: actions/checkout@v4
65+
- name: Install cargo lipo and rust compiler for ios target
66+
if: ${{ !cancelled() }}
67+
run: |
68+
cargo install --locked cargo-lipo
69+
rustup target add x86_64-apple-ios aarch64-apple-ios
70+
- name: clippy
71+
if: ${{ !cancelled() }}
72+
run: cargo clippy --target x86_64-apple-ios --all-features -- -D warnings
73+
- name: Build
74+
if: ${{ !cancelled() }}
75+
run: |
76+
cargo lipo --verbose --all-features
77+
- name: Abort on error
78+
if: ${{ failure() }}
79+
run: echo "iOS build job failed" && false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.VSCodeCounter/
12
target
23
Cargo.lock
34
.idea

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ rust-version = "1.53.0"
1212
features = ["alpn"]
1313
rustdoc-args = ["--cfg", "docsrs"]
1414

15+
[lib]
16+
crate-type = ["staticlib", "rlib"]
17+
1518
[features]
1619
vendored = ["openssl/vendored"]
1720
alpn = ["security-framework/alpn"]

src/imp/openssl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::fmt;
1616
use std::io;
1717
use std::sync::Once;
1818

19-
use {Protocol, TlsAcceptorBuilder, TlsConnectorBuilder};
19+
use crate::{Protocol, TlsAcceptorBuilder, TlsConnectorBuilder};
2020

2121
#[cfg(have_min_max_version)]
2222
fn supported_protocols(

src/imp/security_framework.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use std::error;
1515
use std::fmt;
1616
use std::io;
1717
use std::str;
18-
use std::sync::Mutex;
1918
use std::sync::Once;
2019

2120
#[cfg(not(any(
@@ -58,6 +57,7 @@ use self::security_framework::os::macos::keychain::{self, KeychainSettings, SecK
5857

5958
use {Protocol, TlsAcceptorBuilder, TlsConnectorBuilder};
6059

60+
#[allow(dead_code)]
6161
static SET_AT_EXIT: Once = Once::new();
6262

6363
#[cfg(not(any(
@@ -66,7 +66,8 @@ static SET_AT_EXIT: Once = Once::new();
6666
target_os = "tvos",
6767
target_os = "visionos"
6868
)))]
69-
static TEMP_KEYCHAIN: Mutex<Option<(SecKeychain, tempfile::TempDir)>> = Mutex::new(None);
69+
static TEMP_KEYCHAIN: std::sync::Mutex<Option<(SecKeychain, tempfile::TempDir)>> =
70+
std::sync::Mutex::new(None);
7071

7172
fn convert_protocol(protocol: Protocol) -> SslProtocol {
7273
match protocol {
@@ -233,6 +234,7 @@ impl Identity {
233234
}
234235
}
235236

237+
#[allow(dead_code)]
236238
fn random_password() -> Result<String, Error> {
237239
use std::fmt::Write;
238240
let mut bytes = [0_u8; 10];
@@ -479,6 +481,7 @@ impl TlsAcceptor {
479481

480482
pub struct TlsStream<S> {
481483
stream: secure_transport::SslStream<S>,
484+
#[allow(dead_code)]
482485
cert: Option<SecCertificate>,
483486
}
484487

@@ -641,6 +644,7 @@ impl<S: io::Read + io::Write> io::Write for TlsStream<S> {
641644
}
642645
}
643646

647+
#[allow(dead_code)]
644648
enum Digest {
645649
Sha224,
646650
Sha256,
@@ -649,9 +653,10 @@ enum Digest {
649653
}
650654

651655
impl Digest {
656+
#[allow(dead_code)]
652657
fn hash(&self, data: &[u8]) -> Vec<u8> {
653658
unsafe {
654-
assert!(data.len() <= CC_LONG::max_value() as usize);
659+
assert!(data.len() <= CC_LONG::MAX as usize);
655660
match *self {
656661
Digest::Sha224 => {
657662
let mut buf = [0; CC_SHA224_DIGEST_LENGTH];
@@ -679,16 +684,24 @@ impl Digest {
679684
}
680685

681686
// FIXME ideally we'd pull these in from elsewhere
687+
#[allow(dead_code)]
682688
const CC_SHA224_DIGEST_LENGTH: usize = 28;
689+
#[allow(dead_code)]
683690
const CC_SHA256_DIGEST_LENGTH: usize = 32;
691+
#[allow(dead_code)]
684692
const CC_SHA384_DIGEST_LENGTH: usize = 48;
693+
#[allow(dead_code)]
685694
const CC_SHA512_DIGEST_LENGTH: usize = 64;
686-
#[allow(non_camel_case_types)]
695+
#[allow(non_camel_case_types, dead_code)]
687696
type CC_LONG = u32;
688697

689698
extern "C" {
699+
#[allow(dead_code)]
690700
fn CC_SHA224(data: *const u8, len: CC_LONG, md: *mut u8) -> *mut u8;
701+
#[allow(dead_code)]
691702
fn CC_SHA256(data: *const u8, len: CC_LONG, md: *mut u8) -> *mut u8;
703+
#[allow(dead_code)]
692704
fn CC_SHA384(data: *const u8, len: CC_LONG, md: *mut u8) -> *mut u8;
705+
#[allow(dead_code)]
693706
fn CC_SHA512(data: *const u8, len: CC_LONG, md: *mut u8) -> *mut u8;
694707
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ use std::result;
106106
#[cfg(not(any(target_os = "windows", target_vendor = "apple",)))]
107107
#[macro_use]
108108
extern crate log;
109-
#[cfg(any(target_vendor = "apple",))]
109+
#[cfg(target_vendor = "apple")]
110110
#[path = "imp/security_framework.rs"]
111111
mod imp;
112112
#[cfg(target_os = "windows")]

0 commit comments

Comments
 (0)