Skip to content

Commit b1c4178

Browse files
saleemrashidemilio
authored andcommitted
Run tests on AArch64 using Debian multiarch and QEMU
1 parent 704c02b commit b1c4178

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

.github/workflows/bindgen.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ jobs:
8989
strategy:
9090
matrix:
9191
os: [ubuntu-latest]
92+
target:
93+
- debian: null
94+
cross: null
95+
rust: null
9296
llvm_version: ["3.9", "4.0", "5.0", "9.0"]
97+
main_tests: [1]
9398
release_build: [0, 1]
9499
no_default_features: [0, 1]
95100
# FIXME: There are no pre-built static libclang libraries, so the
@@ -121,6 +126,17 @@ jobs:
121126
feature_extra_asserts: 1
122127
feature_testing_only_docs: 1
123128

129+
- os: ubuntu-latest
130+
target:
131+
debian: arm64
132+
cross: aarch64-linux-gnu
133+
rust: aarch64-unknown-linux-gnu
134+
llvm_version: "9.0"
135+
main_tests: 0
136+
release_build: 0
137+
feature_extra_asserts: 0
138+
feature_testing_only_docs: 0
139+
124140
# Ensure stuff works on macos too
125141
- os: macos-latest
126142
llvm_version: "9.0"
@@ -131,17 +147,36 @@ jobs:
131147
steps:
132148
- uses: actions/checkout@v2
133149

150+
- name: Install multiarch packages
151+
if: matrix.target.debian
152+
run: |
153+
sudo apt-get install binfmt-support qemu-user-static gcc-${{matrix.target.cross}} g++-${{matrix.target.cross}}
154+
source /etc/lsb-release
155+
sudo tee /etc/apt/sources.list <<EOF >/dev/null
156+
deb [arch=${{matrix.target.debian}}] http://ports.ubuntu.com/ubuntu-ports/ $DISTRIB_CODENAME main
157+
deb [arch=${{matrix.target.debian}}] http://ports.ubuntu.com/ubuntu-ports/ $DISTRIB_CODENAME-updates main
158+
deb [arch=${{matrix.target.debian}}] http://ports.ubuntu.com/ubuntu-ports/ $DISTRIB_CODENAME-backports main
159+
deb [arch=${{matrix.target.debian}}] http://ports.ubuntu.com/ubuntu-ports/ $DISTRIB_CODENAME-security main
160+
EOF
161+
sudo dpkg --add-architecture ${{matrix.target.debian}}
162+
sudo apt-get update
163+
sudo apt-get install libc6:${{matrix.target.debian}} libstdc++6:${{matrix.target.debian}}
164+
134165
- name: Install stable
135166
uses: actions-rs/toolchain@v1
136167
with:
137168
profile: minimal
138169
toolchain: stable
170+
target: ${{matrix.target.rust}}
139171
override: true
140172

141173
- name: Run all the tests
142174
env:
143175
GITHUB_ACTIONS_OS: ${{matrix.os}}
176+
RUST_CROSS_COMPILER: ${{matrix.target.cross}}
177+
RUST_TARGET: ${{matrix.target.rust}}
144178
LLVM_VERSION: ${{matrix.llvm_version}}
179+
BINDGEN_MAIN_TESTS: ${{matrix.main_tests}}
145180
BINDGEN_RELEASE_BUILD: ${{matrix.release_build}}
146181
BINDGEN_FEATURE_RUNTIME: ${{matrix.feature_runtime}}
147182
BINDGEN_FEATURE_EXTRA_ASSERTS: ${{matrix.feature_extra_asserts}}

ci/test.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ set_rustfmt_env
9494

9595
get_cargo_args() {
9696
local args=""
97+
if [ ! -z "$RUST_TARGET" ]; then
98+
args+=" --target $RUST_TARGET"
99+
fi
97100
if [ "$BINDGEN_RELEASE_BUILD" == "1" ]; then
98101
args+=" --release"
99102
fi
@@ -116,13 +119,19 @@ get_cargo_args() {
116119
echo $args
117120
}
118121

122+
if [ ! -z "$RUST_CROSS_COMPILER" ]; then
123+
export RUSTFLAGS="-C linker=${RUST_CROSS_COMPILER}-gcc"
124+
fi
125+
119126
CARGO_ARGS=`get_cargo_args`
120127

121128
# Ensure we build without warnings
122129
cargo rustc --lib $CARGO_ARGS -- -Dwarnings
123130

124-
# Run the tests
125-
cargo test $CARGO_ARGS
131+
if [ "$BINDGEN_MAIN_TESTS" == "1" ]; then
132+
# Run the tests
133+
cargo test $CARGO_ARGS
134+
fi
126135

127136
assert_no_diff
128137

0 commit comments

Comments
 (0)