1.0.9.53: trivial typo fixes
[sbcl/lichteblau.git] / tests / run-program.test.sh
blobb95931a420ee536fbbac919efdf2cb8e34be30f7
1 #!/bin/sh
3 # tests related to SB-EXT:RUN-PROGRAM
5 # This software is part of the SBCL system. See the README file for
6 # more information.
8 # While most of SBCL is derived from the CMU CL system, the test
9 # files (like this one) were written from scratch after the fork
10 # from CMU CL.
12 # This software is in the public domain and is provided with
13 # absolutely no warranty. See the COPYING and CREDITS files for
14 # more information.
16 # Make sure that there's at least something in the environment (for
17 # one of the tests below).
18 SOMETHING_IN_THE_ENVIRONMENT='yes there is'
19 export SOMETHING_IN_THE_ENVIRONMENT
20 PATH=/some/path/that/does/not/exist:${PATH}
21 export PATH
23 ${SBCL:-sbcl} <<EOF
24 ;; test that $PATH is searched
25 (assert (zerop (sb-ext:process-exit-code
26 (sb-ext:run-program "true" () :search t :wait t))))
27 (assert (not (zerop (sb-ext:process-exit-code
28 (sb-ext:run-program "false" () :search t :wait t)))))
29 (let ((string (with-output-to-string (stream)
30 (sb-ext:run-program "/bin/echo"
31 '("foo" "bar")
32 :output stream))))
33 (assert (string= string "foo bar
34 ")))
35 ;; Unix environment strings are ordinarily passed with SBCL convention
36 ;; (instead of CMU CL alist-of-keywords convention).
37 (let ((string (with-output-to-string (stream)
38 (sb-ext:run-program "/usr/bin/env" ()
39 :output stream
40 :environment '("FEEFIE=foefum")))))
41 (assert (string= string "FEEFIE=foefum
42 ")))
43 ;; The default Unix environment for the subprocess is the same as
44 ;; for the parent process. (I.e., we behave like perl and lots of
45 ;; other programs, but not like CMU CL.)
46 (let ((string (with-output-to-string (stream)
47 (sb-ext:run-program "/usr/bin/env" ()
48 :output stream)))
49 (expected (apply #'concatenate
50 'string
51 (mapcar (lambda (environ-string)
52 (concatenate 'string
53 environ-string
54 (string #\newline)))
55 (sb-ext:posix-environ)))))
56 (assert (string= string expected)))
57 ;; That's not just because POSIX-ENVIRON is having a bad hair
58 ;; day and returning NIL, is it?
59 (assert (plusp (length (sb-ext:posix-environ))))
60 ;; make sure that a stream input argument is basically reasonable.
61 (let ((string (let ((i (make-string-input-stream "abcdef")))
62 (with-output-to-string (stream)
63 (sb-ext:run-program "/bin/cat" ()
64 :input i :output stream)))))
65 (assert (= (length string) 6))
66 (assert (string= string "abcdef")))
67 ;; success convention for this Lisp program run as part of a larger script
68 (sb-ext:quit :unix-status 52)))
69 EOF
70 if [ $? != 52 ]; then
71 echo test failed: $?
72 exit 1
75 # success convention
76 exit 104