Skip to content

Commit 542eacc

Browse files
authored
tests: add script to verify static libraries (#237)
This is an subtle way for things to break, it's easy to accidentally break it, and the check for it is not _that_ complicated, so we can automate it. Move both test scripts into the tests directory and invoke them from there.
1 parent 7043fa0 commit 542eacc

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ endif
2222

2323
all: target/client target/server
2424

25-
test: all
25+
test: all test-rust
26+
./tests/verify-static-libraries.sh
27+
./tests/client-server.sh
28+
29+
test-rust:
2630
cargo test
27-
./test.sh
2831

2932
target:
3033
mkdir -p $@
File renamed without changes.

tests/verify-static-libraries.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
main() {
6+
local -r uname=$(uname)
7+
local want;
8+
# If you need to change the values here, be sure to update the values in the
9+
# README. Alternatively, it is possible that adding new libraries to link
10+
# against was a mistake that should be reverted or worked around.
11+
if [[ "${uname}" == 'Darwin' ]]; then
12+
want='-framework Security -liconv -lSystem -lresolv -lc -lm -liconv'
13+
elif [[ "${uname}" == 'Linux' ]]; then
14+
want='-lgcc_s -lutil -lrt -lpthread -lm -ldl -lc'
15+
else
16+
# TODO
17+
want=''
18+
fi
19+
# unfortunately --print native-static-libs does not yield the
20+
# information in a machine consumable format, so we need to pull it
21+
# out of stderr.
22+
# https://users.rust-lang.org/t/print-native-static-libs/14102/14
23+
if ! RUSTFLAGS="--print native-static-libs" cargo build 2>&1 >/dev/null | grep -q -F -x "note: native-static-libs: ${want}"; then
24+
echo "got unexpected list of static libraries, fix or update README: ${want}"
25+
exit 1
26+
fi
27+
}
28+
29+
main "$@"

0 commit comments

Comments
 (0)