Skip to content

Commit c487ae5

Browse files
Add script for building test framework artifacts
Pass `TEST_MANAGER_STATIC` when building the `test-manager` crate to have it link statically against `libpcap`. This is optional, but building the with the provided container will produce a statically linked binary.
1 parent ce5b989 commit c487ae5

File tree

5 files changed

+62
-3
lines changed

5 files changed

+62
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/target/
22
/build/
33
/dist
4+
/test/dist
45
.idea/
56
.DS_Store
67
*.log

test/scripts/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ FROM $IMAGE
33

44
ENV OPENSSL_STATIC=1 \
55
OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu \
6-
OPENSSL_INCLUDE_DIR=/usr/include/openssl
6+
OPENSSL_INCLUDE_DIR=/usr/include/openssl \
7+
TEST_MANAGER_STATIC=1
78

89
RUN rustup target add x86_64-pc-windows-gnu
910

test/scripts/build-manager.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
# Build `test-manager`
6+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7+
TEST_FRAMEWORK_ROOT="$SCRIPT_DIR/.."
8+
REPO_DIR="$TEST_FRAMEWORK_ROOT/.."
9+
10+
# shellcheck disable=SC1091
11+
source "$REPO_DIR/scripts/utils/log"
12+
13+
build_linux() {
14+
cd "$TEST_FRAMEWORK_ROOT"
15+
# Build the test manager
16+
cargo build -p test-manager --release
17+
}
18+
19+
case ${1-:""} in
20+
linux)
21+
build_linux
22+
shift
23+
;;
24+
*)
25+
log_error "Invalid platform. Specify a valid platform as first argument"
26+
exit 1
27+
esac

test/scripts/build.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
# Build distributable binaries for the test framework.
6+
# TODO: Support macOS
7+
8+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
9+
TEST_FRAMEWORK_ROOT="$SCRIPT_DIR/.."
10+
11+
# Build
12+
build_linux() {
13+
mkdir -p "$TEST_FRAMEWORK_ROOT/dist"
14+
# Build the test manager
15+
"$SCRIPT_DIR/build-manager.sh" linux
16+
cp "$TEST_FRAMEWORK_ROOT/target/release/test-manager" "$TEST_FRAMEWORK_ROOT/dist/"
17+
18+
# Build the test runner
19+
"$SCRIPT_DIR/build-runner.sh" linux
20+
cp "$TEST_FRAMEWORK_ROOT/target/x86_64-unknown-linux-gnu/release/test-runner" "$TEST_FRAMEWORK_ROOT/dist/"
21+
cp "$TEST_FRAMEWORK_ROOT/target/x86_64-unknown-linux-gnu/release/connection-checker" "$TEST_FRAMEWORK_ROOT/dist/"
22+
}
23+
24+
build_linux

test/test-manager/build.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
use std::env::var;
2+
13
fn main() {
24
// Rebuild if SSH provision script changes
35
println!("cargo::rerun-if-changed=../scripts/ssh-setup.sh");
46

5-
println!("cargo::rustc-link-search=native=/usr/lib/x86_64-linux-gnu");
6-
println!("cargo::rustc-link-lib=static=pcap");
7+
let link_statically = var("TEST_MANAGER_STATIC").is_ok_and(|x| x != "0");
8+
9+
if link_statically {
10+
println!("cargo::rustc-link-search=native=/usr/lib/x86_64-linux-gnu");
11+
println!("cargo::rustc-link-lib=static=pcap");
12+
}
713
}

0 commit comments

Comments
 (0)