-
Notifications
You must be signed in to change notification settings - Fork 4
/
qemu-kbuild-test
executable file
·44 lines (41 loc) · 1.45 KB
/
qemu-kbuild-test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
mem="768M"
[ "$3" -eq 1 ] && args='-zlz4hc,12'
if [ "$3" -eq 2 ]; then
blks=$((RANDOM % 255 + 2))
echo "EROFS pclusterblks=$blks"
args="-zlz4hc,12 -C$((blks*4096)) --random-pclusterblks"
mem="1G"
[ $blks -gt 171 ] && mem="1280M"
fi
if [ "$3" -eq 3 ]; then
chunksize=$((4096 << (RANDOM % 11)))
echo "EROFS chunksize=$chunksize (blockmap)"
args="--chunksize $chunksize -Eforce-inode-blockmap"
fi
if [ "$3" -eq 4 ]; then
chunksize=$((4096 << (RANDOM % 11)))
echo "EROFS chunksize=$chunksize (chunkindexes)"
args="--chunksize $chunksize -Eforce-chunk-indexes"
fi
[ "$3" -eq 5 ] && args='-zzstd'
if [ "$3" -eq 6 ]; then
blks=$((RANDOM % 255 + 2))
echo "EROFS pclusterblks=$blks"
args="-zzstd -C$((blks*4096)) --random-pclusterblks"
mem="1G"
[ $blks -gt 171 ] && mem="1280M"
fi
curl https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.4.140.tar.gz | tar -zx
bin/mkfs.erofs $args linux.erofs.img linux-5.4.140 && rm -rf linux-5.4.140
bin/fsck.erofs linux.erofs.img || exit 1
fallocate -l 11g overlay.ext4.img && mkfs.ext2 -q overlay.ext4.img
sync
qemu-system-x86_64 -nographic -serial mon:stdio -m $mem -smp 4 \
--accel tcg,thread=multi -kernel $1 \
-drive file=$2,index=0,readonly,media=cdrom \
-hdb linux.erofs.img -hdc overlay.ext4.img \
-net nic,model=e1000 -net user \
-append "net.ifnames=0 root=/dev/sr0 console=ttyS0"
mkdir mnt && sudo mount -o loop overlay.ext4.img mnt && \
{ [ -f mnt/exitstatus ] && [ "x`cat mnt/exitstatus`" = "x0" ]; }