The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.
PHONY_TARGETS += coverage\:cli coverage codecov coverage\:go\:checkpoint
# Match Codecov's exclusions locally: production guest and SDK code must not
# disappear from the denominator just because their tests run separately.
COVERAGE_REPORT_ARGS = --ignore-filename-regex '(^|/)(src/deps/[^/]+/vendor|src/test-utils|tests)/'
# Instrument core/shared/REST, non-VM integration, CLI, native VMM, and Linux
# guest tests. --no-report accumulates profiles across the passes; the clean
# first drops profiles left by earlier runs, which would otherwise be merged
# in and inflate the numbers. As in test:unit:rust, every pass runs even when
# an earlier one fails, and the recipe exits non-zero if any pass failed.
define run_unit_coverage
@cargo llvm-cov clean --workspace
@rc=0; \
cargo llvm-cov nextest --no-report --no-tests=warn $(NEXTEST_PROFILE_FLAG) $(RUST_UNIT_CORE_ARGS) $(NEXTEST_FILTER) || rc=$$?; \
cargo llvm-cov nextest --no-report --no-tests=warn $(NEXTEST_PROFILE_FLAG) $(RUST_UNIT_SHARED_ARGS) $(NEXTEST_FILTER) || rc=$$?; \
cargo llvm-cov nextest --no-report --no-tests=warn $(NEXTEST_PROFILE_FLAG) $(RUST_UNIT_VMM_ARGS) $(NEXTEST_FILTER) || rc=$$?; \
cargo llvm-cov test --no-report $(RUST_UNIT_REST_ARGS) -- --test-threads=1 $(REST_CARGOTEST_FILTER) || rc=$$?; \
$(MAKE) coverage:runtime || rc=$$?; \
$(MAKE) coverage:cli || rc=$$?; \
$(MAKE) coverage:bindings || rc=$$?; \
if [ "$$(uname)" = Linux ]; then \
cargo llvm-cov nextest $(GUEST_RUNNER_CONFIG) --no-report --no-tests=fail $(NEXTEST_PROFILE_FLAG) -p boxlite-guest $(NEXTEST_FILTER) || rc=$$?; \
fi; \
exit $$rc
endef
# Generate HTML coverage report (unit tests only).
coverage:
@echo "📊 Generating code coverage report..."
$(run_unit_coverage)
@cargo llvm-cov report $(COVERAGE_REPORT_ARGS) --html --output-dir target/coverage
@echo "✅ Coverage report: target/coverage/html/index.html"
# Generate LCOV output for CI upload.
coverage\:lcov:
@echo "📊 Generating LCOV coverage..."
$(run_unit_coverage)
@mkdir -p target/coverage
@cargo llvm-cov report $(COVERAGE_REPORT_ARGS) --lcov --output-path target/coverage/lcov.info
@echo "✅ LCOV output: target/coverage/lcov.info"
coverage\:cli:
@bash "$(SCRIPT_DIR)/test/with-cli-binary.sh" --coverage \
cargo llvm-cov nextest --no-report --no-tests=fail $(NEXTEST_PROFILE_FLAG) -p boxlite-cli --bins --test auth --test ssh_cloud --test custom_kernel_rc --test checkpoint $(NEXTEST_FILTER) -- --skip ::vm_install::
coverage\:runtime:
@cargo llvm-cov nextest --no-report --no-tests=fail $(NEXTEST_PROFILE_FLAG) \
-p boxlite --no-default-features --features test-support \
--test runtime --test shutdown --test network $(NEXTEST_FILTER)
coverage\:bindings:
@rc=0; \
cargo llvm-cov nextest --no-report --no-tests=fail $(NEXTEST_PROFILE_FLAG) \
-p boxlite-c -p boxlite-node --lib $(NEXTEST_FILTER) || rc=$$?; \
cargo llvm-cov nextest --no-report --no-tests=fail $(NEXTEST_PROFILE_FLAG) \
-p boxlite-python --no-default-features --lib $(NEXTEST_FILTER) || rc=$$?; \
exit $$rc
# Language tests exercise the exported bindings that Rust lib tests cannot see.
# Keep their profiles separate from the core collector and upload both reports.
coverage\:bindings\:external: $(if $(filter 1,$(CI_SCRIPT_TESTS_SEPARATE)),,test\:unit\:scripts)
@bash $(SCRIPT_DIR)/test/coverage-bindings.sh
# Render collected profiles, including partial results from a failed test run.
coverage\:report:
@mkdir -p target/coverage
@cargo llvm-cov report $(COVERAGE_REPORT_ARGS) --lcov --output-path target/coverage/lcov.info
@cargo llvm-cov report $(COVERAGE_REPORT_ARGS) --html --output-dir target/coverage
# Codecov enforces patch coverage against the PR base; total coverage is reported.
codecov: coverage\:lcov
# Add real KVM execution before the CI upload. The vm profile allows time for
# the 3073 MiB split-RAM round trip. List each passing test and disable retries.
coverage\:vmm\:kvm: _ensure-kvm
@cargo llvm-cov nextest --no-report --no-tests=fail --profile vm --retries 0 --status-level pass \
-p boxlite-hypervisor -p boxlite-vmm --lib --run-ignored only --test-threads=1 \
-E '(package(boxlite-hypervisor) & test(/^kvm::/)) | (package(boxlite-vmm) & ((test(/^vm::tests::/) | test(tests::kvm::) $(foreach test,$(VMM_KVM_SNAPSHOT_TESTS),| test($(test)))) - test($(VMM_LINUX_SNAPSHOT_TESTS))))'
@cargo llvm-cov report $(COVERAGE_REPORT_ARGS) --lcov --output-path target/coverage/lcov.info
# Add the real-kernel boots of VMM_KERNEL to the same profiles, listed the same way.
# CI runs it only when the vmm path filter matches.
coverage\:vmm\:boot: export VMM_GUEST_MOUNT_INIT := $(PROJECT_ROOT)/target/vmm/guest-mount/x86_64-unknown-linux-musl/release/boxlite-guest
coverage\:vmm\:boot: _ensure-kvm _ensure-vmm-kernel $(VMM_BALLOON_INIT) $(VMM_DISK_GROW_INIT) $(VMM_HOTPLUG_INIT) vmm\:guest-mount-init
@cargo llvm-cov nextest --no-report --no-tests=fail --profile ci --retries 0 --status-level pass \
-p boxlite-vmm --lib --run-ignored only --test-threads=1 -E 'test(boot::tests::) | test($(VMM_LINUX_SNAPSHOT_TESTS))'
@cargo llvm-cov report $(COVERAGE_REPORT_ARGS) --lcov --output-path target/coverage/lcov.info
GO_SDK_COVERAGE_TAGS ?= boxlite_runner
# These tests need a real local runtime. CI defers them until KVM is available.
GO_SDK_KVM_TESTS := ^Test(NestedVirtualizationCreate(Authorization|PersistsAcrossRuntimeReopen)|SSHUsageConfiguredLocalBoxReturnsOwnedEmptyBatchWithoutBoot)$$
GO_RUNNER_KVM_TESTS := ^Test(NestedVirtualization(RunnerCreateAndReplay|UnavailableFallsBackOnCreate|RunnerCombinesKernelAndNesting)|RunnerDrainsPollOnSIGTERM)$$
# Go's reports include every package, including packages with no tests.
coverage\:go:
ifeq ($(GO_TEST_ARCHIVE_READY),1)
@test -s "$(GO_DEBUG_DIR)/libboxlite.a"
else
@$(MAKE) dev:go GO_CARGO_FEATURES="--features test-support"
endif
@mkdir -p target/coverage
@rc=0; \
(cd sdks/go && $(GO_DEV_ENV) go test -a -count=1 -tags $(GO_DEV_TAGS),boxlite_agent_test,$(GO_SDK_COVERAGE_TAGS) -covermode=atomic -coverpkg=./... \
-coverprofile="$(PROJECT_ROOT)/target/coverage/go-sdk.out" $(if $(filter 1,$(GO_COVERAGE_DEFER_KVM)),-skip '$(GO_SDK_KVM_TESTS)') $(GOTEST_FILTER) ./...) || rc=$$?; \
(cd src/deps/libgvproxy-sys/gvproxy-bridge && go test -covermode=atomic -coverpkg=./... \
-coverprofile="$(PROJECT_ROOT)/target/coverage/gvproxy.out" $(GOTEST_FILTER) ./...) || rc=$$?; \
(cd apps/runner && $(GO_DEV_ENV) GOFLAGS=-tags=$(GO_DEV_TAGS),boxlite_runner go test -covermode=atomic -coverpkg=./... \
-coverprofile="$(PROJECT_ROOT)/target/coverage/runner.out" $(if $(filter 1,$(GO_COVERAGE_DEFER_KVM)),-skip '$(GO_RUNNER_KVM_TESTS)') $(GOTEST_FILTER) ./...) || rc=$$?; \
(cd apps/image-service && go test -covermode=atomic -coverpkg=./... \
-coverprofile="$(PROJECT_ROOT)/target/coverage/image-service.out" $(GOTEST_FILTER) ./...) || rc=$$?; \
(cd apps/secret-server && GOWORK=off go test -race -covermode=atomic -coverpkg=./... \
-coverprofile="$(PROJECT_ROOT)/target/coverage/secret-server.out" $(GOTEST_FILTER) ./...) || rc=$$?; \
exit $$rc
# The ordinary coverage step has already built the native SDK and Go packages.
PHONY_TARGETS += _coverage-go-kvm
_coverage-go-kvm:
@cd sdks/go && $(GO_DEV_ENV) go test -count=1 -tags $(GO_DEV_TAGS),boxlite_agent_test,boxlite_runner,boxlite_ssh_usage_test -covermode=atomic -coverpkg=./... \
-coverprofile="$(PROJECT_ROOT)/target/coverage/go-sdk-kvm.out" -run '$(GO_SDK_KVM_TESTS)' .
@cd apps/runner && $(GO_DEV_ENV) GOFLAGS=-tags=$(GO_DEV_TAGS),boxlite_runner go test -count=1 -covermode=atomic -coverpkg=./... \
-coverprofile="$(PROJECT_ROOT)/target/coverage/runner-kvm.out" -run '$(GO_RUNNER_KVM_TESTS)' ./cmd/runner ./pkg/boxlite
@set -e; for module in go-sdk runner; do \
full="$(PROJECT_ROOT)/target/coverage/$$module.out"; focused="$(PROJECT_ROOT)/target/coverage/$$module-kvm.out"; \
test "$$(head -n 1 "$$full")" = 'mode: atomic' && test "$$(head -n 1 "$$focused")" = 'mode: atomic' || exit 1; \
tail -n +2 "$$focused" >> "$$full"; \
done
PHONY_TARGETS += coverage\:apps\:secret-server\:integration
coverage\:apps\:secret-server\:integration: _require-secret-test-database
@mkdir -p "$(PROJECT_ROOT)/target/coverage"
@cd apps/secret-server && GOWORK=off go test -race -count=1 -covermode=atomic -coverpkg=./... -coverprofile="$(PROJECT_ROOT)/target/coverage/secret-server-integration.out" $(SECRET_SERVER_INTEGRATION_PACKAGES) -run '$(SECRET_SERVER_INTEGRATION_TESTS)'
# Native archive import/export does not boot a VM, but the production constructor still
# requires a supported host. The Linux native-binding job enables KVM first.
coverage\:go\:checkpoint: $(if $(CARGO_LLVM_COV),dev\:c,dev\:go)
@mkdir -p target/coverage
@native_tags=boxlite_dev,boxlite_integration; \
if [ -n "$$CARGO_LLVM_COV" ]; then \
native_tags=$$native_tags,boxlite_coverage; \
native_profile_runtime=("$$(rustc --print target-libdir)"/libprofiler_builtins-*.rlib); \
(cd sdks/go && CGO_LDFLAGS="\"$${native_profile_runtime[0]}\"" go test -count=1 -tags=$$native_tags ./integration/archive/internal/nativeprofile) || exit $$?; \
fi; \
cd sdks/go && go test -count=1 -tags=$$native_tags \
-o "$(PROJECT_ROOT)/target/coverage/checkpoint-native.test" \
-covermode=atomic -coverpkg=github.com/boxlite-ai/boxlite/sdks/go \
-coverprofile="$(PROJECT_ROOT)/target/coverage/go-checkpoint-native.out" \
-run '^TestCheckpointNative' ./integration/archive
coverage\:python: _ensure-python-deps
@mkdir -p target/coverage/python
@. .venv/bin/activate && cd sdks/python && \
python -m pytest tests/ -m "not integration" $(PYTEST_FILTER) \
--cov=boxlite --cov-report=term-missing \
--cov-report=xml:../../target/coverage/python/coverage.xml
coverage\:node: _ensure-node-deps
@cd sdks/node && npm test -- --coverage $(VITEST_FILTER)
coverage\:infra: _ensure-infra-deps
@apps/infra/node_modules/.bin/c8 --all --include='apps/infra/**/*.{ts,js,mjs}' \
--exclude='**/{test,tests,node_modules,dist,.sst}/**' \
--exclude='**/*.test.*' --exclude='**/*.d.ts' \
--reporter=lcov --reporter=text-summary --reports-dir=target/coverage/infra \
$(MAKE) test:apps:infra
coverage\:python\:integration: dev\:python _local-registry
@mkdir -p target/coverage/python
@. .venv/bin/activate && cd sdks/python && \
$(WITH_LOCAL_REGISTRY) python -m pytest tests/ -m "not e2e" $(PYTEST_FILTER) \
--cov=boxlite --cov-report=term-missing \
--cov-report=xml:../../target/coverage/python/coverage.xml
coverage\:node\:integration: dev\:node _local-registry
@cd sdks/node && $(WITH_LOCAL_REGISTRY) npm run test:all -- --coverage $(VITEST_FILTER)
coverage\:api: _ensure-apps-deps
@cd apps && yarn nx run api:test --coverage --skip-nx-cache $(if $(TEST_FILES),--runInBand --passWithNoTests=false --testPathPatterns '$(TEST_FILES)',) $(if $(FILTER),--testNamePattern '$(FILTER)',)
PHONY_TARGETS += coverage\:ci-listener coverage\:github-ci-runner
coverage\:ci-listener: _ensure-apps-deps
@cd apps && yarn nx run ci-listener:test --coverage --skip-nx-cache --runInBand $(if $(FILTER),--testNamePattern '$(FILTER)',)
coverage\:github-ci-runner: _ensure-apps-deps
@cd apps && yarn nx run github-ci-runner:test --coverage --skip-nx-cache --runInBand $(if $(FILTER),--testNamePattern '$(FILTER)',)
# Add VM integration coverage to the unit profiles instead of erasing them.
# Run coverage:lcov first for a combined report; BOXLITE_DEPS_STUB must be unset.
coverage\:integration: $(if $(SETUP_DONE),,runtime\:debug)
@echo "📊 Generating integration test coverage..."
@rc=0; \
cargo llvm-cov nextest \
-p boxlite --features krun,gvproxy,native --test '*' \
--profile vm --no-report $(NEXTEST_FILTER) || rc=$$?; \
cargo llvm-cov nextest -p boxlite-cli --test '*' \
--profile vm --no-report $(NEXTEST_CLI_FILTER) || rc=$$?; \
$(MAKE) coverage:report || rc=$$?; \
exit $$rc
@echo "✅ Combined coverage report: target/coverage/html/index.html"
# Exercise file-copy entry points with a real guest and retain the unit profiles.
# The serve regression is explicitly ignored by the non-VM unit pass.
coverage\:copy\:vm: _ensure-kvm $(if $(SETUP_DONE),,runtime\:debug)
@cargo llvm-cov nextest --no-report --no-tests=fail --profile vm --retries 0 --status-level pass \
-p boxlite --features krun,gvproxy,native --test copy --test copy_ownership
@cargo llvm-cov nextest --no-report --no-tests=fail --profile vm --retries 0 --status-level pass \
-p boxlite-cli --bin boxlite --run-ignored only -E 'test(upload_duplicate_entries_return_conflict)'
@$(MAKE) coverage:report