run_qemu.sh: allow setting MMDEBSTRAP_TESTS_DEBUG and add auto-detection for amlogic a311d bananapi

This commit is contained in:
Johannes Schauer Marin Rodrigues 2024-06-02 22:58:16 +02:00
parent abc66c5dc7
commit 767e8a8bfb
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -4,6 +4,7 @@ set -eu
: "${DEFAULT_DIST:=unstable}" : "${DEFAULT_DIST:=unstable}"
: "${cachedir:=./shared/cache}" : "${cachedir:=./shared/cache}"
: "${MMDEBSTRAP_TESTS_DEBUG:=no}"
tmpdir="$(mktemp -d)" tmpdir="$(mktemp -d)"
cleanup() { cleanup() {
@ -29,20 +30,42 @@ fi
touch shared/output.txt touch shared/output.txt
setpriv --pdeathsig TERM tail -f shared/output.txt & setpriv --pdeathsig TERM tail -f shared/output.txt &
# to connect to serial use: set -- timeout --foreground 40m \
# minicom -D 'unix#/tmp/ttyS0' debvm-run --image="$(realpath "$cachedir")/debian-$DEFAULT_DIST.ext4" \
# --
# or this (quit with ctrl+q): cpuname=$(lscpu | awk '/Model name:/ {print $3}' | tr '\n' '+')
# socat stdin,raw,echo=0,escape=0x11 unix-connect:/tmp/ttyS0 ncpu=$(lscpu | awk '/Core\(s\) per socket:/ {print $4}' | tr '\n' '+')
ret=0 if [ "$cpuname" = "Cortex-A53+Cortex-A73+" ] && [ "$ncpu" = "2+4+" ]; then
timeout --foreground 40m debvm-run --image="$(realpath "$cachedir")/debian-$DEFAULT_DIST.ext4" -- \ # crude detection of the big.LITTLE heterogeneous setup of cores on the
-nic none \ # amlogic a311d bananapi
-m 4G -snapshot \ #
# https://lists.nongnu.org/archive/html/qemu-devel/2020-10/msg08494.html
# https://gitlab.com/qemu-project/qemu/-/issues/239
# https://segments.zhan.science/posts/kvm_on_pinehone_pro/#trouble-with-heterogeneous-architecture
set -- taskset --cpu-list 2,3,4,5 "$@" -smp 4
fi
set -- "$@" -nic none -m 4G -snapshot
if [ "$MMDEBSTRAP_TESTS_DEBUG" = "no" ]; then
# to connect to serial use:
# minicom -D 'unix#/tmp/ttyS0'
# or this (quit with ctrl+q):
# socat stdin,raw,echo=0,escape=0x11 unix-connect:/tmp/ttyS0
set -- "$@" \
-monitor unix:/tmp/monitor,server,nowait \ -monitor unix:/tmp/monitor,server,nowait \
-serial unix:/tmp/ttyS0,server,nowait \ -serial unix:/tmp/ttyS0,server,nowait \
-serial unix:/tmp/ttyS1,server,nowait \ -serial unix:/tmp/ttyS1,server,nowait
-virtfs local,id=mmdebstrap,path="$(pwd)/shared",security_model=none,mount_tag=mmdebstrap \ fi
>"$tmpdir/log" 2>&1 || ret=$?
set -- "$@" -virtfs local,id=mmdebstrap,path="$(pwd)/shared",security_model=none,mount_tag=mmdebstrap
ret=0
if [ "$MMDEBSTRAP_TESTS_DEBUG" = "no" ]; then
"$@" >"$tmpdir/log" 2>&1 || ret=$?
else
"$@" 2>&1 | tee "$tmpdir/log" || ret=$?
fi
if [ "$ret" -ne 0 ]; then if [ "$ret" -ne 0 ]; then
cat "$tmpdir/log" cat "$tmpdir/log"
exit $ret exit $ret