Skip to content

Commit

Permalink
ci: add workflow for rust bench crate (#4210)
Browse files Browse the repository at this point in the history
The bench crate contains interop testing that would be useful to have in
our ci runs. This commit adds a github workflow to run that. It also
adds an options to generate the bindings without running the tests,
since the tests take several minutes to run.
  • Loading branch information
jmayclin authored Dec 7, 2023
1 parent c849c54 commit d6d06bf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@ jobs:
./generate.sh
ldd target/debug/integration | grep libs2n.so
# our benchmark testing includes interop tests between s2n-tls, rustls, and
# openssl
harness-interop-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions-rs/toolchain@v1
id: toolchain
with:
toolchain: stable
override: true

- name: generate bindings
run: ${{env.ROOT_PATH}}/generate.sh --skip-tests

- name: generate test certs
run: ${{env.ROOT_PATH}}/bench/scripts/generate-certs.sh

- name: bench tests
working-directory: ${{env.ROOT_PATH}}/bench
run: cargo test

generate-openssl-102:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions bindings/rust/bench/scripts/generate-certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
set -e

# go to directory certs are located
mkdir -p "$(dirname "$0")"/../certs
pushd "$(dirname "$0")"/../certs > /dev/null

# Generates certs with given algorithms and bits in $1$2/, ex. ec384/
Expand Down
6 changes: 3 additions & 3 deletions bindings/rust/bench/src/s2n_tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ use std::{

/// Custom callback for verifying hostnames. Rustls requires checking hostnames,
/// so this is to make a fair comparison
struct HostNameHandler<'a> {
expected_server_name: &'a str,
struct HostNameHandler {
expected_server_name: &'static str,
}
impl VerifyHostNameCallback for HostNameHandler<'_> {
impl VerifyHostNameCallback for HostNameHandler {
fn verify_host_name(&self, hostname: &str) -> bool {
self.expected_server_name == hostname
}
Expand Down
5 changes: 5 additions & 0 deletions bindings/rust/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ pushd generate
cargo run -- ../s2n-tls-sys
popd

if [ "$1" == "--skip-tests" ]; then
echo "skipping tests"
exit;
fi;

# make sure everything builds and passes sanity checks
pushd s2n-tls-sys
cargo test
Expand Down

0 comments on commit d6d06bf

Please sign in to comment.