Skip to content

Latest commit

 

History

History
 
 

README.md

smolvm Tests

Integration tests and performance benchmarks for smolvm.

Test Suites

File Description Requires VM
test_cli.sh Basic CLI tests (--version, --help, flags) No
test_machine.sh Machine lifecycle + run tests Yes
test_smolfile.sh Smolfile parsing and integration Yes
test_container.sh Container lifecycle tests (create, exec, stop) Yes
test_api.sh HTTP API tests (smolvm serve) Yes
test_pack.sh Pack command tests (pack, run, daemon mode) Yes

Benchmarks

File Description
bench_vm_startup.sh Measures VM cold start time
bench_container.sh Measures container execution time (cold/warm)

Running Tests

Run All Tests

./tests/run_all.sh

Run Specific Test Suite

./tests/run_all.sh cli        # CLI tests only
./tests/run_all.sh machine    # Machine tests only
./tests/run_all.sh container  # Container tests only
./tests/run_all.sh api        # HTTP API tests only
./tests/run_all.sh pack       # Pack tests only
./tests/run_all.sh pack-quick # Pack tests (skip large images)

Run Benchmarks

./tests/run_all.sh bench           # All benchmarks
./tests/run_all.sh bench-vm        # VM startup benchmark
./tests/run_all.sh bench-container # Container benchmark

Run Individual Test Files

./tests/test_cli.sh
./tests/test_machine.sh
./tests/test_smolfile.sh

Use Specific Binary

SMOLVM=/path/to/smolvm ./tests/run_all.sh

Unit Tests

Unit tests are run via cargo (no VM required):

cargo test --lib

Test Requirements

  • CLI tests: Only require the smolvm binary
  • All other tests: Require VM environment (macOS Hypervisor.framework or Linux KVM)
  • Benchmarks: Require VM environment, best run on a quiet system

Binary Discovery

Tests automatically look for the smolvm binary in:

  1. $SMOLVM environment variable
  2. dist/smolvm-*-darwin-*/smolvm or dist/smolvm-*-linux-*/smolvm
  3. target/release/smolvm

Common Utilities

The common.sh file provides shared test utilities:

  • find_smolvm - Locate the smolvm binary
  • init_smolvm - Initialize and validate the binary
  • run_test - Run a test function with pass/fail tracking
  • print_summary - Print test results summary
  • ensure_machine_running - Start the default machine
  • cleanup_machine - Stop the default machine
  • extract_container_id - Parse container ID from command output
  • cleanup_container - Force remove a container

Test Count

Suite Tests
CLI 10
Machine 30
Smolfile 28
Container 10
API 16
Pack 25
Total 119