Browse Source

Fix up some test runner issues

Clean up dockerfile build by using devkitarm base image to get devkitpro
tools. Also upload artifacts after running, and fix some issues due to
Github Actions working slightly different than plain docker.
pull/1/head
Ian Chamberlain 1 year ago
parent
commit
780d45d4a6
No known key found for this signature in database
GPG Key ID: AE5484D09405AA60
  1. 2
      .github/actions/setup/action.yml
  2. 12
      .github/workflows/ci.yml
  3. 1
      Cargo.toml
  4. 14
      Dockerfile
  5. 34
      docker/entrypoint.sh
  6. 6
      tests/integration.rs

2
.github/actions/setup/action.yml

@ -28,6 +28,8 @@ runs:
- name: Set up Rust cache - name: Set up Rust cache
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
with:
shared-key: rust3ds
- name: Install build tools for host - name: Install build tools for host
shell: bash shell: bash

12
.github/workflows/ci.yml

@ -63,8 +63,7 @@ jobs:
run: cargo 3ds test --no-run --test integration run: cargo 3ds test --no-run --test integration
- name: Build doc tests - name: Build doc tests
# need build-std=test until https://github.com/rust3ds/cargo-3ds/pull/42 run: cargo 3ds test --no-run --doc
run: cargo 3ds test --doc -Zbuild-std=std,test
- name: Run lib + integration tests - name: Run lib + integration tests
uses: ./.github/actions/citra uses: ./.github/actions/citra
@ -74,3 +73,12 @@ jobs:
# TODO: run doc tests. We might be able to do something with e.g. # TODO: run doc tests. We might be able to do something with e.g.
# cargo's "runner" configuration, but it seems we also need a test # cargo's "runner" configuration, but it seems we also need a test
# runtime and stuff for that to work. # runtime and stuff for that to work.
- name: Upload citra logs and capture videos
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: citra-logs-${{ matrix.toolchain }}
path: |
target/armv6k-nintendo-3ds/debug/deps/*.txt
target/armv6k-nintendo-3ds/debug/deps/*.webm

1
Cargo.toml

@ -12,4 +12,3 @@ socket = []
ctru-rs = { git = "https://github.com/rust3ds/ctru-rs" } ctru-rs = { git = "https://github.com/rust3ds/ctru-rs" }
ctru-sys = { git = "https://github.com/rust3ds/ctru-rs" } ctru-sys = { git = "https://github.com/rust3ds/ctru-rs" }
libc = "0.2.147" libc = "0.2.147"
shim-3ds = { git = "https://github.com/rust3ds/shim-3ds", version = "0.1.0" }

14
Dockerfile

@ -8,16 +8,12 @@ COPY ./docker/download_citra.sh /usr/local/bin/download_citra
RUN apt-get update -y && apt-get install -y jq RUN apt-get update -y && apt-get install -y jq
RUN download_citra ${CITRA_CHANNEL} ${CITRA_RELEASE} RUN download_citra ${CITRA_CHANNEL} ${CITRA_RELEASE}
RUN wget https://apt.devkitpro.org/install-devkitpro-pacman && \ FROM devkitpro/devkitarm:latest as devkitarm
chmod +x ./install-devkitpro-pacman && \
yes | /tmp/install-devkitpro-pacman
RUN dkp-pacman -S --noconfirm \
devkitARM-gdb \
libctru
FROM ubuntu:latest FROM ubuntu:latest
RUN apt-get update -y && \ RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \
apt-get update -y && \
apt-get install -y \ apt-get install -y \
libswscale5 \ libswscale5 \
libsdl2-2.0-0 \ libsdl2-2.0-0 \
@ -25,11 +21,11 @@ RUN apt-get update -y && \
libavfilter7 \ libavfilter7 \
xvfb xvfb
COPY --from=builder /opt/devkitpro /opt/devkitpro COPY --from=devkitarm /opt/devkitpro /opt/devkitpro
ENV PATH=/opt/devkitpro/devkitARM/bin:${PATH} ENV PATH=/opt/devkitpro/devkitARM/bin:${PATH}
COPY --from=builder /tmp/citra.AppImage /usr/local/bin/citra COPY --from=builder /tmp/citra.AppImage /usr/local/bin/citra
COPY ./docker/sdl2-config.ini /root/.config/citra-emu/ COPY ./docker/sdl2-config.ini /app/
COPY ./docker/test-runner.gdb /app/ COPY ./docker/test-runner.gdb /app/
COPY ./docker/entrypoint.sh /app/ COPY ./docker/entrypoint.sh /app/

34
docker/entrypoint.sh

@ -1,26 +1,50 @@
#!/bin/bash #!/bin/bash
# Clean up child processes on exit: https://stackoverflow.com/a/2173421/14436105 # Clean up child processes on exit: https://stackoverflow.com/a/2173421/14436105
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT trap "pkill -P $$" EXIT INT TERM
ls -lart $@ mkdir -p ~/.config/citra-emu
cp /app/sdl2-config.ini ~/.config/citra-emu
# For some reason, log file is only written when this dir already exists,
# but it is only created after the first run of citra (our only run, in the container)
mkdir -p ~/.local/share/citra-emu/
ERRS=0 ERRS=0
# shellcheck disable=SC2068 # shellcheck disable=SC2068
for EXE in $@; do for EXE in $@; do
VIDEO_OUT="$(dirname "$EXE")/$(basename "$EXE" .elf)_out.webm" VIDEO_OUT="$(dirname "$EXE")/$(basename "$EXE" .elf)_capture.webm"
# colored logs would be nice, but we can always just grab the plaintext log file # colored logs would be nice, but we can always just grab the plaintext log file
xvfb-run citra --appimage-extract-and-run --dump-video="$VIDEO_OUT" "$EXE" &>/dev/null & xvfb-run citra \
--appimage-extract-and-run \
--dump-video="$VIDEO_OUT" \
"$EXE" \
&>/dev/null &
PID=$!
# Citra takes a little while to start up, so wait a little before we try to connect # Citra takes a little while to start up, so wait a little before we try to connect
sleep 3 sleep 3
arm-none-eabi-gdb --batch-silent --command /app/test-runner.gdb "$EXE" arm-none-eabi-gdb --silent --batch-silent --command /app/test-runner.gdb "$EXE"
STATUS=$? STATUS=$?
if [ $STATUS -ne 0 ]; then if [ $STATUS -ne 0 ]; then
echo >&2 "FAILED (exit status $STATUS): $EXE"
ERRS=$(( ERRS + 1 )) ERRS=$(( ERRS + 1 ))
fi fi
kill -INT $PID &>/dev/null
sleep 1
if kill -0 $PID &>/dev/null; then
kill -KILL $PID &>/dev/null
fi
CITRA_LOG=~/.local/share/citra-emu/log/citra_log.txt
CITRA_LOG_OUT="$(dirname "$EXE")/$(basename "$EXE" .elf)_citra_log.txt"
if test -f "$CITRA_LOG"; then
cp "$CITRA_LOG" "$CITRA_LOG_OUT"
else
echo "WARNING: citra log not found"
fi
done done
exit $ERRS exit $ERRS

6
tests/integration.rs

@ -1,5 +1,5 @@
// Workaround for https://github.com/rust-lang/rust/issues/94348 #![feature(custom_test_frameworks)]
extern crate shim_3ds; #![test_runner(test_runner::run_gdb)]
#[test] #[test]
fn it_works() { fn it_works() {
@ -8,6 +8,6 @@ fn it_works() {
#[test] #[test]
#[should_panic] #[should_panic]
fn it_fails() { fn it_panics() {
assert_eq!(2 + 2, 5); assert_eq!(2 + 2, 5);
} }

Loading…
Cancel
Save