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