(use test tcp posix (srfi 4)) (load "test-utils") (load "../sendfile.so") (import sendfile) (newline) (display "starting server on port 5555") (define server-pid (process-fork server)) (unless (wait-for-server 3) (display "could not start server!!!!") (exit 0)) ;;wait 5 seconds to prevent from weird bug on some machines (newline) (display "stand by ....") (flush-output) (sleep 4) (test-group "read-write-loop" (test "send" test-file-size (with-prepared-environment test-file (lambda (in out) (impl:read-write-loop/fd in out test-file-size)))) (sleep 1) (test "verify" test-file-checksum (compute-file-checksum test-file-out))) (test-group "read-write-loop (ports-only)" (test "send" test-file-size (with-prepared-environment test-file (lambda (in out) (impl:read-write-loop/port in out test-file-size)) #t)) (sleep 1) (test "verify" test-file-checksum (compute-file-checksum test-file-out))) (if os-dep:sendfile-available? (test-group "sendfile-impl" (test "send" test-file-size (with-prepared-environment test-file (lambda (in out) (impl:sendfile in out test-file-size)))) (sleep 1) (test "verify" test-file-checksum (compute-file-checksum test-file-out)))) (if os-dep:mmap-available? (test-group "mmapped io" (test "send" test-file-size (with-prepared-environment test-file (lambda (in out) (impl:mmapped in out test-file-size)))) (sleep 1) (test "verify" test-file-checksum (compute-file-checksum test-file-out)))) (test-begin "interface") (test-group "sendfile" (test "send" test-file-size (with-prepared-environment test-file (lambda (in out) (sendfile in out)))) (sleep 1) (test "verify" test-file-checksum (compute-file-checksum test-file-out))) (test-end "interface") (test-begin "forcing implementation") (test "read-write-loop" 'read-write-loop (with-prepared-environment test-file (lambda (in out) (parameterize ((force-implementation 'read-write)) (sendfile in out) *last-selected-implementation*)))) (if os-dep:sendfile-available? (test "sendfile" 'sendfile (with-prepared-environment test-file (lambda (in out) (parameterize ((force-implementation 'sendfile)) (sendfile in out) *last-selected-implementation*))))) (if os-dep:mmap-available? (test "mmapped" 'mmapped (with-prepared-environment test-file (lambda (in out) (parameterize ((force-implementation 'mmapped)) (sendfile in out) *last-selected-implementation*))))) (test-end "forcing implementation") (display "shutting down server") (process-signal server-pid) (newline) (display "sent SIGTERM to server. please make sure the server isn't running anymore!") (newline)