kit

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

run.sh (19416B)


      1 #!/bin/sh
      2 # Driver-level checks for `kit run` Wasm sandbox CLI behavior.
      3 
      4 set -u
      5 
      6 script_dir=$(cd "$(dirname "$0")" && pwd)
      7 repo_root=$(cd "$script_dir/../.." && pwd)
      8 
      9 KIT="${KIT:-$repo_root/build/kit}"
     10 
     11 if [ ! -x "$KIT" ]; then
     12     echo "driver-wasm: kit binary not found at $KIT" >&2
     13     exit 2
     14 fi
     15 
     16 work=$(mktemp -d "${TMPDIR:-/tmp}/kit-driver-wasm-test.XXXXXX")
     17 trap 'rm -rf "$work"' EXIT
     18 
     19 KIT_KIT_DIR="$repo_root/test/lib"
     20 . "$repo_root/test/lib/kit_sh_kit.sh"
     21 kit_report_init
     22 
     23 cat > "$work/return0.wat" <<'WAT'
     24 (module
     25   (func (export "test_main") (result i32)
     26     i32.const 0))
     27 WAT
     28 
     29 cat > "$work/host_add.wat" <<'WAT'
     30 (module
     31   (import "env" "host_add" (func $host_add (param i32 i32) (result i32)))
     32   (func (export "test_main") (result i32)
     33     i32.const 21
     34     i32.const 21
     35     call $host_add
     36     i32.const 42
     37     i32.sub))
     38 WAT
     39 
     40 cat > "$work/memory_2page_max.wat" <<'WAT'
     41 (module
     42   (memory 1 2)
     43   (func (export "test_main") (result i32)
     44     i32.const 0))
     45 WAT
     46 
     47 cat > "$work/memory_one.wat" <<'WAT'
     48 (module
     49   (memory 1)
     50   (func (export "test_main") (result i32)
     51     i32.const 0))
     52 WAT
     53 
     54 cat > "$work/wasi_exit.wat" <<'WAT'
     55 (module
     56   (import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (param i32)))
     57   (func (export "test_main") (result i32)
     58     i32.const 7
     59     call $proc_exit
     60     i32.const 0))
     61 WAT
     62 
     63 # proc_exit is _Noreturn: real toolchains (wasi-libc) emit `unreachable` right
     64 # after the call. proc_exit must unwind out of the guest rather than return into
     65 # that `unreachable` and trap the process. (Regression: previously SIGTRAPped.)
     66 cat > "$work/wasi_exit_unreachable.wat" <<'WAT'
     67 (module
     68   (import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (param i32)))
     69   (func (export "test_main") (result i32)
     70     i32.const 9
     71     call $proc_exit
     72     unreachable))
     73 WAT
     74 
     75 cat > "$work/wasi_stdout.wat" <<'WAT'
     76 (module
     77   (import "wasi_snapshot_preview1" "fd_write"
     78     (func $fd_write (param i32 i32 i32 i32) (result i32)))
     79   (memory 1)
     80   (data (i32.const 0) "\08\00\00\00\0b\00\00\00")
     81   (data (i32.const 8) "hello wasi\0a")
     82   (func (export "test_main") (result i32)
     83     i32.const 1
     84     i32.const 0
     85     i32.const 1
     86     i32.const 20
     87     call $fd_write
     88     i32.const 0
     89     i32.ne))
     90 WAT
     91 
     92 cat > "$work/wasi_env.wat" <<'WAT'
     93 (module
     94   (import "wasi_snapshot_preview1" "environ_sizes_get"
     95     (func $sizes (param i32 i32) (result i32)))
     96   (import "wasi_snapshot_preview1" "environ_get"
     97     (func $get (param i32 i32) (result i32)))
     98   (memory 1)
     99   (func (export "test_main") (result i32)
    100     (local $err i32)
    101     (local $p i32)
    102     i32.const 0
    103     i32.const 4
    104     call $sizes
    105     local.set $err
    106     (if (i32.ne (local.get $err) (i32.const 0))
    107       (then (return (local.get $err))))
    108     (if (i32.ne (i32.load (i32.const 0)) (i32.const 1))
    109       (then (return (i32.const 10))))
    110     i32.const 8
    111     i32.const 64
    112     call $get
    113     local.set $err
    114     (if (i32.ne (local.get $err) (i32.const 0))
    115       (then (return (local.get $err))))
    116     i32.const 8
    117     i32.load
    118     local.set $p
    119     (if (i32.ne (i32.load8_u (local.get $p)) (i32.const 75))
    120       (then (return (i32.const 11))))
    121     (if (i32.ne (i32.load8_u offset=13 (local.get $p)) (i32.const 61))
    122       (then (return (i32.const 12))))
    123     (if (i32.ne (i32.load8_u offset=14 (local.get $p)) (i32.const 111))
    124       (then (return (i32.const 13))))
    125     i32.const 0))
    126 WAT
    127 
    128 cat > "$work/wasi_args.wat" <<'WAT'
    129 (module
    130   (import "wasi_snapshot_preview1" "args_sizes_get"
    131     (func $sizes (param i32 i32) (result i32)))
    132   (import "wasi_snapshot_preview1" "args_get"
    133     (func $get (param i32 i32) (result i32)))
    134   (memory 1)
    135   (func (export "test_main") (result i32)
    136     (local $err i32)
    137     (local $p i32)
    138     i32.const 0
    139     i32.const 4
    140     call $sizes
    141     local.set $err
    142     (if (i32.ne (local.get $err) (i32.const 0))
    143       (then (return (local.get $err))))
    144     (if (i32.ne (i32.load (i32.const 0)) (i32.const 2))
    145       (then (return (i32.const 20))))
    146     i32.const 8
    147     i32.const 64
    148     call $get
    149     local.set $err
    150     (if (i32.ne (local.get $err) (i32.const 0))
    151       (then (return (local.get $err))))
    152     i32.const 12
    153     i32.load
    154     local.set $p
    155     (if (i32.ne (i32.load8_u (local.get $p)) (i32.const 97))
    156       (then (return (i32.const 21))))
    157     (if (i32.ne (i32.load8_u offset=4 (local.get $p)) (i32.const 97))
    158       (then (return (i32.const 22))))
    159     i32.const 0))
    160 WAT
    161 
    162 cat > "$work/wasi_runtime_caps.wat" <<'WAT'
    163 (module
    164   (import "wasi_snapshot_preview1" "random_get"
    165     (func $random_get (param i32 i32) (result i32)))
    166   (import "wasi_snapshot_preview1" "clock_time_get"
    167     (func $clock_time_get (param i32 i64 i32) (result i32)))
    168   (import "wasi_snapshot_preview1" "fd_prestat_get"
    169     (func $fd_prestat_get (param i32 i32) (result i32)))
    170   (import "wasi_snapshot_preview1" "fd_prestat_dir_name"
    171     (func $fd_prestat_dir_name (param i32 i32 i32) (result i32)))
    172   (memory 1)
    173   (func (export "test_main") (result i32)
    174     (local $err i32)
    175     i32.const 64
    176     i32.const 16
    177     call $random_get
    178     local.set $err
    179     (if (i32.ne (local.get $err) (i32.const 0))
    180       (then (return (i32.const 41))))
    181     i32.const 1
    182     i64.const 0
    183     i32.const 96
    184     call $clock_time_get
    185     local.set $err
    186     (if (i32.ne (local.get $err) (i32.const 0))
    187       (then (return (i32.const 42))))
    188     i32.const 3
    189     i32.const 128
    190     call $fd_prestat_get
    191     local.set $err
    192     (if (i32.ne (local.get $err) (i32.const 0))
    193       (then (return (i32.const 43))))
    194     (if (i32.ne (i32.load (i32.const 132)) (i32.const 8))
    195       (then (return (i32.const 44))))
    196     i32.const 3
    197     i32.const 160
    198     i32.const 8
    199     call $fd_prestat_dir_name
    200     local.set $err
    201     (if (i32.ne (local.get $err) (i32.const 0))
    202       (then (return (i32.const 45))))
    203     (if (i32.ne (i32.load8_u (i32.const 160)) (i32.const 47))
    204       (then (return (i32.const 46))))
    205     (if (i32.ne (i32.load8_u offset=1 (i32.const 160)) (i32.const 115))
    206       (then (return (i32.const 47))))
    207     i32.const 0))
    208 WAT
    209 
    210 cat > "$work/wasi_fs_read.wat" <<'WAT'
    211 (module
    212   (import "wasi_snapshot_preview1" "path_open"
    213     (func $path_open
    214       (param i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i32)))
    215   (import "wasi_snapshot_preview1" "fd_read"
    216     (func $fd_read (param i32 i32 i32 i32) (result i32)))
    217   (import "wasi_snapshot_preview1" "fd_close"
    218     (func $fd_close (param i32) (result i32)))
    219   (memory 1)
    220   (data (i32.const 0) "\80\00\00\00\05\00\00\00")
    221   (data (i32.const 64) "hello.txt")
    222   (func (export "test_main") (result i32)
    223     (local $fd i32)
    224     (local $err i32)
    225     i32.const 3
    226     i32.const 0
    227     i32.const 64
    228     i32.const 9
    229     i32.const 0
    230     i64.const 0
    231     i64.const 0
    232     i32.const 0
    233     i32.const 16
    234     call $path_open
    235     local.set $err
    236     (if (i32.ne (local.get $err) (i32.const 0))
    237       (then (return (local.get $err))))
    238     i32.const 16
    239     i32.load
    240     local.set $fd
    241     local.get $fd
    242     i32.const 0
    243     i32.const 1
    244     i32.const 20
    245     call $fd_read
    246     local.set $err
    247     (if (i32.ne (local.get $err) (i32.const 0))
    248       (then (return (local.get $err))))
    249     (if (i32.ne (i32.load (i32.const 20)) (i32.const 5))
    250       (then (return (i32.const 30))))
    251     (if (i32.ne (i32.load8_u (i32.const 128)) (i32.const 104))
    252       (then (return (i32.const 31))))
    253     (if (i32.ne (i32.load8_u offset=4 (i32.const 128)) (i32.const 111))
    254       (then (return (i32.const 32))))
    255     local.get $fd
    256     call $fd_close
    257     drop
    258     i32.const 0))
    259 WAT
    260 
    261 cat > "$work/wasi_seek.wat" <<'WAT'
    262 (module
    263   (import "wasi_snapshot_preview1" "path_open"
    264     (func $path_open (param i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i32)))
    265   (import "wasi_snapshot_preview1" "fd_read"
    266     (func $fd_read (param i32 i32 i32 i32) (result i32)))
    267   (import "wasi_snapshot_preview1" "fd_seek"
    268     (func $fd_seek (param i32 i64 i32 i32) (result i32)))
    269   (import "wasi_snapshot_preview1" "fd_tell"
    270     (func $fd_tell (param i32 i32) (result i32)))
    271   (import "wasi_snapshot_preview1" "fd_close"
    272     (func $fd_close (param i32) (result i32)))
    273   (memory 1)
    274   (data (i32.const 64) "hello.txt")
    275   (func (export "test_main") (result i32)
    276     (local $fd i32) (local $err i32)
    277     ;; path_open(dirfd=3, ..., "hello.txt", oflags=0, ..., &fd=16)
    278     i32.const 3 i32.const 0 i32.const 64 i32.const 9
    279     i32.const 0 i64.const 0 i64.const 0 i32.const 0 i32.const 16
    280     call $path_open local.set $err
    281     (if (i32.ne (local.get $err) (i32.const 0)) (then (return (i32.const 1))))
    282     (i32.load (i32.const 16)) local.set $fd
    283     ;; read 2 bytes into buf=128; iov at [0]=128 [4]=2; nread at 8
    284     (i32.store (i32.const 0) (i32.const 128))
    285     (i32.store (i32.const 4) (i32.const 2))
    286     local.get $fd i32.const 0 i32.const 1 i32.const 8
    287     call $fd_read local.set $err
    288     (if (i32.ne (local.get $err) (i32.const 0)) (then (return (i32.const 2))))
    289     (if (i32.ne (i32.load (i32.const 8)) (i32.const 2)) (then (return (i32.const 3))))
    290     (if (i32.ne (i32.load8_u (i32.const 128)) (i32.const 104)) ;; 'h'
    291       (then (return (i32.const 4))))
    292     ;; fd_seek(fd, offset=3, whence=0/SET, &newpos=24)
    293     local.get $fd i64.const 3 i32.const 0 i32.const 24
    294     call $fd_seek local.set $err
    295     (if (i32.ne (local.get $err) (i32.const 0)) (then (return (i32.const 5))))
    296     (if (i64.ne (i64.load (i32.const 24)) (i64.const 3)) (then (return (i32.const 6))))
    297     ;; fd_tell(fd, &pos=32)
    298     local.get $fd i32.const 32
    299     call $fd_tell local.set $err
    300     (if (i32.ne (local.get $err) (i32.const 0)) (then (return (i32.const 7))))
    301     (if (i64.ne (i64.load (i32.const 32)) (i64.const 3)) (then (return (i32.const 8))))
    302     ;; read 1 byte from pos 3: expect 'l'=108
    303     (i32.store (i32.const 4) (i32.const 1))
    304     local.get $fd i32.const 0 i32.const 1 i32.const 8
    305     call $fd_read local.set $err
    306     (if (i32.ne (local.get $err) (i32.const 0)) (then (return (i32.const 9))))
    307     (if (i32.ne (i32.load8_u (i32.const 128)) (i32.const 108)) ;; 'l'
    308       (then (return (i32.const 10))))
    309     local.get $fd call $fd_close drop
    310     i32.const 0))
    311 WAT
    312 
    313 cat > "$work/wasi_filestat.wat" <<'WAT'
    314 (module
    315   (import "wasi_snapshot_preview1" "path_open"
    316     (func $path_open (param i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i32)))
    317   (import "wasi_snapshot_preview1" "fd_filestat_get"
    318     (func $fd_filestat_get (param i32 i32) (result i32)))
    319   (import "wasi_snapshot_preview1" "fd_close"
    320     (func $fd_close (param i32) (result i32)))
    321   (memory 1)
    322   (data (i32.const 256) "hello.txt")
    323   (func (export "test_main") (result i32)
    324     (local $fd i32) (local $err i32)
    325     i32.const 3 i32.const 0 i32.const 256 i32.const 9
    326     i32.const 0 i64.const 0 i64.const 0 i32.const 0 i32.const 16
    327     call $path_open local.set $err
    328     (if (i32.ne (local.get $err) (i32.const 0)) (then (return (i32.const 1))))
    329     (i32.load (i32.const 16)) local.set $fd
    330     ;; fd_filestat_get(fd, filestat=64): 64-byte struct
    331     local.get $fd i32.const 64
    332     call $fd_filestat_get local.set $err
    333     (if (i32.ne (local.get $err) (i32.const 0)) (then (return (i32.const 2))))
    334     ;; filetype @ 64+16=80: expect 4 (regular file)
    335     (if (i32.ne (i32.load8_u (i32.const 80)) (i32.const 4))
    336       (then (return (i32.const 3))))
    337     ;; size @ 64+32=96 (u64 LE): expect 5
    338     (if (i64.ne (i64.load (i32.const 96)) (i64.const 5))
    339       (then (return (i32.const 4))))
    340     local.get $fd call $fd_close drop
    341     i32.const 0))
    342 WAT
    343 
    344 cat > "$work/wasi_path_filestat.wat" <<'WAT'
    345 (module
    346   (import "wasi_snapshot_preview1" "path_filestat_get"
    347     (func $path_filestat_get (param i32 i32 i32 i32 i32) (result i32)))
    348   (memory 1)
    349   (data (i32.const 256) "hello.txt")
    350   (func (export "test_main") (result i32)
    351     (local $err i32)
    352     ;; path_filestat_get(dirfd=3, flags=0, path=256, pathlen=9, filestat=64)
    353     i32.const 3 i32.const 0 i32.const 256 i32.const 9 i32.const 64
    354     call $path_filestat_get local.set $err
    355     (if (i32.ne (local.get $err) (i32.const 0)) (then (return (local.get $err))))
    356     ;; filetype @ 64+16=80: expect 4 (regular file)
    357     (if (i32.ne (i32.load8_u (i32.const 80)) (i32.const 4))
    358       (then (return (i32.const 10))))
    359     ;; size @ 64+32=96 (u64 LE): expect 5
    360     (if (i64.ne (i64.load (i32.const 96)) (i64.const 5))
    361       (then (return (i32.const 11))))
    362     i32.const 0))
    363 WAT
    364 
    365 cat > "$work/wasi_opendir_readdir.wat" <<'WAT'
    366 (module
    367   (import "wasi_snapshot_preview1" "path_open"
    368     (func $path_open (param i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i32)))
    369   (import "wasi_snapshot_preview1" "fd_readdir"
    370     (func $fd_readdir (param i32 i32 i32 i64 i32) (result i32)))
    371   (import "wasi_snapshot_preview1" "fd_close"
    372     (func $fd_close (param i32) (result i32)))
    373   (memory 1)
    374   (data (i32.const 64) "subdir")
    375   (func (export "test_main") (result i32)
    376     (local $dir_fd i32) (local $err i32)
    377     ;; path_open(3, 0, "subdir", oflags=4/OFLAGS_DIRECTORY, ..., &fd=16)
    378     i32.const 3 i32.const 0 i32.const 64 i32.const 6
    379     i32.const 4 i64.const 0 i64.const 0 i32.const 0 i32.const 16
    380     call $path_open local.set $err
    381     (if (i32.ne (local.get $err) (i32.const 0)) (then (return (i32.const 1))))
    382     (i32.load (i32.const 16)) local.set $dir_fd
    383     ;; fd_readdir(dir_fd, buf=128, buflen=256, cookie=0, &bufused=32)
    384     local.get $dir_fd i32.const 128 i32.const 256 i64.const 0 i32.const 32
    385     call $fd_readdir local.set $err
    386     (if (i32.ne (local.get $err) (i32.const 0)) (then (return (i32.const 2))))
    387     ;; expect exactly one entry: "world.txt" (9 bytes) → bufused=24+9=33
    388     (if (i32.ne (i32.load (i32.const 32)) (i32.const 33))
    389       (then (return (i32.const 3))))
    390     ;; dirent namlen @ buf+16=144: expect 9
    391     (if (i32.ne (i32.load (i32.const 144)) (i32.const 9))
    392       (then (return (i32.const 4))))
    393     ;; dirent filetype @ buf+20=148: expect 4 (regular)
    394     (if (i32.ne (i32.load8_u (i32.const 148)) (i32.const 4))
    395       (then (return (i32.const 5))))
    396     local.get $dir_fd call $fd_close drop
    397     i32.const 0))
    398 WAT
    399 
    400 cat > "$work/wasi_unknown.wat" <<'WAT'
    401 (module
    402   (import "wasi_snapshot_preview1" "path_unlink_file"
    403     (func $unlink (param i32 i32 i32) (result i32)))
    404   (memory 1)
    405   (func (export "test_main") (result i32)
    406     i32.const 0
    407     i32.const 0
    408     i32.const 0
    409     call $unlink))
    410 WAT
    411 
    412 cat > "$work/main.c" <<'SRC'
    413 int main(void) { return 0; }
    414 SRC
    415 
    416 printf 'hello' > "$work/hello.txt"
    417 mkdir -p "$work/subdir"
    418 printf 'world' > "$work/subdir/world.txt"
    419 
    420 run_ok "wasm-default-runs-no-imports" \
    421   "$KIT" run -e test_main "$work/return0.wat"
    422 
    423 KIT_TEST_HOST_IMPORTS=1 "$KIT" run -e test_main "$work/host_add.wat" \
    424   > "$work/default-deny.out" 2> "$work/default-deny.err"
    425 if [ "$?" -ne 0 ]; then
    426   ok "wasm-default-denies-test-env-fallback"
    427 else
    428   not_ok "wasm-default-denies-test-env-fallback" "$work/default-deny.out"
    429 fi
    430 contains "wasm-default-deny-diag" "$work/default-deny.err" \
    431   "wasm host import unresolved"
    432 
    433 run_ok "wasm-explicit-test-import" \
    434   "$KIT" run --wasm-imports=test -e test_main "$work/host_add.wat"
    435 
    436 run_fail "wasm-memory-cap-fails" \
    437   "$KIT" run --wasm-memory-max=64K -e test_main "$work/memory_2page_max.wat"
    438 contains "wasm-memory-cap-diag" "$work/wasm-memory-cap-fails.err" \
    439   "wasm linear memory reservation exceeds 65536 bytes"
    440 
    441 run_ok "wasm-memory-cap-allows" \
    442   "$KIT" run --wasm-memory-max=128K -e test_main "$work/memory_2page_max.wat"
    443 
    444 run_fail "wasm-memories-cap-fails" \
    445   "$KIT" run --wasm-memories-max=0 -e test_main "$work/memory_one.wat"
    446 contains "wasm-memories-cap-diag" "$work/wasm-memories-cap-fails.err" \
    447   "wasm memory count exceeds 0"
    448 
    449 run_ok "wasm-policy-flags-parse" \
    450   "$KIT" run --wasm-env=inherit --wasm-env-pass=PATH \
    451     --wasm-env-set=KIT_TEST=1 --wasm-map-dir="$work=/work:ro" \
    452     --wasm-map-file="$work/return0.wat=/return0.wat:ro" --wasm-cwd=/work \
    453     --wasm-stdio=inherit --wasm-clock=monotonic --wasm-random=seed:abcd \
    454     -e test_main "$work/return0.wat"
    455 
    456 "$KIT" run --wasm-wasi -e test_main "$work/wasi_exit.wat" \
    457   > "$work/wasm-wasi-proc-exit.out" 2> "$work/wasm-wasi-proc-exit.err"
    458 if [ "$?" -eq 7 ]; then
    459   ok "wasm-wasi-proc-exit"
    460 else
    461   not_ok "wasm-wasi-proc-exit" "$work/wasm-wasi-proc-exit.err"
    462 fi
    463 
    464 "$KIT" run --wasm-wasi -e test_main "$work/wasi_exit_unreachable.wat" \
    465   > "$work/wasm-wasi-proc-exit-unreachable.out" \
    466   2> "$work/wasm-wasi-proc-exit-unreachable.err"
    467 if [ "$?" -eq 9 ]; then
    468   ok "wasm-wasi-proc-exit-unreachable"
    469 else
    470   not_ok "wasm-wasi-proc-exit-unreachable" \
    471     "$work/wasm-wasi-proc-exit-unreachable.err"
    472 fi
    473 
    474 "$KIT" run --wasm-wasi --wasm-stdio=inherit -e test_main \
    475   "$work/wasi_stdout.wat" > "$work/wasm-wasi-stdout.out" \
    476   2> "$work/wasm-wasi-stdout.err"
    477 if [ "$?" -eq 0 ]; then ok "wasm-wasi-stdout"; else
    478   not_ok "wasm-wasi-stdout" "$work/wasm-wasi-stdout.err"
    479 fi
    480 contains "wasm-wasi-stdout-text" "$work/wasm-wasi-stdout.out" "hello wasi"
    481 
    482 "$KIT" run --wasm-wasi --wasm-stdio=null -e test_main \
    483   "$work/wasi_stdout.wat" > "$work/wasm-wasi-stdout-null.out" \
    484   2> "$work/wasm-wasi-stdout-null.err"
    485 if [ "$?" -eq 0 ] && [ ! -s "$work/wasm-wasi-stdout-null.out" ]; then
    486   ok "wasm-wasi-stdout-null"
    487 else
    488   not_ok "wasm-wasi-stdout-null" "$work/wasm-wasi-stdout-null.err"
    489 fi
    490 
    491 run_ok "wasm-wasi-env-set" \
    492   "$KIT" run --wasm-wasi --wasm-env-set=KIT_WASM_TEST=ok \
    493     -e test_main "$work/wasi_env.wat"
    494 
    495 run_ok "wasm-wasi-args" \
    496   "$KIT" run --wasm-wasi -e test_main "$work/wasi_args.wat" -- alpha
    497 
    498 run_ok "wasm-wasi-random-clock-prestat" \
    499   "$KIT" run --wasm-wasi --wasm-clock=monotonic --wasm-random=seed:abcd \
    500     --wasm-map-dir="$work=/sandbox:ro" -e test_main \
    501     "$work/wasi_runtime_caps.wat"
    502 
    503 run_ok "wasm-wasi-fs-read" \
    504   "$KIT" run --wasm-wasi --wasm-map-dir="$work=/sandbox:ro" \
    505     -e test_main "$work/wasi_fs_read.wat"
    506 
    507 run_ok "wasm-wasi-fs-map-file-read" \
    508   "$KIT" run --wasm-wasi \
    509     --wasm-map-file="$work/hello.txt=/sandbox/hello.txt:ro" \
    510     -e test_main "$work/wasi_fs_read.wat"
    511 
    512 run_ok "wasm-wasi-seek-tell" \
    513   "$KIT" run --wasm-wasi --wasm-map-dir="$work=/sandbox:ro" \
    514     -e test_main "$work/wasi_seek.wat"
    515 
    516 run_ok "wasm-wasi-fd-filestat-get" \
    517   "$KIT" run --wasm-wasi --wasm-map-dir="$work=/sandbox:ro" \
    518     -e test_main "$work/wasi_filestat.wat"
    519 
    520 run_ok "wasm-wasi-path-filestat-get" \
    521   "$KIT" run --wasm-wasi --wasm-map-dir="$work=/sandbox:ro" \
    522     -e test_main "$work/wasi_path_filestat.wat"
    523 
    524 run_ok "wasm-wasi-opendir-readdir" \
    525   "$KIT" run --wasm-wasi --wasm-map-dir="$work=/sandbox:ro" \
    526     -e test_main "$work/wasi_opendir_readdir.wat"
    527 
    528 run_fail "wasm-wasi-unknown-import-fails" \
    529   "$KIT" run --wasm-wasi -e test_main "$work/wasi_unknown.wat"
    530 contains "wasm-wasi-unknown-import-diag" \
    531   "$work/wasm-wasi-unknown-import-fails.err" \
    532   "path_unlink_file"
    533 
    534 run_fail "wasm-flags-reject-native" \
    535   "$KIT" run --wasm-memory-max=1M "$work/main.c"
    536 contains "wasm-flags-reject-native-diag" "$work/wasm-flags-reject-native.err" \
    537   "wasm sandbox flags require a wasm input"
    538 
    539 run_fail "wasm-rejects-mixed-native-inputs" \
    540   "$KIT" run -e test_main "$work/return0.wat" "$work/main.c"
    541 contains "wasm-rejects-mixed-native-inputs-diag" \
    542   "$work/wasm-rejects-mixed-native-inputs.err" \
    543   "sandboxed wasm run does not support mixed native inputs"
    544 
    545 run_fail "wasm-import-mode-invalid" \
    546   "$KIT" run --wasm-imports=env -e test_main "$work/return0.wat"
    547 contains "wasm-import-mode-invalid-diag" \
    548   "$work/wasm-import-mode-invalid.err" \
    549   "unknown --wasm-imports value"
    550 
    551 run_fail "wasm-fs-invalid" \
    552   "$KIT" run --wasm-fs=host -e test_main "$work/return0.wat"
    553 contains "wasm-fs-invalid-diag" "$work/wasm-fs-invalid.err" \
    554   "unknown --wasm-fs value"
    555 
    556 kit_summary test-driver-wasm
    557 kit_exit