-
-
Notifications
You must be signed in to change notification settings - Fork 91
chore: Refactor test.sh
#165
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
Conversation
Effectively the same, except `docker_build` now uses `ldd` in the container instead of `file`, like the other tests as the QEMU bug has been resolved since Aug 2023 (QEMU 8.1.0).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth noting, this PR makes the need for Dockerfile.test-runner
redundant.
You could just run ubuntu:noble
and use ldd
from there. Assuming the rustmusl-temp
built image is not used to verify in a different environment.
😅 i am (occasionally) testing arm on a mac, getting some issues there; $ just test
just _t_macos_aarch64 plain
+ CRATE_NAME=plaincrate
+ CRATE_PATH=./test/plaincrate
+ docker_build
+ echo 'Target dir: aarch64-unknown-linux-musl'
Target dir: aarch64-unknown-linux-musl
+ echo 'Platform: linux/arm64'
Platform: linux/arm64
+ docker run --rm -it --env RUST_BACKTRACE=1 --volume ./test/plaincrate:/volume --volume cargo-cache:/opt/cargo/registry --platform linux/arm64 rustmusl-temp cargo build
compile log
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.08s
+ local CRATE_ARTIFACT=./target/aarch64-unknown-linux-musl/debug/plaincrate
+ docker run --rm -it --env RUST_BACKTRACE=1 --volume ./test/plaincrate:/volume --workdir /volume --platform linux/arm64 test-runner bash -ex -o pipefail -c '
'\''./target/aarch64-unknown-linux-musl/debug/plaincrate'\''
ldd '\''./target/aarch64-unknown-linux-musl/debug/plaincrate'\'' 2>&1 | grep -qE '\''not a dynamic|statically linked'\'' && echo '\'' is a static executable'\''
'
+ ./target/aarch64-unknown-linux-musl/debug/plaincrate
Hello, visitor number 3469763539
+ ldd ./target/aarch64-unknown-linux-musl/debug/plaincrate
+ grep -qE 'not a dynamic|statically linked'
error: Recipe `_t_macos_aarch64` failed with exit code 1
error: Recipe `_ti` failed on line 32 with exit code 1 EDIT: dumping + ldd ./target/aarch64-unknown-linux-musl/debug/plaincrate
not a dynamic executable EDIT2; it's the pipefail option. updated and referenced in comment. |
UPDATE: Ah, great :) I guess that's one of those features that don't work well with the standard bash provided by macOS. It should work fine in the container usage though: $ docker run --rm -it localhost/example-openssl bash -ex -o pipefail -c "
target/x86_64-unknown-linux-musl/release/example
ldd target/x86_64-unknown-linux-musl/release/example 2>&1 \
| grep -qE 'not a dynamic|statically linked' \
&& echo 'is a static executable'
"
+ target/x86_64-unknown-linux-musl/release/example
OpenSSL version is: OpenSSL 3.5.0 8 Apr 2025
+ ldd target/x86_64-unknown-linux-musl/release/example
+ grep -qE 'not a dynamic|statically linked'
I don't have access to a mac, but presumably either:
$ docker run --rm --platform "linux/arm64" ubuntu:noble /lib/ld-linux-aarch64.so.1 --list /usr/bin/bash
(0x0000400000810000)
libtinfo.so.6 => /lib/aarch64-linux-gnu/libtinfo.so.6 (0x00004000009b0000)
libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000400000a00000)
/lib/ld-linux-aarch64.so.1 (0x00007f9351ac9000)
# AMD64 has a different filename and location:
$ docker run --rm --platform "linux/amd64" ubuntu:noble /lib64/ld-linux-x86-64.so.2 --list /usr/bin/bash
linux-vdso.so.1 (0x00007ffe99359000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007ff57385a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff573648000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff5739fe000)
# Alternatively:
$ docker run --rm --platform "linux/amd64" ubuntu:noble /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 --list /usr/bin/bash
linux-vdso.so.1 (0x00007fff81d16000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007ff8c1d03000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff8c1af1000)
/lib64/ld-linux-x86-64.so.2 => /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 (0x00007ff8c1ea7000) If you can't run that successfully on macOS and you have the latest Docker Desktop, then I'm not sure what else you can do 😅
$ patchelf --print-interpreter target/x86_64-unknown-linux-musl/release/example
patchelf: cannot find section '.interp'. The input file is most likely statically linked
$ patchelf --print-interpreter /usr/bin/bash
/lib64/ld-linux-x86-64.so.2 |
Thanks for the investigation, tried a little more. I am unfortunately pretty up to date with docker desktop and bash. I wouldn't have expected bash to matter in the container (but old bash is definitely a thing elsewhere yeah). It is possible that the test container behaves differently on mac and has different features of packages compiled there, but can't think of where to go investigating this. At any rate, I'm just going to merge and remove the |
for #165 Signed-off-by: clux <[email protected]>
for #165 Signed-off-by: clux <[email protected]>
I intended this to be a bit smaller but figured I might as well tidy up the whole file while I'm at it.
Despite the large diff, it should function effectively the same, except
docker_build
now usesldd
in the container instead offile
, like the other tests as the QEMU bug has been resolved since Aug 2023 (QEMU 8.1.0).I normalized some of the script for consistency:
check_crate_build_locally()
.-r
assigned to thecrate
var (nowCRATE_NAME
) seemed unnecessary. The variable was hoisted out of the functions, thus they can't be prefixedlocal
(given it's a small script this seems fine).file
forldd
, and I adjusted the command to a multi-line string input, similar to HereDoc usage inDockerfile
it is like an inline shell script 👍 (easier to grok).--workdir
so no need tocd
in the command given.x86_64
target locally is now formatted the same way but differs in path checked so I added aCRATE_ARTIFACT
variable 😅When multi-arch / ARM64 image support was added to the project, there was this PR comment added about an
ldd
bug when relying on QEMU:muslrust/test.sh
Lines 20 to 29 in 6b436d1
Doesn't appear to be a problem since QEMU 8.1.0 (released Aug 2023)?: multiarch/qemu-user-static#172 (comment)