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
14 changes: 14 additions & 0 deletions .github/workflows/nightly-harnesses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ jobs:
make -j"$(nproc)" kernel.elf
file kernel.elf

# 51 harnesses copy disk.img to a scratch path and exit 2 without it. It
# is an untracked, gitignored 128 MB binary that had only ever been made
# by hand on one machine, so it simply did not exist on a runner: the
# first full nightly run lost most of the suite to "disk.img not found",
# which reads as a wall of kernel failures rather than a missing fixture.
#
# The fixture it copies in (userspace/info.elf.signed -- the 14144 bytes
# verify-fsyscalls.sh asserts on) is TRACKED, so this needs nothing from
# the build and the ordering here is not load-bearing.
- name: Build the FAT32 disk.img that the harnesses mount as drive C
run: |
bash tools/make-disk-img.sh
ls -l disk.img

- name: Run the suite
run: |
bash verify/run-all.sh
Expand Down
98 changes: 98 additions & 0 deletions tools/make-disk-img.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/env bash
#==============================================================================
# make-disk-img.sh -- build the FAT32 `disk.img` the harness suite needs for C:.
#
# WHY THIS EXISTS
#
# 51 of the harnesses in verify/ reference disk.img, copying it to a scratch
# path and exiting 2 if it is missing. Nothing in the repo built it: it was an
# untracked, gitignored artifact that existed only on the machine where it had
# once been made by hand. That is invisible locally -- the file is just there
# -- and fatal anywhere else. The first full nightly run lost most of the suite
# to "disk.img not found", which reads as a wall of kernel failures.
#
# It is NOT committed to git: a 128 MB binary in a repo, ~99.99% of it zeroes,
# to hold one 14 KB file that is already tracked. Generating it takes under a
# second; storing it does not.
#
# WHAT THE HARNESSES ACTUALLY REQUIRE
#
# 1. A REAL FAT32 volume. verify-ring3-fatls.sh checks the FAT32 signature at
# offset 0x52 and refuses a zeroed image, because against one C: would not
# mount and `ls C:/` would fail for a reason unrelated to what it tests --
# a vacuous run that scores as a kernel bug.
#
# 2. C:/HELLO.ELF, 14144 bytes. userspace/fileio.c opens it O_RDONLY and
# lseeks to SEEK_END; verify-fsyscalls.sh asserts the result is EXACTLY
# 14144, so the size is load-bearing. It is never executed -- only read --
# so this is a size-and-content fixture, not a runnable binary.
#
# We use info.elf.signed, which is 14144 bytes. Do NOT substitute
# hello.elf.signed just because the names match: it is 14388 bytes and
# would fail that assertion. (The hand-made image had a stale 14144-byte
# HELLO.ELF from an older signing run, which is why the name never
# matched its content.)
#
# Idempotent: rebuilds from scratch every time, so a corrupted image is fixed
# by re-running rather than debugged.
#==============================================================================
set -euo pipefail
cd "$(dirname "$0")/.."

OUT="${1:-disk.img}"
FIXTURE="userspace/info.elf.signed"
FIXTURE_SIZE=14144

command -v mformat >/dev/null 2>&1 || {
echo "ERROR: mformat not found (install mtools: brew install mtools / apt-get install mtools)" >&2
exit 1
}

# The fixture is tracked in git, so a checkout has it. If it is missing, say so
# rather than silently producing an image without the one file C: must contain.
if [ ! -f "$FIXTURE" ]; then
echo "ERROR: $FIXTURE not found (it is tracked -- is this a full checkout?)" >&2
exit 1
fi

# Assert the size the harness hardcodes. If signing ever changes it, fail HERE
# with the real reason rather than 800 s later inside verify-fsyscalls.sh as a
# confusing "SEEK_END reported N, expected 14144".
actual=$(wc -c < "$FIXTURE" | tr -d ' ')
if [ "$actual" -ne "$FIXTURE_SIZE" ]; then
echo "ERROR: $FIXTURE is $actual bytes, but verify-fsyscalls.sh asserts" >&2
echo " C:/HELLO.ELF is exactly $FIXTURE_SIZE. Update both together." >&2
exit 1
fi

