0.8.0.70:
[sbcl/lichteblau.git] / tests / run-program.test.sh
blobad11cace324189d4a752055cf03c6d84f05ac485
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
22 ${SBCL:-sbcl} <<EOF
23 ;; test that $PATH is searched
24 (assert (zerop (sb-ext:process-exit-code
25 (sb-ext:run-program "true" () :search t :wait t))))
26 (assert (not (zerop (sb-ext:process-exit-code
27 (sb-ext:run-program "false" () :search t :wait t)))))
28 (let ((string (with-output-to-string (stream)
29 (sb-ext:run-program "/bin/echo"
30 '("foo" "bar")
31 :output stream))))
32 (assert (string= string "foo bar
33 ")))
34 ;; Unix environment strings are ordinarily passed with SBCL convention
35 ;; (instead of CMU CL alist-of-keywords convention).
36 (let ((string (with-output-to-string (stream)
37 (sb-ext:run-program "/usr/bin/env" ()
38 :output stream
39 :environment '("FEEFIE=foefum")))))
40 (assert (string= string "FEEFIE=foefum
41 ")))
42 ;; The default Unix environment for the subprocess is the same as
43 ;; for the parent process. (I.e., we behave like perl and lots of
44 ;; other programs, but not like CMU CL.)
45 (let ((string (with-output-to-string (stream)
46 (sb-ext:run-program "/usr/bin/env" ()
47 :output stream)))
48 (expected (apply #'concatenate
49 'string
50 (mapcar (lambda (environ-string)
51 (concatenate 'string
52 environ-string
53 (string #\newline)))
54 (sb-ext:posix-environ)))))
55 (assert (string= string expected)))
56 ;; That's not just because POSIX-ENVIRON is having a bad hair
57 ;; day and returning NIL, is it?
58 (assert (plusp (length (sb-ext:posix-environ))))
59 ;; success convention for this Lisp program run as part of a larger script
60 (sb-ext:quit :unix-status 52)))
61 EOF
62 if [ $? != 52 ]; then
63 echo test failed: $?
64 exit 1
67 # success convention
68 exit 104