Browse Source

Overhaul the test-runner entrypoint for one file

Make sure docker is installed in our custom action
pull/7/head
Ian Chamberlain 1 year ago
parent
commit
0f7be6f691
No known key found for this signature in database
GPG Key ID: AE5484D09405AA60
  1. 8
      .github/actions/test/action.yml
  2. 90
      docker/entrypoint.sh

8
.github/actions/test/action.yml

@ -27,8 +27,14 @@ runs: @@ -27,8 +27,14 @@ runs:
with:
tags: ${{ inputs.runner-image }}:latest
push: false
load: true
- shell: bash
- name: Ensure docker is installed in the container
shell: bash
run: apt-get update -y && apt-get install docker.io -y
- name: Run cargo 3ds test
shell: bash
# Set a custom runner for `cargo test` commands to use.
# Use ${GITHUB_WORKSPACE} due to
# https://github.com/actions/runner/issues/2058, which also means

90
docker/entrypoint.sh

@ -1,50 +1,64 @@ @@ -1,50 +1,64 @@
#!/bin/bash
# Clean up child processes on exit: https://stackoverflow.com/a/2173421/14436105
trap "pkill -P $$" EXIT INT TERM
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)_capture.webm"
# colored logs would be nice, but we can always just grab the plaintext log file
xvfb-run citra \
set -x
function cleanup_jobs() {
# shellcheck disable=SC2317 # Unreachable because it's only used in trap
if [ -n "$(jobs -p)" ]; then
sleep 5 &
wait -n
# shellcheck disable=SC2046 # We want to expand jobs here and for `wait`
kill -9 $(jobs -p)
# shellcheck disable=SC2046
wait $(jobs -p) &>/dev/null
fi
}
trap cleanup_jobs EXIT
EXE_ELF=$1
EXE_3DSX="$(dirname "$EXE")/$(basename "$EXE" .elf).3dsx"
EXE_TO_RUN="$EXE_ELF"
if [ -f "$EXE_3DSX" ]; then
echo >&2 "Found $(basename "$EXE_3DSX"), it will be run instead of $(basename "$EXE_ELF")"
EXE_TO_RUN="$EXE_3DSX"
fi
VIDEO_OUT="$(dirname "$EXE_ELF")/$(basename "$EXE_ELF" .elf)_capture.webm"
CITRA_LOG_DIR=~/.local/share/citra-emu/log
CITRA_OUT="$CITRA_LOG_DIR/citra_output.txt"
xvfb-run --auto-servernum \
citra \
--appimage-extract-and-run \
--dump-video="$VIDEO_OUT" \
"$EXE" \
&>/dev/null &
PID=$!
"$EXE_TO_RUN" \
&>"$CITRA_OUT" &
CITRA_PID=$!
# Citra takes a little while to start up, so wait a little before we try to connect
sleep 3
# Citra takes a little while to start up, so wait a little before we try to connect
sleep 5
arm-none-eabi-gdb --silent --batch-silent --command /app/test-runner.gdb "$EXE"
STATUS=$?
if [ $STATUS -ne 0 ]; then
echo >&2 "FAILED (exit status $STATUS): $EXE"
ERRS=$(( ERRS + 1 ))
fi
arm-none-eabi-gdb --silent --batch-silent --command /app/test-runner.gdb "$EXE_ELF"
STATUS=$?
kill -INT $PID &>/dev/null
sleep 1
if kill -0 $PID &>/dev/null; then
kill -KILL $PID &>/dev/null
fi
kill $CITRA_PID
cleanup_jobs
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"
CITRA_LOG="$CITRA_LOG_DIR/citra_log.txt"
for f in "$CITRA_LOG" "$CITRA_OUT"; do
OUT="$(dirname "$EXE_ELF")/$(basename "$EXE_ELF" .elf)_$(basename "$f")"
if test -f "$f"; then
cp "$f" "$OUT"
if [ $STATUS -ne 0 ]; then
echo >&2 "$(basename $f) copied to $OUT"
fi
else
echo "WARNING: citra log not found"
echo >&2 "WARNING: $(basename "$f") not found"
fi
done
exit $ERRS
exit $STATUS

Loading…
Cancel
Save