0.9.10.36:
[sbcl.git] / tests / run-program.impure.lisp
1 ;;;; various RUN-PROGRAM tests with side effects
2
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; While most of SBCL is derived from the CMU CL system, the test
7 ;;;; files (like this one) were written from scratch after the fork
8 ;;;; from CMU CL.
9 ;;;;
10 ;;;; This software is in the public domain and is provided with
11 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
12 ;;;; more information.
13
14 (cl:in-package :cl-user)
15
16 ;; Actually there's no real side-effect here. The impurity we're
17 ;; avoiding is the sigchld handler that RUN-PROGRAM sets up, which
18 ;; interfers with the manual unix process control done by the test
19 ;; framework (sometimes the handler will manage to WAIT3 a process
20 ;; before run-tests WAITPIDs it).
21
22 (let* ((process (sb-ext:run-program "/bin/cat" '() :wait nil
23                                     :output :stream :input :stream))
24        (out (process-input process))
25        (in (process-output process)))
26   (unwind-protect
27        (loop for i from 0 to 255 do
28              (write-byte i out)
29              (force-output out)
30              (assert (= (read-byte in) i)))
31     (process-close process)))