Skip to content

Commit babc0d1

Browse files
committed
fix: address copilot review feedback on Justfile comments and script
Signed-off-by: danbugs <danilochiarlone@gmail.com>
1 parent 19c0377 commit babc0d1

4 files changed

Lines changed: 63 additions & 29 deletions

File tree

examples/dotnet-nativeaot/Justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ghcr_kernel := "ghcr.io/hyperlight-dev/hyperlight-unikraft/dotnet-nativeaot-kern
1919
run:
2020
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}}
2121

22-
# Run 5 times via snapshot/restore
22+
# Run 10 times via snapshot/restore
2323
run-10:
2424
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}}
2525

examples/dotnet/Justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ghcr_kernel := "ghcr.io/hyperlight-dev/hyperlight-unikraft/dotnet-kernel:latest"
1919
run:
2020
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}}
2121

22-
# Run 5 times via snapshot/restore
22+
# Run 10 times via snapshot/restore
2323
run-10:
2424
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --repeat 9 --memory {{memory}}
2525

examples/run-all-examples.sh

Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,80 +6,108 @@
66
#
77
# Per-example logs: results-<name>.txt
88
# Final summary: results-summary.txt
9+
#
10+
# Requires GNU coreutils (date +%s%N). On macOS: brew install coreutils
11+
# and use gdate, or install GNU date.
12+
13+
set -euo pipefail
914

1015
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
1116
cd "$SCRIPT_DIR"
1217

1318
SUMMARY="results-summary.txt"
14-
echo "=== Hyperlight-Unikraft Examples Run — $(date) ===" | tee "$SUMMARY"
19+
FAILURES=0
20+
21+
# Portable millisecond timer: prefer date +%s%N (GNU), fall back to
22+
# python3 if %N is unsupported (macOS).
23+
now_ns() {
24+
local ns
25+
ns=$(date +%s%N 2>/dev/null)
26+
if [ "${#ns}" -gt 10 ]; then
27+
echo "$ns"
28+
else
29+
python3 -c 'import time; print(int(time.time()*1e9))'
30+
fi
31+
}
32+
33+
echo "=== Hyperlight-Unikraft Examples Run -- $(date) ===" | tee "$SUMMARY"
1534
echo "" | tee -a "$SUMMARY"
1635

