Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/scripts/qemu_ck_pipe_test.sh # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / scripts / qemu_ck_pipe_test.sh` 108 lines ยท 6579 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # AIENOS_CK_PIPE gate (AIENOS-NATIVE-PIPE-1, aienos-mv#428): the native pipe primitive (native/kernel/core/pipe.c) driven 3 # from inside the C kernel. A TEST-ONLY image (make CK_PIPE_TEST=1, refused with CK_HARDWARE_STAGING) runs 4 # core/pipe_test.c after "kernel: alive": a producer and a consumer task, step functions interleaved by the kernel's 5 # run-queue scheduler, each holding one pipe end in its own capability table, then the negative cases. The boot then 6 # goes on as usual to its report and PSCI reset. 7 # 8 # Label: QEMU (aarch64 virt), TEST build, not physical. Nothing here ran on a Spark or any real machine; a PASS 9 # qualifies nothing physical. 10 # Checks (one boot): 11 # payload_nul_byte_for_byte 160 KiB with every fifth byte NUL arrives byte for byte, no temporary file 12 # backpressure_would_block a slow consumer fills the 64 KiB pipe; the producer sees WOULD_BLOCK 13 # eof_after_last_writer the consumer reads EOF (0 bytes, OK) after the producer closes 14 # bounded_memory never more than the pipe capacity buffered 15 # blocking_wait_wake_through_scheduler the blocking variant parks and is woken through the scheduler 16 # broken_pipe_no_reader write with no reader -> BROKEN_PIPE, no bytes 17 # revoked_write_refused_no_bytes_after write after revoke -> REVOKED, nothing delivered after it 18 # revoke_midstream_no_data_after the consumer revokes mid-transfer; no read succeeds afterwards 19 # stale_handle_after_close a closed handle stays STALE after its slot is reused 20 # unknown_op_not_supported unknown op / other ABI version -> NOT_SUPPORTED before any effect 21 # cancel_interrupts_once cancel -> INTERRUPTED once with no byte moved 22 # every check: both capability tables and the pipe pool empty afterwards (tables_empty=1). 23 # Last line: AIENOS_CK_PIPE: PASS|FAIL|NOT_RUN. 24 set -euo pipefail 25 26 repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" 27 cd "${repo_root}" 28 verdict=AIENOS_CK_PIPE 29 code_fd="${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}" 30 vars_fd="${AAVMF_VARS:-/usr/share/AAVMF/AAVMF_VARS.fd}" 31 command -v qemu-system-aarch64 >/dev/null || { echo "qemu-system-aarch64 not installed"; echo "${verdict}: NOT_RUN"; exit 2; } 32 [[ -r "${code_fd}" && -r "${vars_fd}" ]] || { echo "AAVMF firmware not found"; echo "${verdict}: NOT_RUN"; exit 2; } 33 34 cross="" 35 if [ "$(uname -m)" != "aarch64" ]; then cross="aarch64-linux-gnu-"; fi 36 commit="$(git rev-parse HEAD 2>/dev/null || echo unknown)" 37 out="${AIENOS_CK_OUT_PIPE:-${repo_root}/target/native-kernel-test-pipe}" 38 make -s -C native/kernel CROSS="${cross}" OUT="${out}" AIENOS_COMMIT="${commit}" CK_PIPE_TEST=1 >/dev/null 39 40 # Machine quiet flag (read only) and the QEMU gate lock (one gate at a time): 41 # scripts/lib_gate_hold.sh (aienos#278). 42 . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib_gate_hold.sh" 43 if ! gh_quiet_check || ! gh_lock_take qemu_ck_pipe_test "${AIENOS_GATE_MINUTES:-60}"; then 44 echo "NOT_RUN ${gh_why}" 45 echo "${verdict}: NOT_RUN" 46 exit 3 47 fi 48 # Release only this run's own gate lock record, at most once. 49 release_flag() { gh_lock_release; } 50 work="$(mktemp -d)" 51 cleanup() { rm -rf "${work}"; release_flag; } 52 trap cleanup EXIT 53 mkdir -p "${work}/esp/EFI/BOOT" "${work}/esp/EFI/AIENOS" 54 touch "${work}/esp/EFI/AIENOS/BOOTREPORT.TXT" 55 cp "${out}/BOOTAA64.EFI" "${work}/esp/EFI/BOOT/BOOTAA64.EFI" 56 cp "${vars_fd}" "${work}/vars.fd" 57 log="${work}/serial.log" 58 59 started=$(date +%s) 60 set +e 61 timeout "${AIENOS_QEMU_TIMEOUT:-300}" qemu-system-aarch64 \ 62 -M virt,virtualization=on,gic-version=3 -accel tcg,thread=single -cpu max -smp 4 -m 2048 \ 63 -drive if=pflash,format=raw,readonly=on,file="${code_fd}" \ 64 -drive if=pflash,format=raw,file="${work}/vars.fd" \ 65 -drive if=none,id=esp,format=raw,file=fat:rw:"${work}/esp" \ 66 -device virtio-blk-pci,drive=esp \ 67 -device ramfb -display none -nic none \ 68 -serial file:"${log}" -no-reboot 69 qemu_status=$? 70 set -e 71 elapsed=$(( $(date +%s) - started )) 72 release_flag 73 74 serial="${work}/serial.txt" 75 tr -d '\r' <"${log}" >"${serial}" 76 [[ -z "${AIENOS_LOG_DIR:-}" ]] || cp "${serial}" "${AIENOS_LOG_DIR}/qemu_ck_pipe_serial.log" 77 failed=0 78 pass() { echo "PASS $1"; } 79 fail() { echo "FAIL $1"; failed=1; } 80 has() { grep -qE -- "$2" "$1"; } 81 check() { if has "${serial}" "$2"; then pass "$1"; else fail "$1"; fi; } 82 echo "qemu exit ${qemu_status} after ${elapsed} s (commit ${commit:0:12})" 83 [[ "${qemu_status}" == 0 ]] && pass "QEMU exit status 0 (PSCI reset)" || fail "QEMU exit status ${qemu_status} (124 = timeout)" 84 85 label='QEMU \(aarch64 virt\), TEST build, not physical' 86 check "left firmware and entered the kernel" "kernel: alive" 87 check "the image announces the TEST-ONLY pipe self-test" "^pipe_test: TEST-ONLY pipe self-test begin abi_version=1 capacity=65536 pool_pipes=4 payload=163840; ${label}\$" 88 for c in payload_nul_byte_for_byte backpressure_would_block eof_after_last_writer bounded_memory \ 89 blocking_wait_wake_through_scheduler broken_pipe_no_reader revoked_write_refused_no_bytes_after \ 90 revoke_midstream_no_data_after stale_handle_after_close unknown_op_not_supported cancel_interrupts_once; do 91 check "${c}" "^pipe_check: name=${c} result=PASS tables_empty=1; ${label}\$" 92 done 93 check "payload detail: all 163840 bytes, NUL bytes counted, zero mismatches" "^pipe_detail: nonblocking bytes=163840 sent=163840 nul=[1-9][0-9]* expected_nul=[1-9][0-9]* mismatches=0 would_block=[1-9]" 94 check "blocking detail: waits and wakeups observed" "^pipe_detail: blocking bytes=163840 .* waits=[1-9][0-9]* wakeups=[1-9]" 95 check "revoked write refused, zero bytes delivered" "^pipe_detail: revoked write=REVOKED n=0 read=REVOKED n=0 bytes_delivered=0\$" 96 check "broken pipe detail" "^pipe_detail: broken_pipe write_after_reader_close=BROKEN_PIPE n=0\$" 97 check "self-test summary: 11 checks, 0 failed" "^pipe_test: done checks=11 failed=0 capacity=65536 pool_pipes=4; ${label}\$" 98 if has "${serial}" "^pipe_check: .* result=FAIL"; then fail "no pipe check failed"; else pass "no pipe check failed"; fi 99 check "the boot went on to its report" "report_kind: final" 100 if has "${serial}" "report_kind: (panic|fault)"; then fail "panic or fault reported"; else pass "no kernel panic or fault report"; fi 101 102 if [[ "${failed}" != 0 || -n "${AIENOS_QEMU_VERBOSE:-}" ]]; then 103 echo "---- serial console (pipe lines) ----" 104 grep -E "^(pipe_|kernel: alive|report_kind|panic)" "${serial}" || true 105 fi 106 [[ "${failed}" == 0 ]] && { echo "${verdict}: PASS"; exit 0; } 107 echo "${verdict}: FAIL" 108 exit 1