forked from dan/liminix
1
0
Fork 0

add CI job to test tftpboot

This commit is contained in:
Daniel Barlow 2023-12-18 22:42:29 +00:00
parent 9ca9723c9d
commit e5db2691e5
7 changed files with 123 additions and 3 deletions

View File

@ -45,9 +45,9 @@
boot.commandLine = [
"console=ttyAMA0"
];
hardware = {
loadAddress = lim.parseInt "0x00010000";
entryPoint = lim.parseInt "0x00010000";
hardware = let addr = lim.parseInt "0x40008000"; in {
loadAddress = addr;
entryPoint = addr;
};
};
}

View File

@ -212,6 +212,9 @@ extraPkgs // {
CONFIG_CMD_UBIFS=y
CONFIG_BOOTSTD=y
CONFIG_BOOTMETH_DISTRO=y
CONFIG_LZMA=y
CONFIG_CMD_LZMADEC=y
CONFIG_SYS_BOOTM_LEN=0x1000000
'';
};

View File

@ -7,4 +7,5 @@
ext4 = import ./ext4/test.nix;
min-copy-closure = import ./min-copy-closure/test.nix;
fennel = import ./fennel/test.nix;
tftpboot = import ./tftpboot/test.nix;
}

31
tests/tftpboot/a.sh Normal file
View File

@ -0,0 +1,31 @@
"qemu-system-arm" \
"-M" \
"virt,highmem=off" \
"-cpu" \
"cortex-a15" \
"-m" \
"272" \
"-echr" \
"16" \
"-device" \
"loader,file=run-vm-FwJ0aL,addr=0x3c00000" \
"-serial" \
"mon:stdio" \
"-drive" \
"if=pflash,format=raw,file=run-vm-duvYIP" \
"-drive" \
"if=none,format=raw,id=hd0,file=run-vm-FwJ0aL" \
"-device" \
"virtio-blk-pci,drive=hd0" \
"-netdev" \
"socket,id=access,mcast=230.0.0.1:1234,localaddr=127.0.0.1" \
"-device" \
"virtio-net,disable-legacy=on,disable-modern=off,netdev=access,mac=ba:ad:1d: \
ea:21:02" \
"-netdev" \
"user,tftp=/build,id=lan" \
"-device" \
"virtio-net,disable-legacy=on,disable-modern=off,netdev=lan,mac=ba:ad:1d:ea: \
21:01" \
"-display" \
"none"

View File

@ -0,0 +1,33 @@
{ config, pkgs, lib, lim, ... } :
let
inherit (pkgs.pseudofile) dir symlink;
dts = pkgs.runCommand "qemu.dts" {
nativeBuildInputs = with pkgs.pkgsBuildBuild; [ dtc qemu ];
} ''
qemu-system-arm -machine virt -machine dumpdtb=tmp.dtb
dtc -I dtb -O dts -o $out tmp.dtb
'';
in {
imports = [
../../modules/outputs/ext4fs.nix
../../modules/outputs/tftpboot.nix
];
config = {
hardware.dts.src = lib.mkForce dts;
boot.tftp = {
loadAddress = lim.parseInt "0x42000000";
serverip = "10.0.2.2";
ipaddr = "10.0.2.15";
};
boot.imageFormat = "fit";
rootfsType = "ext4";
filesystem = dir {
hello = {
type = "f";
uid = 7;
gid = 24;
file = "hello world";
};
};
};
}

View File

@ -0,0 +1,21 @@
set timeout 10
spawn socat unix-connect:vm/console -
expect "stop autoboot"
send "\r"
expect "=>"
send "setenv ethact eth1\r"
set fh [open "result/boot.scr"]
while {[gets $fh line] >= 0} {
expect "=>"
send "$line\r"
}
close $fh
expect {
"s6-linux-init" { exit 0 }
timeout { exit 1 }
}

31
tests/tftpboot/test.nix Normal file
View File

@ -0,0 +1,31 @@
{
liminix
}:
let derivation = (import liminix {
device = import "${liminix}/devices/qemu-armv7l/";
liminix-config = ./configuration.nix;
});
img = derivation.outputs.tftpboot;
pkgs = derivation.pkgs;
pkgsBuild = pkgs.pkgsBuildBuild;
in pkgsBuild.runCommand "check" {
nativeBuildInputs = with pkgsBuild; [
expect
socat
run-liminix-vm
] ;
} ''
mkdir vm
ln -s ${img} result
run-liminix-vm \
--background ./vm \
--u-boot ${pkgs.ubootQemuArm}/u-boot.bin \
--arch arm \
--flag -S \
--phram-address 0x40200000 \
--lan "user,tftp=`pwd`" \
--disk-image result/rootfs \
result/uimage result/rootfs
expect ${./script.expect} 2>&1 |tee $out
''