boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

056-shell-fileio.scm (1006B)


      1 ; End-to-end shell + file-IO smoke test for the prelude. Covers the
      2 ; full process-management path (run -> spawn -> sys-clone/sys-execve,
      3 ; sys-wait/decode-wait-status) AND the port abstraction
      4 ; (open-input/refill!/read-all/bv-concat-reverse/close), with string
      5 ; literals carrying paths and argv into the syscall layer.
      6 ;
      7 ; Plan: shell-out a one-line `echo` that writes a known payload to
      8 ; /tmp; wait for the child; reopen the file via the prelude's port API;
      9 ; read the contents back and compare with bytevector=?.
     10 (define path     "/tmp/scheme1-shell-fileio.txt")
     11 (define expected "hello, scheme1!\n")
     12 
     13 (define rc (run "/bin/sh" "-c" "echo 'hello, scheme1!' > /tmp/scheme1-shell-fileio.txt"))
     14 (if (not (car rc))     (sys-exit 10) 0)
     15 (if (not (= (cdr rc) 0)) (sys-exit 20) 0)
     16 
     17 (define op (open-input path))
     18 (if (not (car op)) (sys-exit 30) 0)
     19 (define rd (read-all (cdr op)))
     20 (close (cdr op))
     21 (if (not (car rd)) (sys-exit 40) 0)
     22 
     23 (if (bytevector=? (cdr rd) expected)
     24     (sys-exit 0)
     25     (sys-exit 50))