Make test cases buildable on FreeBSD

This commit is contained in:
mintsuki 2020-07-06 22:59:28 +02:00
parent e7669cadae
commit 6d5efbdc15
2 changed files with 45 additions and 65 deletions

102
Makefile
View File

@ -1,4 +1,6 @@
.PHONY: all clean echfs-test ext2-test
OS := $(shell uname)
.PHONY: all clean echfs-test ext2-test test.img
all:
$(MAKE) -C src all
@ -7,31 +9,35 @@ all:
clean:
$(MAKE) -C src clean
echfs-test: all
$(MAKE) -C test
test.img:
rm -f test.img
dd if=/dev/zero bs=1M count=0 seek=64 of=test.img
parted -s test.img mklabel gpt
parted -s test.img mkpart primary 2048s 6143s
parted -s test.img mkpart primary 6144s 131038s
echfs-utils -g -p1 test.img quick-format 512
echfs-utils -g -p1 test.img import test/test.elf boot/test.elf
echfs-utils -g -p1 test.img import test/qloader2.cfg qloader2.cfg
./qloader2-install src/qloader2.bin test.img 2048
dd if=/dev/zero bs=1M count=0 seek=4096 of=test.img
ifeq ($(OS), Linux)
parted -s test.img mklabel msdos
parted -s test.img mkpart primary 100%
else ifeq ($(OS), FreeBSD)
sudo mdconfig -a -t vnode -f test.img -u md9
sudo gpart create -s mbr md9
sudo gpart add -a 4k -t '!14' md9
sudo mdconfig -d -u md9
endif
echfs-test: test.img all
$(MAKE) -C test
echfs-utils -m -p0 test.img quick-format 32768
echfs-utils -m -p0 test.img import test/test.elf boot/test.elf
echfs-utils -m -p0 test.img import test/qloader2.cfg qloader2.cfg
./qloader2-install src/qloader2.bin test.img
qemu-system-x86_64 -hda test.img -debugcon stdio
ext2-test: all
ext2-test: test.img all
$(MAKE) -C test
rm -rf test.img test_image/
rm -rf test_image/
mkdir test_image
dd if=/dev/zero bs=1M count=0 seek=64 of=test.img
parted -s test.img mklabel gpt
parted -s test.img mkpart primary 2048s 6143s
parted -s test.img mkpart primary 6144s 131038s
sudo losetup -Pf --show test.img > loopback_dev
sudo partprobe `cat loopback_dev`
sudo mkfs.ext2 `cat loopback_dev`p2
sudo mount `cat loopback_dev`p2 test_image
sudo mkfs.ext2 `cat loopback_dev`p1
sudo mount `cat loopback_dev`p1 test_image
sudo mkdir test_image/boot
sudo cp test/test.elf test_image/boot/
sudo cp test/qloader2.cfg test_image/
@ -39,59 +45,33 @@ ext2-test: all
sudo umount test_image/
sudo losetup -d `cat loopback_dev`
rm -rf test_image loopback_dev
./qloader2-install src/qloader2.bin test.img 2048
./qloader2-install src/qloader2.bin test.img
qemu-system-x86_64 -hda test.img -debugcon stdio
fat32-test: all
fat32-test: test.img all
$(MAKE) -C test
rm -rf test.img test_image/
rm -rf test_image/
mkdir test_image
dd if=/dev/zero bs=1M count=0 seek=64 of=test.img
parted -s test.img mklabel gpt
parted -s test.img mkpart primary 2048s 6143s
parted -s test.img mkpart primary 6144s 131038s
ifeq ($(OS), Linux)
sudo losetup -Pf --show test.img > loopback_dev
sudo partprobe `cat loopback_dev`
sudo mkfs.fat -F 32 `cat loopback_dev`p2
sudo mount `cat loopback_dev`p2 test_image
sudo mkfs.fat -F 32 `cat loopback_dev`p1
sudo mount `cat loopback_dev`p1 test_image
else ifeq ($(OS), FreeBSD)
sudo mdconfig -a -t vnode -f test.img -u md9
sudo newfs_msdos -F 32 /dev/md9s1
sudo mount -t msdosfs /dev/md9s1 test_image
endif
sudo mkdir test_image/boot
sudo cp test/test.elf test_image/boot/
sudo cp test/qloader2.cfg test_image/
sync
sudo umount test_image/
ifeq ($(OS), Linux)
sudo losetup -d `cat loopback_dev`
else ifeq ($(OS), FreeBSD)
sudo mdconfig -d -u md9
endif
rm -rf test_image loopback_dev
./qloader2-install src/qloader2.bin test.img 2048
qemu-system-x86_64 -hda test.img -debugcon stdio
fat32-test-big-clusters: all
$(MAKE) -C test
rm -rf test.img test_image/
mkdir test_image
# Setup partitions
dd if=/dev/zero bs=1M count=0 seek=512 of=test.img
parted -s test.img mklabel gpt
parted -s test.img mkpart primary 2048s 6143s
parted -s test.img mkpart primary 6144s 1042432s
sudo losetup -Pf --show test.img > loopback_dev
sudo partprobe `cat loopback_dev`
sudo mkfs.fat -s 8 -F 32 `cat loopback_dev`p2
sudo mount `cat loopback_dev`p2 test_image
sudo mkdir test_image/boot
# Copy some random files to fill up the fats to span multiple clusters.
# This will make the test more credible.
sudo find ./src -type f -exec cp -n {} test_image/ \;
sudo find ./src -type f -exec cp -n {} test_image/boot/ \;
# Copy the actual important files
sudo cp test/test.elf test_image/boot/
sudo cp test/qloader2.cfg test_image/
sync
sudo umount test_image/
sudo losetup -d `cat loopback_dev`
rm -rf test_image loopback_dev
./qloader2-install src/qloader2.bin test.img 2048
./qloader2-install src/qloader2.bin test.img
qemu-system-x86_64 -hda test.img -debugcon stdio

View File

@ -4,21 +4,21 @@ TIMEOUT=3
PROTOCOL=stivale
KERNEL_PARTITION=1
KERNEL_PARTITION=0
KERNEL_PATH=boot/test.elf
KERNEL_CMDLINE=something
MODULE_PARTITION=1
MODULE_PARTITION=0
MODULE_PATH=qloader2.cfg
MODULE_STRING=something here
:Test 2
KERNEL_PARTITION=1
KERNEL_PARTITION=0
KERNEL_PATH=/boot/test.elf
KERNEL_PROTO=stivale
KERNEL_CMDLINE=none
MODULE_PARTITION=1
MODULE_PARTITION=0
MODULE_PATH=qloader2.cfg
MODULE_STRING=something here