echo "==> Creating 128 MB FAT32 image: $OUT"
rm -f "$OUT"
# bs=1M, not 1m: GNU dd rejects the lowercase suffix outright, and BSD dd
# accepts both. The suite used 1m and died on every Linux runner.
dd if=/dev/zero of="$OUT" bs=1M count=128 status=none

# Geometry matches the original hand-made image: 63 sectors/track, 16 heads,
# 2 sectors/cluster, 32 reserved. -F forces FAT32 (mformat would otherwise
# pick FAT16 at this size, and the driver under test is the FAT32 one).
mformat -i "$OUT" -F -T 262144 -h 16 -s 63 -c 2 -R 32 ::

mcopy -i "$OUT" "$FIXTURE" ::HELLO.ELF

# INFO.ELF was also present in the hand-made image. No harness or userspace
# source opens it -- the only two mentions in the tree are a usage example in
# qemu_typist.py and a comment in verify-exec-frame-leak.sh warning NOT to use
# it (it is a larger image and would move that harness's expected page count).
# Included anyway so the generated image is a faithful replacement rather than
# a subset, which keeps "it worked before" from meaning something different.
mcopy -i "$OUT" "$FIXTURE" ::INFO.ELF

# Verify what we produced rather than trusting mformat's exit code: check the
# same FAT32 signature verify-ring3-fatls.sh checks, and read the file back.
if ! dd if="$OUT" bs=1 skip=82 count=8 status=none | grep -q "FAT32"; then
echo "ERROR: produced image has no FAT32 signature at 0x52" >&2
exit 1
fi
back=$(mdir -i "$OUT" ::HELLO.ELF 2>/dev/null | grep -c "HELLO" || true)
[ "$back" -ge 1 ] || { echo "ERROR: HELLO.ELF not readable back from $OUT" >&2; exit 1; }

echo "==> OK: $OUT ($(wc -c < "$OUT" | tr -d ' ') bytes), C:/HELLO.ELF = $FIXTURE_SIZE bytes"
2 changes: 1 addition & 1 deletion verify/auto-verify-exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ i686-elf-grub-mkrescue -o "$ISO" iso >/dev/null 2>&1
echo "==> Fresh BLANK disk (forces first-boot password setup)"
rm -f "$RUN_DISK" "$SERIAL" "$TRACE" "$MON_SOCK"
# 128 MiB zeroed image, same geometry as disk.img
dd if=/dev/zero of="$RUN_DISK" bs=1m count=128 status=none
dd if=/dev/zero of="$RUN_DISK" bs=1M count=128 status=none

echo "==> Launching headless QEMU (monitor on $MON_SOCK)"
qemu-system-i386 -cpu Broadwell,+rdrand,+rdseed -cdrom "$ISO" \
Expand Down
2 changes: 1 addition & 1 deletion verify/verify-argv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ i686-elf-grub-mkrescue -o "$ISO" iso >/dev/null 2>&1

echo "==> Fresh BLANK disk (forces first-boot password setup)"
rm -f "$RUN_DISK" "$SERIAL" "$TRACE" "$MON_SOCK"
dd if=/dev/zero of="$RUN_DISK" bs=1m count=128 status=none
dd if=/dev/zero of="$RUN_DISK" bs=1M count=128 status=none

echo "==> Launching headless QEMU (monitor on $MON_SOCK)"
qemu-system-i386 -cpu Broadwell,+rdrand,+rdseed -cdrom "$ISO" \
Expand Down
2 changes: 1 addition & 1 deletion verify/verify-bgjobs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ i686-elf-grub-mkrescue -o "$ISO" iso >/dev/null 2>&1

echo "==> Fresh BLANK disk (forces first-boot password setup)"
rm -f "$RUN_DISK" "$SERIAL" "$TRACE" "$MON_SOCK"
dd if=/dev/zero of="$RUN_DISK" bs=1m count=128 status=none
dd if=/dev/zero of="$RUN_DISK" bs=1M count=128 status=none

