kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

commit 2a21dd256562d42cba804a07bc2c7a53e2fb891b
parent 306b2919c7c7aea6a5641295b79bb3a9df6b16ba
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Wed, 17 Jun 2026 18:08:58 -0700

Slim tier1 system sentinels

Diffstat:
Mmk/test.mk | 2+-
Mtest/rt/addr2line.sh | 84++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mtest/tier1/cross/run.sh | 2+-
Mtest/tier1/manifests/system/debug-dwarf.txt | 2+-
Mtest/tier1/manifests/system/dist.txt | 6++----
Mtest/tier1/manifests/system/tools.txt | 10++--------
Mtest/tier1/system/README.md | 24+++++++++++++-----------
Mtest/tier1/system/debug-dwarf.sh | 3+++
Atest/tier1/system/dist-kitchen.sh | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtest/tier1/system/dist.sh | 22+++++++++++++++++-----
Atest/tier1/system/driver-kitchen.sh | 110+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atest/tier1/system/tools-kitchen.sh | 106+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtest/tier1/system/tools.sh | 22+++++++++++++++++-----
13 files changed, 429 insertions(+), 37 deletions(-)

diff --git a/mk/test.mk b/mk/test.mk @@ -245,7 +245,7 @@ test-t1-build: @$(T1_LOG) build $(MAKE) --no-print-directory lib bin rt test-t1-driver: - @$(T1_LOG) driver env KIT=$(abspath $(BIN)) sh test/driver/run.sh + @$(T1_LOG) driver env KIT=$(abspath $(BIN)) sh test/tier1/system/driver-kitchen.sh test-t1-core-api: @$(T1_LOG) core-api $(MAKE) --no-print-directory test-hash test-release-index test-abi-classify diff --git a/test/rt/addr2line.sh b/test/rt/addr2line.sh @@ -184,13 +184,95 @@ run_one() { # <arch> <opt> fi } +addr2line_jobs() { + case "${KIT_RT_ADDR2LINE_JOBS:-${KIT_TEST_JOBS:-auto}}" in + ""|1) echo 1 ;; + auto) + n=$(getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1) + case "$n" in ''|*[!0-9]*) n=1 ;; esac + [ "$n" -gt 6 ] && n=6 + [ "$n" -lt 1 ] && n=1 + echo "$n" ;; + *[!0-9]*) + echo "invalid KIT_RT_ADDR2LINE_JOBS=${KIT_RT_ADDR2LINE_JOBS:-${KIT_TEST_JOBS:-auto}}" >&2 + return 2 ;; + *) + n="${KIT_RT_ADDR2LINE_JOBS:-${KIT_TEST_JOBS}}" + [ "$n" -lt 1 ] && n=1 + echo "$n" ;; + esac +} + +running_jobs() { + jobs -pr | wc -l | tr -d '[:space:]' +} + +wait_for_slot() { + max=$1 + while [ "$(running_jobs)" -ge "$max" ]; do + sleep 0.05 + done +} + +replay_events() { + ev=$1 + [ -f "$ev" ] || return 0 + while IFS="$(printf '\t')" read -r kind a b; do + [ -n "$kind" ] || continue + case "$kind" in + PASS) kit_pass "$a" ;; + FAIL) kit_fail "$a" "$b" ;; + SKIP) kit_skip "$a" "$b" ;; + SKIP_NA) kit_skip_na "$a" "$b" ;; + XFAIL) kit_xfail "$a" "$b" ;; + XPASS) kit_xpass "$a" ;; + TIME) kit_time "$a" "$b" ;; + *) kit_fail "addr2line-event" "unknown event kind $kind" ;; + esac + done < "$ev" +} + +parallel_dir="$BUILD_DIR/.parallel.$$" +mkdir -p "$parallel_dir" +order="$parallel_dir/order" +: > "$order" +jobs_max=$(addr2line_jobs) || { + kit_summary test-rt-addr2line + kit_exit +} + for arch in ${KIT_RT_RUNTIME_ARCHES:-aa64 x64 rv64}; do case "$arch" in aa64|x64|rv64) - for opt in ${KIT_RT_OPT_LEVELS:-0 1}; do run_one "$arch" "$opt"; done ;; + for opt in ${KIT_RT_OPT_LEVELS:-0 1}; do + id="$arch-O$opt" + ev="$parallel_dir/$id.ev" + out="$parallel_dir/$id.out" + status="$parallel_dir/$id.status" + printf '%s\t%s\t%s\t%s\n' "$id" "$ev" "$out" "$status" >> "$order" + wait_for_slot "$jobs_max" + ( + KIT_EV="$ev" + export KIT_EV + run_one "$arch" "$opt" > "$out" 2>&1 + printf '%s\n' "$?" > "$status" + ) & + done ;; *) not_ok "$arch" "unknown arch" ;; esac done +wait || true + +while IFS="$(printf '\t')" read -r id ev out status; do + [ -n "$id" ] || continue + cat "$out" 2>/dev/null || true + lane_rc=$(cat "$status" 2>/dev/null || printf '1\n') + if [ "$lane_rc" -ne 0 ]; then + kit_fail "$id" "worker exit=$lane_rc" + fi + replay_events "$ev" +done < "$order" + kit_summary test-rt-addr2line kit_exit diff --git a/test/tier1/cross/run.sh b/test/tier1/cross/run.sh @@ -314,7 +314,7 @@ for arch in aa64 x64 rv64; do enqueue_lane "linux-musl-$arch:static" hosted_lane "linux-musl-$arch" static enqueue_lane "linux-musl-$arch:dynamic" hosted_lane "linux-musl-$arch" dynamic enqueue_lane "linux-musl-$arch:shared" linux_shared_lane "linux-musl-$arch" - enqueue_lane "freebsd-$arch:static" hosted_lane "freebsd-$arch" static + enqueue_lane "freebsd-$arch" hosted_lane "freebsd-$arch" default done for arch in aa64 x64; do diff --git a/test/tier1/manifests/system/debug-dwarf.txt b/test/tier1/manifests/system/debug-dwarf.txt @@ -4,4 +4,4 @@ make:test-dwarf make:test-debug driver:objdump-dwarf/01-dwarf-all driver:dbg/repl-help -driver:addr2line-symbolize +driver:addr2line-symbolize-kitchen diff --git a/test/tier1/manifests/system/dist.txt b/test/tier1/manifests/system/dist.txt @@ -1,4 +1,2 @@ -# Local distribution primitive Tier 1 sentinel targets. -test-driver-cas -test-driver-pkg - +# Local distribution primitive Tier 1 sentinel steps. +tier1:dist-kitchen diff --git a/test/tier1/manifests/system/tools.txt b/test/tier1/manifests/system/tools.txt @@ -1,8 +1,2 @@ -# Cheap driver-tool Tier 1 sentinel targets. -test-driver-ar -test-driver-cpio -test-driver-tools -test-driver-strings -test-driver-objdump -test-driver-objcopy -test-driver-strip +# Cheap driver-tool Tier 1 sentinel steps. +tier1:tools-kitchen diff --git a/test/tier1/system/README.md b/test/tier1/system/README.md @@ -1,8 +1,9 @@ # Tier 1 System Sentinels -These scripts are manifest-driven wrappers around existing cheap make targets or -driver scripts. They are intended to catch broad system regressions quickly -without pulling in cross-provisioning, VM, ecosystem, libc, or release suites. +These scripts are manifest-driven wrappers around dedicated Tier 1 kitchen +sentinels. They are intended to catch broad system regressions quickly without +pulling in full driver corpora, cross-provisioning, VM, ecosystem, libc, or +release suites. Each wrapper redirects command output into `build/test/tier1/logs/system/<area>/` and prints the log path. On failure it @@ -10,19 +11,20 @@ tails the captured log. ## Coverage -- `tools.sh` runs existing cheap tool-driver sentinels: `test-driver-ar` - (`ar`, `ranlib`), `test-driver-cpio`, `test-driver-tools` (`xxd`, `cmp`, - `hash`, `sha256sum`, `b2sum`, `crc32`, `disas`, `mc`, `compress`, `image`), - `test-driver-strings`, `test-driver-objdump`, `test-driver-objcopy`, and - `test-driver-strip`. +- `tools.sh` runs one kitchen fixture over the byte utilities, archive tools, + object inspection/transformation tools, `cpio`, compression, disassembly, + machine-code assembly, and image emission. +- `driver-kitchen.sh` runs one multitool dispatch fixture over `cc`, `check`, + `cpp`, `as`, `ld`, `run`, `install`, `nm`, `size`, and `addr2line`. - `runtime-headers.sh` runs `test-rt-headers` for the triples listed in `manifests/system/runtime-headers.txt`, then checks that every requested smoke object was produced. - `debug-dwarf.sh` runs DWARF reader and debug producer unit targets, one committed `objdump --dwarf` golden, the lightweight `kit dbg` help transcript, - and the `addr2line`/`symbolize` backtrace smoke. -- `dist.sh` runs the local CAS and package driver suites through - `test-driver-cas` and `test-driver-pkg`. + and a single `addr2line`/`symbolize` backtrace lane. +- `dist.sh` runs one CAS/package fixture covering tree add/verify/materialize, + tar.gz verification, kpkg create/inspect/verify/unpack, and one tamper + rejection. ## Deferred diff --git a/test/tier1/system/debug-dwarf.sh b/test/tier1/system/debug-dwarf.sh @@ -97,6 +97,9 @@ run_manifest_step() { sh "$repo_root/test/dbg/run.sh" ;; driver:addr2line-symbolize) run_step addr2line-symbolize make -C "$repo_root" test-rt-backtrace ;; + driver:addr2line-symbolize-kitchen) + run_step addr2line-symbolize env KIT_RT_RUNTIME_ARCHES=aa64 \ + KIT_RT_OPT_LEVELS=1 make -C "$repo_root" test-rt-backtrace ;; *) printf 'tier1/debug-dwarf: unknown manifest step: %s\n' "$step" >&2 return 2 ;; diff --git a/test/tier1/system/dist-kitchen.sh b/test/tier1/system/dist-kitchen.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# Coarse Tier 1 kitchen-sink smoke for CAS and package distribution. + +set -u + +script_dir=$(cd "$(dirname "$0")" && pwd) +repo_root=$(cd "$script_dir/../../.." && pwd) +KIT="${KIT:-$repo_root/build/kit}" + +if [ ! -x "$KIT" ]; then + echo "dist-kitchen: kit binary not found at $KIT" >&2 + exit 2 +fi + +work=$(mktemp -d "${TMPDIR:-/tmp}/kit-t1-dist.XXXXXX") +trap 'rm -rf "$work"' EXIT + +HOME="$work/home" +KIT_TRUSTED_KEYS="$work/trusted_keys" +SOURCE_DATE_EPOCH=1 +export HOME KIT_TRUSTED_KEYS SOURCE_DATE_EPOCH + +KIT_KIT_DIR="$repo_root/test/lib" +. "$repo_root/test/lib/kit_sh_kit.sh" +kit_report_init + +mkdir -p "$work/src/bin" "$work/cas" "$work/out" "$work/pkg" "$work/unpack" +printf 'tier1 package payload\n' > "$work/src/payload.txt" +{ + printf '#!/bin/sh\n' + printf 'printf "tier1 tool\\n"\n' +} > "$work/src/bin/tool.sh" +chmod +x "$work/src/bin/tool.sh" + +run_ok cas-add-tree "$KIT" cas add-tree --cas "$work/cas" --root "$work/src" +tree_id=$(first_hex_id "$work/cas-add-tree.out") +if [ -n "$tree_id" ]; then + ok cas-tree-id +else + echo "could not parse tree id" > "$work/cas-tree-id.diag" + not_ok cas-tree-id "$work/cas-tree-id.diag" +fi +tree_file=$(cas_object_path "$work/cas" tree "$tree_id") +assert_file_exists cas-tree-object "$tree_file" +run_ok cas-verify "$KIT" cas verify-tree --cas "$work/cas" "$tree_id" +run_ok cas-materialize "$KIT" cas materialize --cas "$work/cas" "$tree_id" -C "$work/out/root" +same_file cas-materialize-payload "$work/src/payload.txt" "$work/out/root/payload.txt" +is_executable cas-materialize-exec "$work/out/root/bin/tool.sh" + +run_ok pkg-keygen "$KIT" pkg keygen -o "$work/key" +run_ok pkg-create-targz "$KIT" pkg create --name tier1 --version 1.0.0 \ + --format tar.gz --cas "$work/cas" --tree "$tree_id" \ + -s "$work/key.key" -o "$work/pkg/tier1.tar.gz" +run_ok pkg-verify-targz "$KIT" pkg verify -p "$work/key.pub" "$work/pkg/tier1.tar.gz" + +run_ok pkg-create-kpkg "$KIT" pkg create --name tier1 --version 1.0.0 \ + --format kpkg --compression lz4-block-v1 --cas "$work/cas" --tree "$tree_id" \ + -s "$work/key.key" -o "$work/pkg/tier1.kpkg" +run_ok pkg-inspect-kpkg "$KIT" pkg inspect "$work/pkg/tier1.kpkg" +contains pkg-inspect-name "$work/pkg-inspect-kpkg.out" "name = tier1" +run_ok pkg-verify-kpkg "$KIT" pkg verify -p "$work/key.pub" "$work/pkg/tier1.kpkg" +run_ok pkg-unpack-kpkg "$KIT" pkg unpack --verify -p "$work/key.pub" \ + "$work/pkg/tier1.kpkg" -C "$work/unpack/kpkg" +same_file pkg-unpack-payload "$work/src/payload.txt" "$work/unpack/kpkg/payload.txt" +is_executable pkg-unpack-exec "$work/unpack/kpkg/bin/tool.sh" + +cp "$work/pkg/tier1.kpkg" "$work/pkg/tier1.bad.kpkg" +printf '\377' | dd of="$work/pkg/tier1.bad.kpkg" bs=1 seek=0 count=1 conv=notrunc \ + >/dev/null 2>&1 +run_fail pkg-rejects-tamper "$KIT" pkg verify -p "$work/key.pub" "$work/pkg/tier1.bad.kpkg" + +kit_summary dist-kitchen +kit_exit diff --git a/test/tier1/system/dist.sh b/test/tier1/system/dist.sh @@ -55,11 +55,23 @@ start_step() { printf '%s\t%s\t%s\n' "$id" "$out" "$status" >> "$order" t1_parallel_wait_for_slot "$jobs" ( - if run_step "$target" make -C "$repo_root" "$target" > "$out" 2>&1; then - printf '0\n' > "$status" - else - printf '%s\n' "$?" > "$status" - fi + case "$target" in + tier1:dist-kitchen) + if run_step dist-kitchen env KIT="$repo_root/build/kit" \ + sh "$repo_root/test/tier1/system/dist-kitchen.sh" \ + > "$out" 2>&1; then + printf '0\n' > "$status" + else + printf '%s\n' "$?" > "$status" + fi ;; + *) + if run_step "$target" make -C "$repo_root" "$target" \ + > "$out" 2>&1; then + printf '0\n' > "$status" + else + printf '%s\n' "$?" > "$status" + fi ;; + esac ) & } diff --git a/test/tier1/system/driver-kitchen.sh b/test/tier1/system/driver-kitchen.sh @@ -0,0 +1,110 @@ +#!/bin/sh +# Coarse Tier 1 kitchen-sink smoke for the multitool driver. + +set -u + +script_dir=$(cd "$(dirname "$0")" && pwd) +repo_root=$(cd "$script_dir/../../.." && pwd) +KIT="${KIT:-$repo_root/build/kit}" + +if [ ! -x "$KIT" ]; then + echo "driver-kitchen: kit binary not found at $KIT" >&2 + exit 2 +fi + +work=$(mktemp -d "${TMPDIR:-/tmp}/kit-t1-driver.XXXXXX") +trap 'rm -rf "$work"' EXIT + +KIT_KIT_DIR="$repo_root/test/lib" +. "$repo_root/test/lib/kit_sh_kit.sh" +kit_report_init + +cat > "$work/main.c" <<'SRC' +int helper(int x) { return x + 1; } +int main(void) { return helper(41); } +void _start(void) { (void)main(); for (;;) {} } +SRC + +cat > "$work/bad.c" <<'SRC' +int broken( { return 0; } +SRC + +run_ok cc-dumpmachine "$KIT" cc -target riscv64-linux -dumpmachine +contains cc-dumpmachine-rv64 "$work/cc-dumpmachine.out" "riscv64-linux" + +run_ok cpp-stdout "$KIT" cpp "$work/main.c" +contains cpp-has-helper "$work/cpp-stdout.out" "helper" + +run_ok check-good "$KIT" check "$work/main.c" +run_fail check-bad "$KIT" check "$work/bad.c" +contains check-bad-diagnostic "$work/check-bad.err" "fatal:" + +run_ok cc-object "$KIT" cc -target x86_64-linux -g -c "$work/main.c" \ + -o "$work/main.o" +run_ok cc-emit-ir "$KIT" cc -O1 --emit=ir -c "$work/main.c" \ + -o "$work/main.ir" +contains cc-ir-has-func "$work/main.ir" "func sym#" + +run_ok ld-exe "$KIT" ld -e _start "$work/main.o" -o "$work/main.exe" +is_executable ld-exe-mode "$work/main.exe" +run_ok objdump-private "$KIT" objdump -p "$work/main.exe" +contains objdump-entry "$work/objdump-private.out" "entry point" + +run_ok nm-basic "$KIT" nm "$work/main.o" +contains nm-main "$work/nm-basic.out" "main" +run_ok size-basic "$KIT" size "$work/main.o" +contains size-has-text "$work/size-basic.out" "text" + +helper_addr=$("$KIT" nm "$work/main.o" 2>/dev/null | awk '/ helper$/{print $1; exit}') +if [ -n "$helper_addr" ] && + "$KIT" addr2line -e "$work/main.o" "0x$helper_addr" \ + > "$work/addr2line.out" 2> "$work/addr2line.err" && + grep -q "main.c" "$work/addr2line.out"; then + ok addr2line-basic +else + { printf 'helper_addr=%s\n' "$helper_addr" + sed 's/^/out: /' "$work/addr2line.out" 2>/dev/null + sed 's/^/err: /' "$work/addr2line.err" 2>/dev/null; } \ + > "$work/addr2line.diag" + not_ok addr2line-basic "$work/addr2line.diag" +fi + +cat > "$work/rv64.s" <<'SRC' +.text +.globl rv64_entry +rv64_entry: + li a0, 7 + ret +SRC +run_ok as-rv64 "$KIT" as -target riscv64-linux "$work/rv64.s" \ + -o "$work/rv64.o" +run_ok objdump-rv64 "$KIT" objdump -h "$work/rv64.o" +contains objdump-rv64-format "$work/objdump-rv64.out" "elf64-riscv64" + +cat > "$work/run-main.c" <<'SRC' +int main(void) { return 42; } +SRC +"$KIT" run "$work/run-main.c" > "$work/run.out" 2> "$work/run.err" +run_rc=$? +if [ "$run_rc" -eq 42 ]; then + ok run-exit-status +else + { printf 'exit=%s want=42\n' "$run_rc" + sed 's/^/err: /' "$work/run.err"; } > "$work/run.diag" + not_ok run-exit-status "$work/run.diag" +fi + +inst="$work/inst" +run_ok install-explicit "$KIT" install "$inst" cc nm +assert_file_exists install-cc "$inst/cc" +assert_file_exists install-nm "$inst/nm" +if [ -e "$inst/ld" ]; then + echo "ld installed despite explicit cc nm list" > "$work/install.diag" + not_ok install-explicit-only-listed "$work/install.diag" +else + ok install-explicit-only-listed +fi +run_ok install-dispatch "$inst/cc" --help + +kit_summary driver-kitchen +kit_exit diff --git a/test/tier1/system/tools-kitchen.sh b/test/tier1/system/tools-kitchen.sh @@ -0,0 +1,106 @@ +#!/bin/sh +# Coarse Tier 1 kitchen-sink smoke for driver utility tools. + +set -u + +script_dir=$(cd "$(dirname "$0")" && pwd) +repo_root=$(cd "$script_dir/../../.." && pwd) +KIT="${KIT:-$repo_root/build/kit}" + +if [ ! -x "$KIT" ]; then + echo "tools-kitchen: kit binary not found at $KIT" >&2 + exit 2 +fi + +work=$(mktemp -d "${TMPDIR:-/tmp}/kit-t1-tools.XXXXXX") +trap 'rm -rf "$work"' EXIT + +KIT_KIT_DIR="$repo_root/test/lib" +. "$repo_root/test/lib/kit_sh_kit.sh" +kit_report_init + +printf 'tier1 tools\000bytes\377\n' > "$work/data.bin" +run_ok xxd-dump "$KIT" xxd "$work/data.bin" +run_ok xxd-plain "$KIT" xxd -p "$work/data.bin" +"$KIT" xxd -r "$work/xxd-dump.out" > "$work/data.rt" 2> "$work/xxd-rt.err" +same_file xxd-roundtrip "$work/data.bin" "$work/data.rt" +run_ok cmp-identical "$KIT" cmp "$work/data.bin" "$work/data.rt" +run_fail cmp-different "$KIT" cmp "$work/data.bin" "$work/xxd-plain.out" + +run_ok hash-sha "$KIT" hash -a sha256 "$work/data.bin" +contains hash-sha-output "$work/hash-sha.out" " " +run_ok hash-alias "$KIT" crc32 "$work/data.bin" + +printf 'compressible tier1 payload\n%.0s' 1 2 3 4 5 > "$work/text.txt" +"$KIT" compress -z gzip "$work/text.txt" | "$KIT" compress -d > "$work/text.gzip.rt" 2> "$work/compress-gzip.err" +same_file compress-gzip-roundtrip "$work/text.txt" "$work/text.gzip.rt" +"$KIT" compress -z lz4 "$work/text.txt" | "$KIT" compress -d > "$work/text.lz4.rt" 2> "$work/compress-lz4.err" +same_file compress-lz4-roundtrip "$work/text.txt" "$work/text.lz4.rt" + +run_ok disas-aa64 "$KIT" disas -target aarch64 -x "1f 20 03 d5" +contains disas-aa64-nop "$work/disas-aa64.out" "nop" +run_ok mc-aa64 "$KIT" mc -target aarch64 -p "add x0, x1, x2" +run_ok mc-disas "$KIT" disas -target aarch64 -x "$(cat "$work/mc-aa64.out")" +contains mc-disas-add "$work/mc-disas.out" "add x0, x1, x2" + +cat > "$work/a.c" <<'SRC' +int tier1_a(int x) { return x + 1; } +SRC +cat > "$work/b.c" <<'SRC' +extern int tier1_a(int); +int tier1_b(int x) { return tier1_a(x) + 2; } +SRC +run_ok cc-a "$KIT" cc -target riscv64-linux -g -c "$work/a.c" -o "$work/a.o" +run_ok cc-b "$KIT" cc -target riscv64-linux -g -c "$work/b.c" -o "$work/b.o" +run_ok ar-create "$KIT" ar rcs "$work/libtier1.a" "$work/a.o" "$work/b.o" +run_ok ranlib "$KIT" ranlib "$work/libtier1.a" +run_ok ar-list "$KIT" ar t "$work/libtier1.a" +contains ar-has-a "$work/ar-list.out" "a.o" +contains ar-has-b "$work/ar-list.out" "b.o" + +run_ok objdump-archive "$KIT" objdump -f "$work/libtier1.a" +contains objdump-rv64 "$work/objdump-archive.out" "elf64-riscv64" +run_ok objcopy-rename "$KIT" objcopy --rename-section=.text=.tier1_text \ + "$work/a.o" "$work/a.renamed.o" +run_ok objdump-renamed "$KIT" objdump -h "$work/a.renamed.o" +contains objcopy-renamed-section "$work/objdump-renamed.out" ".tier1_text" +run_ok strip-debug "$KIT" strip --strip-debug "$work/a.o" -o "$work/a.stripped.o" +run_ok objdump-stripped "$KIT" objdump -h "$work/a.stripped.o" +if grep '\.debug_' "$work/objdump-stripped.out" >/dev/null 2>&1; then + not_ok strip-drops-debug "$work/objdump-stripped.out" +else + ok strip-drops-debug +fi + +printf 'abc\000tier1-string\000' > "$work/strings.bin" +run_ok strings-basic "$KIT" strings "$work/strings.bin" +contains strings-finds "$work/strings-basic.out" "tier1-string" + +mkdir -p "$work/payload/root/sub" "$work/ex" +printf 'hello cpio\n' > "$work/payload/root/sub/file.txt" +( cd "$work/payload" && "$KIT" cpio -o -F "$work/root.cpio" root ) \ + > "$work/cpio-create.out" 2> "$work/cpio-create.err" +[ "$?" -eq 0 ] && ok cpio-create || not_ok cpio-create "$work/cpio-create.err" +run_ok cpio-list "$KIT" cpio -t -F "$work/root.cpio" +contains cpio-has-file "$work/cpio-list.out" "root/sub/file.txt" +( cd "$work/ex" && "$KIT" cpio -i -F "$work/root.cpio" ) \ + > "$work/cpio-extract.out" 2> "$work/cpio-extract.err" +[ "$?" -eq 0 ] && ok cpio-extract || not_ok cpio-extract "$work/cpio-extract.err" +same_file cpio-roundtrip "$work/payload/root/sub/file.txt" "$work/ex/root/sub/file.txt" + +cat > "$work/kernel.s" <<'SRC' +.globl _start +.section .text +_start: + ret +.section .rodata + .byte 0x11, 0x22, 0x33, 0x44 +SRC +run_ok image-build "$KIT" build-exe -target x86_64-none-elf -nostdlib \ + -static -no-pie -e _start "$work/kernel.s" -o "$work/kernel.elf" +run_ok image-bin "$KIT" image --format bin "$work/kernel.elf" -o "$work/kernel.bin" +run_ok objcopy-bin "$KIT" objcopy -O binary "$work/kernel.elf" "$work/kernel.objcopy.bin" +same_file image-matches-objcopy "$work/kernel.bin" "$work/kernel.objcopy.bin" + +kit_summary tools-kitchen +kit_exit diff --git a/test/tier1/system/tools.sh b/test/tier1/system/tools.sh @@ -55,11 +55,23 @@ start_step() { printf '%s\t%s\t%s\n' "$id" "$out" "$status" >> "$order" t1_parallel_wait_for_slot "$jobs" ( - if run_step "$target" make -C "$repo_root" "$target" > "$out" 2>&1; then - printf '0\n' > "$status" - else - printf '%s\n' "$?" > "$status" - fi + case "$target" in + tier1:tools-kitchen) + if run_step tools-kitchen env KIT="$repo_root/build/kit" \ + sh "$repo_root/test/tier1/system/tools-kitchen.sh" \ + > "$out" 2>&1; then + printf '0\n' > "$status" + else + printf '%s\n' "$?" > "$status" + fi ;; + *) + if run_step "$target" make -C "$repo_root" "$target" \ + > "$out" 2>&1; then + printf '0\n' > "$status" + else + printf '%s\n' "$?" > "$status" + fi ;; + esac ) & }