Simple test

This commit is contained in:
Imbus 2026-02-09 13:59:10 +01:00
parent 9723924222
commit 36a98b2630

43
test.sh Normal file
View file

@ -0,0 +1,43 @@
#!/usr/env/bin bash
set -e
DISKFILE="/tmp/disk.img"
BINFILE="/tmp/file.bin"
LOOPNUM=$((RANDOM % 156 + 100))
LOOPDEV="/dev/loop${LOOPNUM}"
echo "Using device: ${LOOPDEV}"
cleanup() {
echo "Cleaning up..."
set +e
sudo losetup -d ${LOOPDEV}
sudo rm ${LOOPDEV}
sudo rm ${BINFILE} ${DISKFILE}
}
trap cleanup EXIT INT TERM
if losetup ${LOOPDEV} >/dev/null 2>&1; then
echo "${LOOPDEV} already in use" >&2
cleanup
exit 1
fi
if [ ! -f ${DISKFILE} ]; then
dd if=/dev/zero of=${DISKFILE} bs=1M count=256
fi
if [ ! -f ${BINFILE} ]; then
dd if=/dev/urandom of=${BINFILE} bs=1M count=64
fi
if [ ! -e ${LOOPDEV} ]; then
sudo losetup ${LOOPDEV} ${DISKFILE}
fi
sudo ./writeimg -nd ${LOOPDEV} ${BINFILE}
sudo ./writeimg -vnd ${LOOPDEV} ${BINFILE}
echo "Looks good!"