Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo install just

# 2. kraft-hyperlight (builds Unikraft kernels)
git clone --branch hyperlight-platform https://github.com/danbugs/kraftkit.git
git clone --branch plat-hyperlight https://github.com/unikraft/kraftkit/
cd kraftkit && go build -o kraft-hyperlight ./cmd/kraft
sudo mv kraft-hyperlight /usr/local/bin/ && cd ..

Expand Down
6 changes: 3 additions & 3 deletions examples/dotnet-nativeaot/Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ ghcr_kernel := "ghcr.io/hyperlight-dev/hyperlight-unikraft/dotnet-nativeaot-kern
run:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}}

# Run 5 times via snapshot/restore
run-5:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 4 --memory {{memory}}
# Run 10 times via snapshot/restore
run-10:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}}
Comment on lines 21 to +24

# Build rootfs via Docker (cross-platform)
rootfs:
Expand Down
6 changes: 3 additions & 3 deletions examples/dotnet/Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ ghcr_kernel := "ghcr.io/hyperlight-dev/hyperlight-unikraft/dotnet-kernel:latest"
run:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}}

# Run 5 times via snapshot/restore
run-5:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 4 --memory {{memory}}
# Run 10 times via snapshot/restore
run-10:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}}
Comment on lines 21 to +24

# Build rootfs via Docker (cross-platform)
rootfs:
Expand Down
8 changes: 4 additions & 4 deletions examples/go/Justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# go on Hyperlight
#
# just run - Run once
# just run-5 - Run 5x (snapshot/restore)
# just run-10 - Run 10x (snapshot/restore)
# just rootfs - Build rootfs via Docker (cross-platform)
# just build - Build/pull kernel
# just clean - Remove build artifacts
Expand All @@ -19,9 +19,9 @@ ghcr_kernel := "ghcr.io/hyperlight-dev/hyperlight-unikraft/go-kernel:latest"
run:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}} -- hello

# Run 5 times via snapshot/restore
run-5:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 4 --memory {{memory}} -- hello
# Run 10 times via snapshot/restore
run-10:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}} -- hello

# Build rootfs via Docker (cross-platform)
rootfs:
Expand Down
8 changes: 4 additions & 4 deletions examples/helloworld-c/Justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# helloworld-c on Hyperlight
#
# just run - Run once
# just run-5 - Run 5x (snapshot/restore)
# just run-10 - Run 10x (snapshot/restore)
# just rootfs - Build rootfs via Docker (cross-platform)
# just build - Build/pull kernel
# just clean - Remove build artifacts
Expand All @@ -19,9 +19,9 @@ ghcr_kernel := "ghcr.io/hyperlight-dev/hyperlight-unikraft/helloworld-c-kernel:l
run:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}}

# Run 5 times via snapshot/restore
run-5:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 4 --memory {{memory}}
# Run 10 times via snapshot/restore
run-10:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}}

# Build rootfs via Docker (cross-platform)
rootfs:
Expand Down
8 changes: 4 additions & 4 deletions examples/hostfs-posix-c/Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ run:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}} --mount {{mount_dir}}

[unix]
run-5:
run-10:
mkdir -p {{mount_dir}}
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 4 --memory {{memory}} --mount {{mount_dir}}
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}} --mount {{mount_dir}}

[windows]
run-5:
run-10:
New-Item -ItemType Directory -Force -Path {{mount_dir}} | Out-Null
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 4 --memory {{memory}} --mount {{mount_dir}}
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}} --mount {{mount_dir}}

rootfs:
docker build --platform linux/amd64 --target cpio -t {{image}}-cpio .
Expand Down
8 changes: 4 additions & 4 deletions examples/hostfs-posix-py/Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ run:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}} --mount {{mount_dir}} -- /hostfs_demo.py

[unix]
run-5:
run-10:
mkdir -p {{mount_dir}}
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 4 --memory {{memory}} --mount {{mount_dir}} -- /hostfs_demo.py
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}} --mount {{mount_dir}} -- /hostfs_demo.py

[windows]
run-5:
run-10:
New-Item -ItemType Directory -Force -Path {{mount_dir}} | Out-Null
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 4 --memory {{memory}} --mount {{mount_dir}} -- /hostfs_demo.py
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}} --mount {{mount_dir}} -- /hostfs_demo.py

rootfs:
docker build --platform linux/amd64 --target cpio -t {{image}}-cpio .
Expand Down
6 changes: 3 additions & 3 deletions examples/nodejs/Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ ghcr_kernel := "ghcr.io/hyperlight-dev/hyperlight-unikraft/nodejs-kernel:latest"
run:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}} -- /app/hello.js

# Run 5 times via snapshot/restore
run-5:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 4 --memory {{memory}} -- /app/hello.js
# Run 10 times via snapshot/restore
run-10:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}} -- /app/hello.js

# Build rootfs via Docker (cross-platform)
rootfs:
Expand Down
8 changes: 4 additions & 4 deletions examples/powershell/Justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# powershell on Hyperlight
#
# just run - Run once
# just run-5 - Run 5x (snapshot/restore)
# just run-10 - Run 10x (snapshot/restore)
# just rootfs - Build rootfs via Docker (cross-platform)
# just build - Build/pull kernel
# just clean - Remove build artifacts
Expand All @@ -19,9 +19,9 @@ ghcr_kernel := "ghcr.io/hyperlight-dev/hyperlight-unikraft/powershell-kernel:lat
run:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}} -- -NoProfile -File /scripts/hello.ps1

# Run 5 times via snapshot/restore
run-5:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 4 --memory {{memory}} -- -NoProfile -File /scripts/hello.ps1
# Run 10 times via snapshot/restore
run-10:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}} -- -NoProfile -File /scripts/hello.ps1

# Build rootfs via Docker (cross-platform)
rootfs:
Expand Down
8 changes: 4 additions & 4 deletions examples/python-tools/Justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# python-tools on Hyperlight
#
# just run - Run once
# just run-5 - Run 5x (snapshot/restore)
# just run-10 - Run 10x (snapshot/restore)
# just rootfs - Build rootfs via Docker (cross-platform)
# just build - Build/pull kernel
# just clean - Remove build artifacts
Expand All @@ -19,9 +19,9 @@ ghcr_kernel := "ghcr.io/hyperlight-dev/hyperlight-unikraft/python-tools-kernel:l
run:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}} --enable-tools -- /test_tools.py

# Run 5 times via snapshot/restore
run-5:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 4 --memory {{memory}} --enable-tools -- /test_tools.py
# Run 10 times via snapshot/restore
run-10:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}} --enable-tools -- /test_tools.py

# Build rootfs via Docker (cross-platform)
rootfs:
Expand Down
8 changes: 4 additions & 4 deletions examples/python/Justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# python on Hyperlight
#
# just run - Run once
# just run-5 - Run 5x (snapshot/restore)
# just run-10 - Run 10x (snapshot/restore)
# just rootfs - Build rootfs via Docker (cross-platform)
# just build - Build/pull kernel
# just clean - Remove build artifacts
Expand All @@ -19,9 +19,9 @@ ghcr_kernel := "ghcr.io/hyperlight-dev/hyperlight-unikraft/python-kernel:latest"
run:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}} -- /hello.py

# Run 5 times via snapshot/restore
run-5:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 4 --memory {{memory}} -- /hello.py
# Run 10 times via snapshot/restore
run-10:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}} -- /hello.py

# Build rootfs via Docker (cross-platform)
rootfs:
Expand Down
8 changes: 4 additions & 4 deletions examples/rust/Justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# rust on Hyperlight
#
# just run - Run once
# just run-5 - Run 5x (snapshot/restore)
# just run-10 - Run 10x (snapshot/restore)
# just rootfs - Build rootfs via Docker (cross-platform)
# just build - Build/pull kernel
# just clean - Remove build artifacts
Expand All @@ -19,9 +19,9 @@ ghcr_kernel := "ghcr.io/hyperlight-dev/hyperlight-unikraft/rust-kernel:latest"
run:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}}

