Skip to content

Commit

Permalink
Merge pull request #1373 from jluebbe/qemu-init
Browse files Browse the repository at this point in the history
qemu-test-init: fix git repo access and simplify service handling
  • Loading branch information
ejoerns committed Apr 4, 2024
2 parents ab33823 + a2c074c commit 95e90ba
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions qemu-test-init
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ mount -t sysfs none /sys
mount -t debugfs debugfs /sys/kernel/debug/ || true
mount -t tracefs tracefs /sys/kernel/tracing/ || true
mount -t tmpfs none /mnt
mount -t tmpfs none /root
mount -t tmpfs none /run
mount -t tmpfs none /tmp

# create overlay for /etc
mkdir /tmp/etc-overlay /tmp/etc-work
mount -t overlay overlay -o lowerdir=/etc,upperdir=/tmp/etc-overlay,workdir=/tmp/etc-work /etc

BUILD_DIR="build/"

# parse cmdline
Expand Down Expand Up @@ -43,13 +48,14 @@ ip link set eth0 up
ip addr add 10.0.2.15/24 dev eth0
ip link set eth0 up
ip route add default via 10.0.2.2
# /etc is not writable from here
echo "nameserver 10.0.2.3" > /tmp/resolv.conf
mount --bind /tmp/resolv.conf /etc/resolv.conf
echo "nameserver 10.0.2.3" > /etc/resolv.conf

# switch to rauc dir
cd "$(dirname "$0")"

# allow git access to our repo
git config --system --add safe.directory "$(pwd)"

# fake entropy
$BUILD_DIR/test/fakerand

Expand All @@ -68,18 +74,6 @@ mkfs.ext4 /tmp/rootdev
truncate --size=64M /tmp/appdev
mkfs.ext4 /tmp/appdev

# dbus daemon if service is enabled
if grep -q "ENABLE_SERVICE 1" $BUILD_DIR/config.h; then
cp -a /etc/dbus-1/system.d /tmp
cp -a $BUILD_DIR/data/de.pengutronix.rauc.conf /tmp/system.d
chown root:root /tmp/system.d/de.pengutronix.rauc.conf
chmod 644 /tmp/system.d/de.pengutronix.rauc.conf
mount --bind /tmp/system.d /etc/dbus-1/system.d
mount -t tmpfs none /var/run
mkdir -p /var/run/dbus
time dbus-daemon --system --fork --nopidfile --nosyslog --print-address
fi

# rauc binary in PATH
if [ -n "$SHELL" ]; then
mkdir /tmp/bin
Expand Down Expand Up @@ -115,15 +109,30 @@ if type casync; then
export RAUC_TEST_CASYNC=1
fi

# rauc system config & service start
if [ -n "$SERVICE" ]; then
mkdir /tmp/rauc
cp qemu-test-rauc-config /tmp/rauc/system.conf
cp test/openssl-ca/dev-ca.pem /tmp/rauc/ca.cert.pem
if [ -n "$SERVICE_BACKTRACE" ] && type gdb; then
gdb --batch --ex "run" --ex "thread apply all bt" --args rauc service --conf=/tmp/rauc/system.conf &
else
rauc service --conf=/tmp/rauc/system.conf &
# remove potential host rauc system config
rm -rf /etc/rauc
# create rauc system config for testing and data directory
mkdir /etc/rauc /tmp/rauc
cp qemu-test-rauc-config /etc/rauc/system.conf
cp test/openssl-ca/dev-ca.pem /etc/rauc/ca.cert.pem

# rauc and dbus service start
if grep -q "ENABLE_SERVICE 1" $BUILD_DIR/config.h; then
# dbus
cp -a $BUILD_DIR/data/de.pengutronix.rauc.conf /etc/dbus-1/system.d
chown root:root /etc/dbus-1/system.d/de.pengutronix.rauc.conf
chmod 644 /etc/dbus-1/system.d/de.pengutronix.rauc.conf
mount -t tmpfs none /var/run
mkdir -p /var/run/dbus
time dbus-daemon --system --fork --nopidfile --nosyslog --print-address

# rauc
if [ -n "$SERVICE" ]; then
if [ -n "$SERVICE_BACKTRACE" ] && type gdb; then
gdb --batch --ex "run" --ex "thread apply all bt" --args rauc service &
else
rauc service &
fi
fi
fi

Expand Down

0 comments on commit 95e90ba

Please sign in to comment.