Skip to content

Build test-manager as a standalone executable #6615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/target/
/build/
/dist
/test/dist
.idea/
.DS_Store
*.log
Expand Down
19 changes: 18 additions & 1 deletion test/scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
ARG IMAGE=ghcr.io/mullvad/mullvadvpn-app-build:latest
FROM $IMAGE

ENV OPENSSL_STATIC=1 \
OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu \
OPENSSL_INCLUDE_DIR=/usr/include/openssl \
TEST_MANAGER_STATIC=1

RUN rustup target add x86_64-pc-windows-gnu

RUN apt-get update && apt-get install -y \
mtools pkg-config libssl-dev libpcap-dev
mtools pkg-config libssl-dev

RUN git clone https://github.com/the-tcpdump-group/libpcap.git
RUN apt-get install -y autoconf flex bison

RUN cd libpcap \
&& ./autogen.sh \
&& ./configure --enable-remote=yes --enable-dbus=no --enable-shared=no \
&& make \
&& make install

RUN rm -rf libpcap
RUN apt-get remove -y autoconf flex bison
27 changes: 27 additions & 0 deletions test/scripts/build-manager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -eu

# Build `test-manager`
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TEST_FRAMEWORK_ROOT="$SCRIPT_DIR/.."
REPO_DIR="$TEST_FRAMEWORK_ROOT/.."

# shellcheck disable=SC1091
source "$REPO_DIR/scripts/utils/log"

build_linux() {
cd "$TEST_FRAMEWORK_ROOT"
# Build the test manager
cargo build -p test-manager --release
}

case ${1-:""} in
linux)
build_linux
shift
;;
*)
log_error "Invalid platform. Specify a valid platform as first argument"
exit 1
esac
24 changes: 24 additions & 0 deletions test/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -eu

# Build distributable binaries for the test framework.
# TODO: Support macOS

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TEST_FRAMEWORK_ROOT="$SCRIPT_DIR/.."

# Build
build_linux() {
mkdir -p "$TEST_FRAMEWORK_ROOT/dist"
# Build the test manager
"$SCRIPT_DIR/build-manager.sh" linux
cp "$TEST_FRAMEWORK_ROOT/target/release/test-manager" "$TEST_FRAMEWORK_ROOT/dist/"

# Build the test runner
"$SCRIPT_DIR/build-runner.sh" linux
cp "$TEST_FRAMEWORK_ROOT/target/x86_64-unknown-linux-gnu/release/test-runner" "$TEST_FRAMEWORK_ROOT/dist/"
cp "$TEST_FRAMEWORK_ROOT/target/x86_64-unknown-linux-gnu/release/connection-checker" "$TEST_FRAMEWORK_ROOT/dist/"
}

build_linux
9 changes: 9 additions & 0 deletions test/test-manager/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
use std::env::var;

fn main() {
// Rebuild if SSH provision script changes
println!("cargo::rerun-if-changed=../scripts/ssh-setup.sh");

let link_statically = var("TEST_MANAGER_STATIC").is_ok_and(|x| x != "0");

if link_statically {
println!("cargo::rustc-link-search=native=/usr/lib/x86_64-linux-gnu");
println!("cargo::rustc-link-lib=static=pcap");
}
}
Loading