(use fuse posix test) (define u+rwx/reg (bitwise-ior file/reg perm/irusr perm/iwusr perm/ixusr)) (define u+rwx/dir (bitwise-ior file/dir perm/irusr perm/iwusr perm/ixusr)) (define (test-exception path) (define pid (let ((fs (make-filesystem getattr: (lambda (path) (cond ((string=? path "/") (vector u+rwx/dir 2 (current-user-id) (current-group-id) 0 (current-seconds) (current-seconds) (current-seconds))) ((string=? path "/error") (vector u+rwx/reg 1 (current-user-id) (current-group-id) 0 (current-seconds) (current-seconds) (current-seconds))) (else #f))) readdir: (lambda (path) (and (string=? path "/") (list "." ".." "error"))) open: (lambda (path mode) (error 'open "Error opening path" path mode))))) (process-fork (lambda () (set-signal-handler! signal/term (lambda (_) (filesystem-stop! path fs))) (let ((n 0)) (with-exception-handler (lambda (e) (set! n (add1 n))) (lambda () (filesystem-start! path fs) (filesystem-wait! path fs) (exit n)))))))) (sleep 1) (let ((file (string-append path "/error"))) (do ((n 0 (add1 n))) ((= n 10) (process-signal pid signal/term) (let-values (((_ _ exit-status) (process-wait pid))) (test-assert (>= exit-status n)))) (test-error (file-open file open/read))))) (test-assert (create-directory "path" #t)) (test-exception "path") (test-assert (delete-directory "path" #t))