echo "==> Launching headless QEMU (monitor on $MON_SOCK)"
qemu-system-i386 -cpu Broadwell,+rdrand,+rdseed -cdrom "$ISO" \
Expand Down
2 changes: 1 addition & 1 deletion verify/verify-chmod-owner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ cp kernel.elf iso/boot/kernel.elf
i686-elf-grub-mkrescue -o "$ISO" iso >/dev/null 2>&1 || { echo "FAIL: ISO"; exit 2; }

rm -f "$RUN_DISK" "$SERIAL" "$MON_SOCK"
dd if=/dev/zero of="$RUN_DISK" bs=1m count=128 status=none
dd if=/dev/zero of="$RUN_DISK" bs=1M count=128 status=none

qemu-system-i386 -cpu Broadwell,+rdrand,+rdseed -cdrom "$ISO" \
-boot d -m 256M \
Expand Down
2 changes: 1 addition & 1 deletion verify/verify-ids-spray.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ run_case() {
rm -f "$serial"
mon=$(mktemp -u /tmp/tinyos-spray-mon.XXXXXX)
disk=$(mktemp -u /tmp/tinyos-spray-disk.XXXXXX)
dd if=/dev/zero of="$disk" bs=1m count=16 >/dev/null 2>&1
dd if=/dev/zero of="$disk" bs=1M count=16 >/dev/null 2>&1

qemu-system-i386 -cpu Broadwell,+rdrand,+rdseed -cdrom "$ISO" \
-boot d -m 256M \
Expand Down
2 changes: 1 addition & 1 deletion verify/verify-pipes-exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ i686-elf-grub-mkrescue -o "$ISO" iso >/dev/null 2>&1

echo "==> Fresh BLANK disk (forces first-boot password setup)"
rm -f "$RUN_DISK" "$SERIAL" "$TRACE" "$MON_SOCK"
dd if=/dev/zero of="$RUN_DISK" bs=1m count=128 status=none
dd if=/dev/zero of="$RUN_DISK" bs=1M count=128 status=none

echo "==> Launching headless QEMU (monitor on $MON_SOCK)"
qemu-system-i386 -cpu Broadwell,+rdrand,+rdseed -cdrom "$ISO" \
Expand Down
2 changes: 1 addition & 1 deletion verify/verify-pipes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ i686-elf-grub-mkrescue -o "$ISO" iso >/dev/null 2>&1

echo "==> Fresh BLANK disk (forces first-boot password setup)"
rm -f "$RUN_DISK" "$SERIAL" "$TRACE" "$MON_SOCK"
dd if=/dev/zero of="$RUN_DISK" bs=1m count=128 status=none
dd if=/dev/zero of="$RUN_DISK" bs=1M count=128 status=none

echo "==> Launching headless QEMU (monitor on $MON_SOCK)"
qemu-system-i386 -cpu Broadwell,+rdrand,+rdseed -cdrom "$ISO" \
Expand Down
2 changes: 1 addition & 1 deletion verify/verify-redirect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ i686-elf-grub-mkrescue -o "$ISO" iso >/dev/null 2>&1

echo "==> Fresh BLANK disk (forces first-boot password setup)"
rm -f "$RUN_DISK" "$SERIAL" "$TRACE" "$MON_SOCK"
dd if=/dev/zero of="$RUN_DISK" bs=1m count=128 status=none
dd if=/dev/zero of="$RUN_DISK" bs=1M count=128 status=none

echo "==> Launching headless QEMU (monitor on $MON_SOCK)"
qemu-system-i386 -cpu Broadwell,+rdrand,+rdseed -cdrom "$ISO" \
Expand Down
2 changes: 1 addition & 1 deletion verify/verify-ring3-fileops.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ i686-elf-grub-mkrescue -o "$ISO" iso >/dev/null 2>&1 || { echo "FAIL: ISO"; exit

echo "==> Fresh BLANK disk (forces first-boot password setup)"
rm -f "$RUN_DISK" "$SERIAL" "$TRACE" "$MON_SOCK"
dd if=/dev/zero of="$RUN_DISK" bs=1m count=128 status=none
dd if=/dev/zero of="$RUN_DISK" bs=1M count=128 status=none

echo "==> Launching headless QEMU"
qemu-system-i386 -cpu Broadwell,+rdrand,+rdseed -cdrom "$ISO" \
Expand Down
2 changes: 1 addition & 1 deletion verify/verify-sectest-redirect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ echo "==> Guard: scheduler_stats() prints only outside its critical section"

echo "==> Fresh BLANK disk (forces first-boot password setup)"
rm -f "$RUN_DISK" "$SERIAL" "$TRACE" "$MON_SOCK"
dd if=/dev/zero of="$RUN_DISK" bs=1m count=128 status=none
dd if=/dev/zero of="$RUN_DISK" bs=1M count=128 status=none

echo "==> Launching headless QEMU (monitor on $MON_SOCK)"
qemu-system-i386 -cpu Broadwell,+rdrand,+rdseed -cdrom "$ISO" \
Expand Down
2 changes: 1 addition & 1 deletion verify/verify-shell-history-logout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ cp kernel.elf iso/boot/kernel.elf
i686-elf-grub-mkrescue -o "$ISO" iso >/dev/null 2>&1 || guard_fail "mkrescue failed"

rm -f "$RUN_DISK" "$SERIAL" "$MON_SOCK"
dd if=/dev/zero of="$RUN_DISK" bs=1m count=128 status=none
dd if=/dev/zero of="$RUN_DISK" bs=1M count=128 status=none

echo "==> Launching headless QEMU..."
qemu-system-i386 -cpu Broadwell,+rdrand,+rdseed -cdrom "$ISO" \
Expand Down
2 changes: 1 addition & 1 deletion verify/verify-spawn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ i686-elf-grub-mkrescue -o "$ISO" iso >/dev/null 2>&1

echo "==> Fresh BLANK disk (forces first-boot password setup)"
rm -f "$RUN_DISK" "$SERIAL" "$TRACE" "$MON_SOCK"
dd if=/dev/zero of="$RUN_DISK" bs=1m count=128 status=none
dd if=/dev/zero of="$RUN_DISK" bs=1M count=128 status=none

echo "==> Launching headless QEMU (monitor on $MON_SOCK)"
qemu-system-i386 -cpu Broadwell,+rdrand,+rdseed -cdrom "$ISO" \
Expand Down
2 changes: 1 addition & 1 deletion verify/verify-syscall-reject-counters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ cp kernel.elf iso/boot/kernel.elf
i686-elf-grub-mkrescue -o "$ISO" iso >/dev/null 2>&1 || guard_fail "mkrescue failed"

rm -f "$RUN_DISK" "$SERIAL" "$MON_SOCK"
dd if=/dev/zero of="$RUN_DISK" bs=1m count=128 status=none
dd if=/dev/zero of="$RUN_DISK" bs=1M count=128 status=none

echo "==> Launching headless QEMU..."
qemu-system-i386 -cpu Broadwell,+rdrand,+rdseed -cdrom "$ISO" \
Expand Down
2 changes: 1 addition & 1 deletion verify/verify-sysredirect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ echo "==> Guard: cmd_mem makes $mem_calls stream_printf call(s) in kernel.elf"

echo "==> Fresh BLANK disk (forces first-boot password setup)"
rm -f "$RUN_DISK" "$SERIAL" "$TRACE" "$MON_SOCK"
dd if=/dev/zero of="$RUN_DISK" bs=1m count=128 status=none
dd if=/dev/zero of="$RUN_DISK" bs=1M count=128 status=none

echo "==> Launching headless QEMU (monitor on $MON_SOCK)"
qemu-system-i386 -cpu Broadwell,+rdrand,+rdseed -cdrom "$ISO" \
Expand Down
Loading