diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 077222b..95629df 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -28,6 +28,8 @@ runs: - name: Set up Rust cache uses: Swatinem/rust-cache@v2 + with: + shared-key: rust3ds - name: Install build tools for host shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a8810fa..04d0614 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,8 +63,7 @@ jobs: run: cargo 3ds test --no-run --test integration - name: Build doc tests - # need build-std=test until https://github.com/rust3ds/cargo-3ds/pull/42 - run: cargo 3ds test --doc -Zbuild-std=std,test + run: cargo 3ds test --no-run --doc - name: Run lib + integration tests uses: ./.github/actions/citra @@ -74,3 +73,12 @@ jobs: # 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 # 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 diff --git a/Cargo.toml b/Cargo.toml index 60a6399..6d49699 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,4 +12,3 @@ socket = [] ctru-rs = { git = "https://github.com/rust3ds/ctru-rs" } ctru-sys = { git = "https://github.com/rust3ds/ctru-rs" } libc = "0.2.147" -shim-3ds = { git = "https://github.com/rust3ds/shim-3ds", version = "0.1.0" } diff --git a/Dockerfile b/Dockerfile index b0f5728..f183e67 100644 --- a/Dockerfile +++ b/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 download_citra ${CITRA_CHANNEL} ${CITRA_RELEASE} -RUN wget https://apt.devkitpro.org/install-devkitpro-pacman && \ - chmod +x ./install-devkitpro-pacman && \ - yes | /tmp/install-devkitpro-pacman -RUN dkp-pacman -S --noconfirm \ - devkitARM-gdb \ - libctru +FROM devkitpro/devkitarm:latest as devkitarm 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 \ libswscale5 \ libsdl2-2.0-0 \ @@ -25,11 +21,11 @@ RUN apt-get update -y && \ libavfilter7 \ xvfb -COPY --from=builder /opt/devkitpro /opt/devkitpro +COPY --from=devkitarm /opt/devkitpro /opt/devkitpro ENV PATH=/opt/devkitpro/devkitARM/bin:${PATH} 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/entrypoint.sh /app/ diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index b514fdd..a64e91d 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,25 +1,49 @@ #!/bin/bash # 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 # shellcheck disable=SC2068 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 - 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 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=$? if [ $STATUS -ne 0 ]; then - ERRS=$((ERRS + 1)) + echo >&2 "FAILED (exit status $STATUS): $EXE" + ERRS=$(( ERRS + 1 )) + 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 diff --git a/tests/integration.rs b/tests/integration.rs index b00b99f..1cd14ac 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1,5 +1,5 @@ -// Workaround for https://github.com/rust-lang/rust/issues/94348 -extern crate shim_3ds; +#![feature(custom_test_frameworks)] +#![test_runner(test_runner::run_gdb)] #[test] fn it_works() { @@ -8,6 +8,6 @@ fn it_works() { #[test] #[should_panic] -fn it_fails() { +fn it_panics() { assert_eq!(2 + 2, 5); }