Tests: test.sh does not use sudo internally, now runs under alpine with musl
This commit is contained in:
parent
8601db8811
commit
d90c05ca77
1 changed files with 22 additions and 15 deletions
37
test.sh
37
test.sh
|
|
@ -4,13 +4,17 @@ set -e
|
||||||
# set -x # For debugging
|
# set -x # For debugging
|
||||||
|
|
||||||
# If you ever mess this up:
|
# If you ever mess this up:
|
||||||
# $ sudo mknod /dev/loop-control c 10 237
|
# $ mknod /dev/loop-control c 10 237
|
||||||
# $ sudo chmod 600 /dev/loop-control
|
# $ chmod 600 /dev/loop-control
|
||||||
# $ sudo chown root:root /dev/loop-control
|
# $ chown root:root /dev/loop-control
|
||||||
#
|
#
|
||||||
# For cleanup:
|
# For cleanup:
|
||||||
# $ sudo find /dev -maxdepth 1 -type b -name 'loop[0-9]*' -exec rm -f {} \;
|
# $ find /dev -maxdepth 1 -type b -name 'loop[0-9]*' -exec rm -f {} \;
|
||||||
|
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
echo "Run as root. We need permissions to write and setup a loop device."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
DISKFILE="/tmp/disk.img"
|
DISKFILE="/tmp/disk.img"
|
||||||
BINFILE="/tmp/file.bin"
|
BINFILE="/tmp/file.bin"
|
||||||
|
|
@ -22,9 +26,9 @@ echo "Using device: ${LOOPDEV}"
|
||||||
cleanup() {
|
cleanup() {
|
||||||
echo "Cleaning up..."
|
echo "Cleaning up..."
|
||||||
set +e -x
|
set +e -x
|
||||||
sudo losetup -d ${LOOPDEV}
|
losetup -d ${LOOPDEV}
|
||||||
sudo rm ${LOOPDEV}
|
rm ${LOOPDEV}
|
||||||
sudo rm ${BINFILE} ${DISKFILE}
|
rm ${BINFILE} ${DISKFILE}
|
||||||
}
|
}
|
||||||
|
|
||||||
trap cleanup EXIT INT TERM
|
trap cleanup EXIT INT TERM
|
||||||
|
|
@ -36,28 +40,31 @@ if losetup ${LOOPDEV} >/dev/null 2>&1; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f ${DISKFILE} ]; then
|
if [ ! -f ${DISKFILE} ]; then
|
||||||
|
echo "Creating ${DISKFILE}"
|
||||||
dd if=/dev/zero of=${DISKFILE} bs=1M count=256
|
dd if=/dev/zero of=${DISKFILE} bs=1M count=256
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f ${BINFILE} ]; then
|
if [ ! -f ${BINFILE} ]; then
|
||||||
|
echo "Creating ${BINFILE}"
|
||||||
dd if=/dev/urandom of=${BINFILE} bs=1M count=64
|
dd if=/dev/urandom of=${BINFILE} bs=1M count=64
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e ${LOOPDEV} ]; then
|
if [ ! -e ${LOOPDEV} ]; then
|
||||||
sudo losetup ${LOOPDEV} ${DISKFILE}
|
mknod ${LOOPDEV} b 7 ${LOOPNUM} # busybox needs this
|
||||||
|
losetup ${LOOPDEV} ${DISKFILE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo ./writeimg -nd ${LOOPDEV} ${BINFILE}
|
./writeimg -nd ${LOOPDEV} ${BINFILE}
|
||||||
sudo ./writeimg -vnd ${LOOPDEV} ${BINFILE}
|
./writeimg -vnd ${LOOPDEV} ${BINFILE}
|
||||||
|
|
||||||
sudo ./writeimg -nd ${LOOPDEV} ./writeimg
|
./writeimg -nd ${LOOPDEV} ./writeimg
|
||||||
sudo ./writeimg -vnd ${LOOPDEV} ./writeimg
|
./writeimg -vnd ${LOOPDEV} ./writeimg
|
||||||
|
|
||||||
sudo ./writeimg -nd ${LOOPDEV} ./LICENSE
|
./writeimg -nd ${LOOPDEV} ./LICENSE
|
||||||
sudo ./writeimg -vnd ${LOOPDEV} ./LICENSE
|
./writeimg -vnd ${LOOPDEV} ./LICENSE
|
||||||
|
|
||||||
# Redirect this to avoid confusion
|
# Redirect this to avoid confusion
|
||||||
! sudo ./writeimg -vnd ${LOOPDEV} ./crc32.h 2>/dev/null
|
! ./writeimg -vnd ${LOOPDEV} ./crc32.h 2>/dev/null
|
||||||
|
|
||||||
GREEN="\e[32m"
|
GREEN="\e[32m"
|
||||||
RESET="\e[0m"
|
RESET="\e[0m"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue