|
| 1 | +#!/bin/bash |
| 2 | +# Run all Hyperlight-Unikraft examples (excluding python-agent-driver) |
| 3 | +# Captures both "just run" (single cold execution) and "just run-X" (repeated snapshot/restore) |
| 4 | +# |
| 5 | +# Usage: chmod +x run-all-examples.sh && ./run-all-examples.sh |
| 6 | +# |
| 7 | +# Per-example logs: results-<name>.txt |
| 8 | +# Final summary: results-summary.txt |
| 9 | + |
| 10 | +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" |
| 11 | +cd "$SCRIPT_DIR" |
| 12 | + |
| 13 | +SUMMARY="results-summary.txt" |
| 14 | +echo "=== Hyperlight-Unikraft Examples Run — $(date) ===" | tee "$SUMMARY" |
| 15 | +echo "" | tee -a "$SUMMARY" |
| 16 | + |
| 17 | +run_example() { |
| 18 | + local name="$1" |
| 19 | + local repeat_cmd="$2" # e.g. "run-5", "run-10", or "" if none |
| 20 | + local outfile="results-${name}.txt" |
| 21 | + |
| 22 | + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | tee -a "$SUMMARY" |
| 23 | + echo "▶ $name" | tee -a "$SUMMARY" |
| 24 | + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | tee -a "$SUMMARY" |
| 25 | + |
| 26 | + cd "$SCRIPT_DIR/$name" |
| 27 | + |
| 28 | + # Build |
| 29 | + printf " [build] running... " |
| 30 | + local t0=$(date +%s%N) |
| 31 | + just build < /dev/null > "$outfile" 2>&1 |
| 32 | + local rc=$? |
| 33 | + local t1=$(date +%s%N) |
| 34 | + local build_ms=$(( (t1 - t0) / 1000000 )) |
| 35 | + if [ $rc -eq 0 ]; then |
| 36 | + echo "✓ ${build_ms}ms" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY" |
| 37 | + else |
| 38 | + echo "✗ FAILED (exit=$rc, ${build_ms}ms)" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY" |
| 39 | + cd "$SCRIPT_DIR" |
| 40 | + return 1 |
| 41 | + fi |
| 42 | + |
| 43 | + # Rootfs |
| 44 | + printf " [rootfs] running... " |
| 45 | + t0=$(date +%s%N) |
| 46 | + just rootfs < /dev/null >> "$outfile" 2>&1 |
| 47 | + rc=$? |
| 48 | + t1=$(date +%s%N) |
| 49 | + local rootfs_ms=$(( (t1 - t0) / 1000000 )) |
| 50 | + if [ $rc -eq 0 ]; then |
| 51 | + echo "✓ ${rootfs_ms}ms" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY" |
| 52 | + else |
| 53 | + echo "✗ FAILED (exit=$rc, ${rootfs_ms}ms)" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY" |
| 54 | + cd "$SCRIPT_DIR" |
| 55 | + return 1 |
| 56 | + fi |
| 57 | + |
| 58 | + # Run once (cold start) |
| 59 | + printf " [run] running... " |
| 60 | + t0=$(date +%s%N) |
| 61 | + just run < /dev/null >> "$outfile" 2>&1 |
| 62 | + rc=$? |
| 63 | + t1=$(date +%s%N) |
| 64 | + local run_ms=$(( (t1 - t0) / 1000000 )) |
| 65 | + if [ $rc -eq 0 ]; then |
| 66 | + echo "✓ ${run_ms}ms" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY" |
| 67 | + else |
| 68 | + echo "✗ FAILED (exit=$rc, ${run_ms}ms)" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY" |
| 69 | + fi |
| 70 | + |
| 71 | + # Run repeated (snapshot/restore) — if a repeat command exists |
| 72 | + if [ -n "$repeat_cmd" ]; then |
| 73 | + printf " [$repeat_cmd] running... " |
| 74 | + t0=$(date +%s%N) |
| 75 | + just "$repeat_cmd" < /dev/null >> "$outfile" 2>&1 |
| 76 | + rc=$? |
| 77 | + t1=$(date +%s%N) |
| 78 | + local repeat_ms=$(( (t1 - t0) / 1000000 )) |
| 79 | + if [ $rc -eq 0 ]; then |
| 80 | + echo "✓ ${repeat_ms}ms" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY" |
| 81 | + else |
| 82 | + echo "✗ FAILED (exit=$rc, ${repeat_ms}ms)" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY" |
| 83 | + fi |
| 84 | + echo " TOTAL: build=${build_ms}ms rootfs=${rootfs_ms}ms run=${run_ms}ms ${repeat_cmd}=${repeat_ms}ms" | tee -a "$SCRIPT_DIR/$SUMMARY" |
| 85 | + else |
| 86 | + echo " TOTAL: build=${build_ms}ms rootfs=${rootfs_ms}ms run=${run_ms}ms" | tee -a "$SCRIPT_DIR/$SUMMARY" |
| 87 | + fi |
| 88 | + |
| 89 | + echo "" | tee -a "$SCRIPT_DIR/$SUMMARY" |
| 90 | + cd "$SCRIPT_DIR" |
| 91 | +} |
| 92 | + |
| 93 | +# Examples with their repeat commands (from each Justfile) |
| 94 | +run_example "helloworld-c" "run-5" |
| 95 | +run_example "rust" "run-5" |
| 96 | +run_example "go" "run-10" |
| 97 | +run_example "shell" "run-5" |
| 98 | +run_example "python" "run-10" |
| 99 | +run_example "python-tools" "run-10" |
| 100 | +run_example "nodejs" "run-10" |
| 101 | +run_example "dotnet" "run-10" |
| 102 | +run_example "dotnet-nativeaot" "run-10" |
| 103 | +run_example "powershell" "run-10" |
| 104 | +run_example "hostfs-posix-c" "run-5" |
| 105 | +run_example "hostfs-posix-py" "run-5" |
| 106 | +run_example "multifn-c" "" |
| 107 | +run_example "python-agent" "" |
| 108 | +run_example "networking-py" "run-get" |
| 109 | + |
| 110 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | tee -a "$SUMMARY" |
| 111 | +echo "✅ ALL DONE — $(date)" | tee -a "$SUMMARY" |
| 112 | +echo "Per-example logs: results-<name>.txt" |
| 113 | +echo "Summary: $SUMMARY" |
0 commit comments