Skip to content

test(e2e): Add e2e coverage for kraft build - #2938

Open
srinivasr wants to merge 1 commit into
unikraft:stagingfrom
srinivasr:test/e2e-kraft-build
Open

srinivasr wants to merge 1 commit into
unikraft:stagingfrom
srinivasr:test/e2e-kraft-build

Conversation

@srinivasr

Copy link
Copy Markdown
Contributor

Prerequisite checklist

Description of changes

Ref: #810

Adds e2e tests for kraft build in test/e2e/cli/build_test.go, with a small fixture app under test/e2e/cli/fixtures/helloworld/ (Kraftfile, Makefile.uk, helloworld.c). No production code changed.

The building context runs kraft build --plat qemu --arch x86_64 once on the fixture, then checks that the kernel image exists and parses as an ELF (ET_EXEC, ELFCLASS32, EM_386), that it contains "Hello world!", and that the .config file was written. There are also --help output specs and two error cases (nonexistent project dir, invalid --rootfs-type). Five specs in total.

The fixture Kraftfile pins unikraft to ba13cc8 (unikraft 0.20.0) so the test doesn't change when the stable channel moves. A full commit SHA can't be used because kraft resolves core/unikraft through the manifests.kraftkit.sh index, which only lists 7-character gitshas and channels.

This spec compiles a unikernel, so the build specs are slower than the other cli specs and are skipped when not on linux/amd64, with a 20-minute timeout on the build step.

Testing

go test ./test/e2e/cli/ -run TestCli -count=1 -args -ginkgo.focus="kraft build" - 5 passed, 0 failed, 1 pending (pre-existing), 88 skipped.
golangci-lint run test/e2e/cli/... - 0 issues.

Note: on GCC 15+ hosts the pinned unikraft may fail to build (C23 makes the unprototyped uk_ctor_func_t call a hard error); UK_CFLAGS=-std=gnu11 works around it locally. CI on ubuntu-24.04 is unaffected.

Builds a minimal helloworld Unikraft project and checks the ELF
artifact, then covers build help and two flag-validation errors.

Signed-off-by: srinivasr <sriniv4sreddy@gmail.com>
@craciunoiuc

Copy link
Copy Markdown
Member

hmm, not sure if this test should be added here

we already have a test like this building helloworld using kraft in the unikraft pipelines and in the catalog pipelines

To justify this, I think it makes sense to add a bit more tests related to how the flags work, not necessarily that the image produced is good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🧊 Icebox

Development

Successfully merging this pull request may close these issues.

2 participants