lz4 test (and better build)

This commit is contained in:
Mikaël Cluseau 2023-12-17 14:28:32 +01:00
parent 12bfa6cfd6
commit d69f2f27ee
3 changed files with 14 additions and 4 deletions

View File

@ -4,3 +4,5 @@ dist/*
go.work go.work
go.work.sum go.work.sum
modd.*conf modd.*conf
test-initrd*
test-initrd/**/*

View File

@ -9,7 +9,9 @@ run go test ./...
run go build -o /go/bin/init -trimpath . run go build -o /go/bin/init -trimpath .
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
from alpine:3.18.4 from alpine:3.18.4 as initrd
run apk add --no-cache xz
workdir /layer workdir /layer
run wget -O- https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-minirootfs-3.18.4-x86_64.tar.gz |tar zxv run wget -O- https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-minirootfs-3.18.4-x86_64.tar.gz |tar zxv
@ -22,4 +24,9 @@ copy --from=build /go/bin/init .
# check viability # check viability
run chroot /layer /init hello run chroot /layer /init hello
entrypoint ["sh","-c","find |cpio -H newc -o |base64"] run find |cpio -H newc -o >/initrd
# ------------------------------------------------------------------------
from alpine:3.18.4
copy --from=initrd /initrd /
entrypoint ["base64","/initrd"]

View File

@ -3,7 +3,8 @@ modd.test.conf {}
dist/initrd dist/cpiocat dist/testconf test-initrd/**/* { dist/initrd dist/cpiocat dist/testconf test-initrd/**/* {
prep: dist/testconf test-initrd/config.yaml prep: dist/testconf test-initrd/config.yaml
prep: cp -f dist/initrd test-initrd.cpio prep: cp -f dist/initrd test-initrd.cpio
prep: cd test-initrd && ../dist/cpiocat <../dist/initrd >../test-initrd.cpio * prep: cd test-initrd && cat ../dist/initrd | ../dist/cpiocat * |lz4 -l9v >../test-initrd.cpio.new
prep: if cpio -t -F test-initrd.cpio 2>&1 |grep bytes.of.junk; then echo "bad cpio archive"; exit 1; fi prep: mv test-initrd.cpio.new test-initrd.cpio
prep: if lz4cat test-initrd.cpio | cpio -t 2>&1 |grep bytes.of.junk; then echo "bad cpio archive"; exit 1; fi
prep: kill $(<qemu.pid) prep: kill $(<qemu.pid)
} }