1736
run_example() {
1837
local name="$1"
1938
local repeat_cmd="$2" # e.g. "run-5", "run-10", or "" if none
2039
local outfile="results-${name}.txt"
2140

22-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | tee -a "$SUMMARY"
23-
echo " $name" | tee -a "$SUMMARY"
24-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | tee -a "$SUMMARY"
41+
echo "---" | tee -a "$SUMMARY"
42+
echo "> $name" | tee -a "$SUMMARY"
43+
echo "---" | tee -a "$SUMMARY"
2544

26-
cd "$SCRIPT_DIR/$name"
45+
if ! cd "$SCRIPT_DIR/$name" 2>/dev/null; then
46+
echo " SKIP: directory $name not found" | tee -a "$SCRIPT_DIR/$SUMMARY"
47+
return 1
48+
fi
2749

2850
# Build
2951
printf " [build] running... "
30-
local t0=$(date +%s%N)
52+
local t0
53+
t0=$(now_ns)
3154
just build < /dev/null > "$outfile" 2>&1
3255
local rc=$?
33-
local t1=$(date +%s%N)
56+
local t1
57+
t1=$(now_ns)
3458
local build_ms=$(( (t1 - t0) / 1000000 ))
3559
if [ $rc -eq 0 ]; then
36-
echo " ${build_ms}ms" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
60+
echo "ok ${build_ms}ms" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
3761
else
38-
echo "✗ FAILED (exit=$rc, ${build_ms}ms)" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
62+
echo "FAILED (exit=$rc, ${build_ms}ms)" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
63+
FAILURES=$((FAILURES + 1))
3964
cd "$SCRIPT_DIR"
4065
return 1
4166
fi
4267

4368
# Rootfs
4469
printf " [rootfs] running... "
45-
t0=$(date +%s%N)
70+
t0=$(now_ns)
4671
just rootfs < /dev/null >> "$outfile" 2>&1
4772
rc=$?
48-
t1=$(date +%s%N)
73+
t1=$(now_ns)
4974
local rootfs_ms=$(( (t1 - t0) / 1000000 ))
5075
if [ $rc -eq 0 ]; then
51-
echo " ${rootfs_ms}ms" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
76+
echo "ok ${rootfs_ms}ms" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
5277
else
53-
echo "✗ FAILED (exit=$rc, ${rootfs_ms}ms)" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
78+
echo "FAILED (exit=$rc, ${rootfs_ms}ms)" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
79+
FAILURES=$((FAILURES + 1))
5480
cd "$SCRIPT_DIR"
5581
return 1
5682
fi
5783

5884
# Run once (cold start)
5985
printf " [run] running... "
60-
t0=$(date +%s%N)
86+
t0=$(now_ns)
6187
just run < /dev/null >> "$outfile" 2>&1
6288
rc=$?
63-
t1=$(date +%s%N)
89+
t1=$(now_ns)
6490
local run_ms=$(( (t1 - t0) / 1000000 ))
6591
if [ $rc -eq 0 ]; then
66-
echo " ${run_ms}ms" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
92+
echo "ok ${run_ms}ms" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
6793
else
68-
echo "✗ FAILED (exit=$rc, ${run_ms}ms)" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
94+
echo "FAILED (exit=$rc, ${run_ms}ms)" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
95+
FAILURES=$((FAILURES + 1))
6996
fi
7097

71-
# Run repeated (snapshot/restore) if a repeat command exists
98+
# Run repeated (snapshot/restore) -- if a repeat command exists
7299
if [ -n "$repeat_cmd" ]; then
73100
printf " [$repeat_cmd] running... "
74-
t0=$(date +%s%N)
101+
t0=$(now_ns)
75102
just "$repeat_cmd" < /dev/null >> "$outfile" 2>&1
76103
rc=$?
77-
t1=$(date +%s%N)
104+
t1=$(now_ns)
78105
local repeat_ms=$(( (t1 - t0) / 1000000 ))
79106
if [ $rc -eq 0 ]; then
80-
echo " ${repeat_ms}ms" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
107+
echo "ok ${repeat_ms}ms" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
81108
else
82-
echo "✗ FAILED (exit=$rc, ${repeat_ms}ms)" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
109+
echo "FAILED (exit=$rc, ${repeat_ms}ms)" | tee -a "$outfile" | tee -a "$SCRIPT_DIR/$SUMMARY"
110+
FAILURES=$((FAILURES + 1))
83111
fi
84112
echo " TOTAL: build=${build_ms}ms rootfs=${rootfs_ms}ms run=${run_ms}ms ${repeat_cmd}=${repeat_ms}ms" | tee -a "$SCRIPT_DIR/$SUMMARY"
85113
else
@@ -92,9 +120,9 @@ run_example() {
92120

93121
# Examples with their repeat commands (from each Justfile)
94122
run_example "helloworld-c" "run-5"
95-
run_example "rust" "run-5"
123+
run_example "rust" "run-10"
96124
run_example "go" "run-10"
97-
run_example "shell" "run-5"
125+
run_example "shell" "run-10"
98126
run_example "python" "run-10"
99127
run_example "python-tools" "run-10"
100128
run_example "nodejs" "run-10"
@@ -107,7 +135,13 @@ run_example "multifn-c" ""
107135
run_example "python-agent" ""
108136
run_example "networking-py" "run-get"
109137

110-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | tee -a "$SUMMARY"
111-
echo "✅ ALL DONE — $(date)" | tee -a "$SUMMARY"
138+
echo "---" | tee -a "$SUMMARY"
139+
if [ "$FAILURES" -gt 0 ]; then
140+
echo "DONE with $FAILURES failure(s) -- $(date)" | tee -a "$SUMMARY"
141+
else
142+
echo "ALL DONE -- $(date)" | tee -a "$SUMMARY"
143+
fi
112144
echo "Per-example logs: results-<name>.txt"
113145
echo "Summary: $SUMMARY"
146+
147+
exit "$FAILURES"

examples/rust/Justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# rust on Hyperlight
22
#
33
# just run - Run once
4-
# just run-5 - Run 10x (snapshot/restore)
4+
# just run-10 - Run 10x (snapshot/restore)
55
# just rootfs - Build rootfs via Docker (cross-platform)
66
# just build - Build/pull kernel
77
# just clean - Remove build artifacts

0 commit comments

Comments
 (0)