# Run 5 times via snapshot/restore
run-5:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 4 --memory {{memory}}
# Run 10 times via snapshot/restore
run-10:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}}

# Build rootfs via Docker (cross-platform)
rootfs:
Expand Down
8 changes: 4 additions & 4 deletions examples/shell/Justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# shell on Hyperlight
#
# just run - Run once
# just run-5 - Run 5x (snapshot/restore)
# just run-10 - Run 10x (snapshot/restore)
# just rootfs - Build rootfs via Docker (cross-platform)
# just build - Build/pull kernel
# just clean - Remove build artifacts
Expand All @@ -19,9 +19,9 @@ ghcr_kernel := "ghcr.io/hyperlight-dev/hyperlight-unikraft/shell-kernel:latest"
run:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}} -- /demo.sh

# Run 5 times via snapshot/restore
run-5:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 4 --memory {{memory}} -- /demo.sh
# Run 10 times via snapshot/restore
run-10:
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}} -- /demo.sh

# Build rootfs via Docker (cross-platform)
rootfs:
Expand Down
86 changes: 86 additions & 0 deletions scripts/test-examples.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Run one example per language to verify the build+run pipeline.
# Languages: C, Rust, Go, .NET, PowerShell, Shell, Python
#
# Usage: .\scripts\test-examples.ps1

$ErrorActionPreference = "Continue"

$RepoRoot = Split-Path -Parent $PSScriptRoot
$ExamplesDir = Join-Path $RepoRoot "examples"
$Failures = 0

function Run-Example {
param([string]$Name)

$dir = Join-Path $ExamplesDir $Name
Write-Host "--- $Name ---"

if (-not (Test-Path $dir)) {
Write-Host " SKIP: directory not found"
return
}

Push-Location $dir

# Build
Write-Host -NoNewline " build: "
$sw = [System.Diagnostics.Stopwatch]::StartNew()
just build 2>&1 | Out-Null
$sw.Stop()
if ($LASTEXITCODE -eq 0) {
Write-Host "ok $($sw.ElapsedMilliseconds)ms"
} else {
Write-Host "FAILED (exit=$LASTEXITCODE, $($sw.ElapsedMilliseconds)ms)"
$script:Failures++
Pop-Location
return
}

# Rootfs
Write-Host -NoNewline " rootfs: "
$sw = [System.Diagnostics.Stopwatch]::StartNew()
just rootfs 2>&1 | Out-Null
$sw.Stop()
if ($LASTEXITCODE -eq 0) {
Write-Host "ok $($sw.ElapsedMilliseconds)ms"
} else {
Write-Host "FAILED (exit=$LASTEXITCODE, $($sw.ElapsedMilliseconds)ms)"
$script:Failures++
Pop-Location
return
}

# Run
Write-Host -NoNewline " run: "
$sw = [System.Diagnostics.Stopwatch]::StartNew()
just run 2>&1 | Out-Null
$sw.Stop()
if ($LASTEXITCODE -eq 0) {
Write-Host "ok $($sw.ElapsedMilliseconds)ms"
} else {
Write-Host "FAILED (exit=$LASTEXITCODE, $($sw.ElapsedMilliseconds)ms)"
$script:Failures++
}

Pop-Location
}

Write-Host "=== test-examples - $(Get-Date) ==="
Write-Host ""

Run-Example "helloworld-c"
Run-Example "rust"
Run-Example "go"
Run-Example "dotnet"
Run-Example "powershell"
Run-Example "shell"
Run-Example "python"

Write-Host ""
if ($Failures -gt 0) {
Write-Host "DONE with $Failures failure(s)"
exit $Failures
} else {
Write-Host "ALL PASSED"
exit 0
}
Loading
Loading