2018-11-04 19:34:40 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2018-11-23 16:40:17 +00:00
|
|
|
set -eu
|
|
|
|
|
2019-03-25 13:21:55 +00:00
|
|
|
: "${DEFAULT_DIST:=unstable}"
|
2018-12-28 06:44:54 +00:00
|
|
|
: "${cachedir:=./shared/cache}"
|
2024-06-02 20:58:16 +00:00
|
|
|
: "${MMDEBSTRAP_TESTS_DEBUG:=no}"
|
2018-11-23 16:44:59 +00:00
|
|
|
tmpdir="$(mktemp -d)"
|
2018-11-04 19:34:40 +00:00
|
|
|
|
2018-12-27 13:14:01 +00:00
|
|
|
cleanup() {
|
2024-10-11 16:29:25 +00:00
|
|
|
rv=$?
|
|
|
|
rm -f "$tmpdir/log"
|
|
|
|
[ -e "$tmpdir" ] && rmdir "$tmpdir"
|
|
|
|
if [ -e shared/output.txt ]; then
|
|
|
|
res="$(cat shared/exitstatus.txt)"
|
|
|
|
if [ "$res" != "0" ]; then
|
|
|
|
# this might possibly overwrite another non-zero rv
|
|
|
|
rv=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
exit $rv
|
2018-12-27 13:14:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
trap cleanup INT TERM EXIT
|
|
|
|
|
2024-10-11 16:29:25 +00:00
|
|
|
echo 1 >shared/exitstatus.txt
|
2023-01-16 06:54:03 +00:00
|
|
|
if [ -e shared/output.txt ]; then
|
2024-10-11 16:29:25 +00:00
|
|
|
rm shared/output.txt
|
2023-01-16 06:54:03 +00:00
|
|
|
fi
|
|
|
|
touch shared/output.txt
|
2024-01-08 21:25:07 +00:00
|
|
|
setpriv --pdeathsig TERM tail -f shared/output.txt &
|
2023-01-16 06:54:03 +00:00
|
|
|
|
2024-06-02 20:58:16 +00:00
|
|
|
set -- timeout --foreground 40m \
|
2024-10-11 16:29:25 +00:00
|
|
|
debvm-run --image="$(realpath "$cachedir")/debian-$DEFAULT_DIST.ext4" \
|
|
|
|
--
|
2024-06-02 20:58:16 +00:00
|
|
|
cpuname=$(lscpu | awk '/Model name:/ {print $3}' | tr '\n' '+')
|
|
|
|
ncpu=$(lscpu | awk '/Core\(s\) per socket:/ {print $4}' | tr '\n' '+')
|
|
|
|
if [ "$cpuname" = "Cortex-A53+Cortex-A73+" ] && [ "$ncpu" = "2+4+" ]; then
|
2024-10-11 16:29:25 +00:00
|
|
|
# crude detection of the big.LITTLE heterogeneous setup of cores on the
|
|
|
|
# amlogic a311d bananapi
|
|
|
|
#
|
|
|
|
# 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
|
2024-06-02 20:58:16 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
set -- "$@" -nic none -m 4G -snapshot
|
|
|
|
|
|
|
|
if [ "$MMDEBSTRAP_TESTS_DEBUG" = "no" ]; then
|
2024-10-11 16:29:25 +00:00
|
|
|
# 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 \
|
|
|
|
-serial unix:/tmp/ttyS0,server,nowait \
|
|
|
|
-serial unix:/tmp/ttyS1,server,nowait
|
2024-06-02 20:58:16 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
set -- "$@" -virtfs local,id=mmdebstrap,path="$(pwd)/shared",security_model=none,mount_tag=mmdebstrap
|
|
|
|
|
|
|
|
ret=0
|
|
|
|
if [ "$MMDEBSTRAP_TESTS_DEBUG" = "no" ]; then
|
2024-10-11 16:29:25 +00:00
|
|
|
"$@" >"$tmpdir/log" 2>&1 || ret=$?
|
2024-06-02 20:58:16 +00:00
|
|
|
else
|
2024-10-11 16:29:25 +00:00
|
|
|
"$@" 2>&1 | tee "$tmpdir/log" || ret=$?
|
2024-06-02 20:58:16 +00:00
|
|
|
fi
|
2020-11-26 22:45:08 +00:00
|
|
|
if [ "$ret" -ne 0 ]; then
|
2024-10-11 16:29:25 +00:00
|
|
|
cat "$tmpdir/log"
|
|
|
|
exit $ret
|
2020-11-26 22:45:08 +00:00
|
|
|
fi
|