~ chicken-core (master) /tests/runtests.sh


  1#!/bin/sh
  2# runtests.sh - run CHICKEN testsuite
  3#
  4# - Note: this needs a proper shell, so it will not work with plain mingw
  5#   (just the compiler and the Windows shell, without MSYS)
  6
  7set -e
  8if [ $(uname) = Windows_NT ]; then
  9    MSYSTEM=1
 10fi
 11TEST_DIR=`pwd`
 12if test -z "$MSYSTEM"; then
 13    PATH_SEP=':'
 14else
 15    PATH_SEP=';'
 16fi
 17
 18unset CSC_OPTIONS
 19
 20DYLD_LIBRARY_PATH=${TEST_DIR}/..
 21LD_LIBRARY_PATH=${TEST_DIR}/..
 22LIBRARY_PATH=${TEST_DIR}/..:${LIBRARY_PATH}
 23# Cygwin uses LD_LIBRARY_PATH for dlopen(), but the dlls linked into
 24# the binary are read by the OS itself, which uses $PATH (mingw too)
 25# Oddly, prefixing .. with ${TEST_DIR}/ does _not_ work on mingw!
 26PATH=..${PATH_SEP}${PATH}
 27
 28export DYLD_LIBRARY_PATH LD_LIBRARY_PATH LIBRARY_PATH PATH
 29
 30case `uname` in
 31	AIX)
 32		DIFF_OPTS=-b ;;
 33	*)
 34		DIFF_OPTS=-bu ;;
 35esac
 36
 37CHICKEN=${TEST_DIR}/../${PROGRAM_PREFIX}chicken${PROGRAM_SUFFIX}
 38CHICKEN_PROFILE=${TEST_DIR}/../${PROGRAM_PREFIX}chicken-profile${PROGRAM_SUFFIX}
 39CHICKEN_INSTALL=${TEST_DIR}/../${PROGRAM_PREFIX}chicken-install${PROGRAM_SUFFIX}
 40CHICKEN_UNINSTALL=${TEST_DIR}/../${PROGRAM_PREFIX}chicken-uninstall${PROGRAM_SUFFIX}
 41CHICKEN_INSTALL_REPOSITORY=${TEST_DIR}/test-repository
 42CHICKEN_REPOSITORY_PATH="${TEST_DIR}/..${PATH_SEP}${CHICKEN_INSTALL_REPOSITORY}"
 43
 44export CHICKEN_INSTALL_REPOSITORY CHICKEN_REPOSITORY_PATH
 45
 46TYPESDB=../types.db
 47COMPILE_OPTIONS="-v -compiler ${CHICKEN} -I${TEST_DIR}/.. -L${TEST_DIR}/.. -include-path ${TEST_DIR}/.. -libdir ${TEST_DIR}/.. -rpath ${TEST_DIR}/.."
 48
 49compile="../${PROGRAM_PREFIX}csc${PROGRAM_SUFFIX} ${COMPILE_OPTIONS} -o a.out -types ${TYPESDB} -ignore-repository"
 50compile_r="../${PROGRAM_PREFIX}csc${PROGRAM_SUFFIX} ${COMPILE_OPTIONS}"
 51compile_s="../${PROGRAM_PREFIX}csc${PROGRAM_SUFFIX} ${COMPILE_OPTIONS} -s -types ${TYPESDB} -ignore-repository"
 52interpret="../${PROGRAM_PREFIX}csi${PROGRAM_SUFFIX} -n -include-path ${TEST_DIR}/.."
 53time=time
 54
 55# Check for a "time" command, since some systems don't ship with a
 56# time(1) or shell builtin and we also can't portably rely on `which',
 57# `command', etc. NOTE "time" must be called from a variable here.
 58set +e
 59$time true >/dev/null 2>/dev/null
 60test $? -eq 127 && time=
 61set -e
 62
 63rm -fr *.exe *.so *.o *.obj *.out *.import.* ../foo.import.* test-repository
 64mkdir -p test-repository
 65cp $TYPESDB test-repository/types.db
 66
 67echo "======================================== repository search path ..."
 68if test -z "$MSYSTEM"; then
 69  export -p >./env.out
 70  unset CHICKEN_REPOSITORY_PATH
 71  $interpret -s repository-path-default.scm
 72  . ./env.out
 73else
 74  env -u CHICKEN_REPOSITORY_PATH $interpret -s repository-path-default.scm
 75fi
 76$compile_s sample-module.scm -j sample-module
 77cp sample-module.so $CHICKEN_INSTALL_REPOSITORY
 78cp sample-module.import.scm $CHICKEN_INSTALL_REPOSITORY
 79$interpret -s repository-path.scm "${TEST_DIR}/.." "${TEST_DIR}/test-repository"
 80
 81echo "======================================== types.db consistency ..."
 82$interpret -s types-db-consistency.scm ${TYPESDB}
 83
 84echo "======================================== version tests ..."
 85$compile version-tests.scm
 86./a.out
 87
 88echo "======================================== compiler tests ..."
 89$compile compiler-tests.scm
 90./a.out
 91
 92echo "======================================== FFI tests ..."
 93$compile ffi-tests.scm
 94./a.out
 95$compile -d3 ffi-tests-2.scm
 96./a.out
 97
 98echo "======================================== csc tests ..."
 99$interpret -s csc-tests.scm
100
101echo "======================================== compiler inlining tests  ..."
102$compile_r inline-me.scm -s -J -oi inline-me.inline
103$compile inlining-tests.scm -optimize-level 3
104./a.out
105$compile inline-unroll.scm -optimize-level 3
106./a.out
107
108echo "======================================== compiler message tests ..."
109$compile -analyze-only messages-test.scm 2>messages.out
110diff $DIFF_OPTS messages.expected messages.out
111
112echo "======================================== optimizer tests  ..."
113$compile rest-arg-tests.scm -specialize
114./a.out
115
116echo "======================================== profiler tests ..."
117$compile null.scm -profile -profile-name TEST.profile
118./a.out
119$CHICKEN_PROFILE TEST.profile
120
121echo "======================================== scrutiny tests ..."
122$compile scrutinizer-tests.scm -analyze-only
123$compile typematch-tests.scm -specialize -no-warnings
124./a.out
125
126$compile test-scrutinizer-message-format.scm -analyze-only -specialize 2>scrutinizer-message-format.out || true
127$compile scrutiny-tests.scm -analyze-only -specialize 2>scrutiny.out
128$compile scrutiny-tests-2.scm -analyze-only -specialize 2>scrutiny-2.out
129$compile specialization-tests.scm -analyze-only -specialize -specialize 2>specialization.out
130
131# Replace foo123 -> fooXX so gensyms don't trigger failures
132$compile redact-gensyms.scm -o redact-gensyms
133./redact-gensyms "tmp,g,scm:,a,b" < scrutinizer-message-format.out > scrutinizer-message-format.redacted
134./redact-gensyms < scrutiny-2.out > scrutiny-2.redacted
135./redact-gensyms < scrutiny.out > scrutiny.redacted
136./redact-gensyms < specialization.out > specialization.redacted
137
138diff $DIFF_OPTS scrutinizer-message-format.expected scrutinizer-message-format.redacted
139diff $DIFF_OPTS scrutiny.expected scrutiny.redacted
140diff $DIFF_OPTS scrutiny-2.expected scrutiny-2.redacted
141diff $DIFF_OPTS specialization.expected specialization.redacted
142
143$compile scrutiny-tests-3.scm -specialize -block
144./a.out
145
146$compile scrutiny-tests-strict.scm -strict-types -specialize
147./a.out
148
149echo "======================================== line number database ..."
150$compile -O3 test-line-numbers.scm 2> test-line-numbers.out
151diff $DIFF_OPTS test-line-numbers.expected test-line-numbers.out
152./a.out
153
154echo "======================================== specialization tests ..."
155rm -f foo.types foo.import.*
156$compile specialization-test-1.scm -emit-types-file foo.types -specialize \
157  -debug ox -emit-import-library foo
158./a.out
159$compile specialization-test-2.scm -types foo.types -types specialization-test-2.types -specialize -debug ox
160./a.out
161rm -f foo.types foo.import.*
162
163echo "======================================== specialization benchmark ..."
164$compile fft.scm -O2 -local -d0 -disable-interrupts -b -o fft1.out
165$compile fft.scm -O2 -local -specialize -debug x -d0 -disable-interrupts -b -o fft2.out -specialize
166echo "normal:"
167$time ./fft1.out 1000 7
168echo "specialized:"
169$time ./fft2.out 1000 7
170
171echo "======================================== unboxing benchmark ..."
172$compile fft.scm -O2 -local -d0 -disable-interrupts -b -o fft1.out
173$compile fft.scm -O4 -debug x -d0 -disable-interrupts -b -o fft2.out
174echo "normal:"
175$time ./fft1.out 1000 7
176echo "unboxing:"
177$time ./fft2.out 1000 7
178
179echo "======================================== callback tests ..."
180$compile -extend c-id-valid.scm callback-tests.scm
181./a.out
182
183if ./a.out twice; then
184    echo "double-return from callback didn't fail"
185    exit 1
186else
187    echo "double-return from callback failed as it should."
188fi
189
190echo "======================================== runtime tests ..."
191$interpret -s apply-test.scm
192$compile apply-test.scm
193./a.out
194if ./a.out -:A10k; then
195    echo "apply test with limited temp stack didn't fail"
196    exit 1
197else
198    echo "apply test with limited temp stack failed as it should."
199fi
200
201$compile test-gc-hooks.scm
202./a.out
203
204echo "======================================== library tests ..."
205$interpret -s library-tests.scm
206$compile -specialize library-tests.scm
207./a.out
208$interpret -s records-and-setters-test.scm
209$compile records-and-setters-test.scm
210./a.out
211$interpret -s record-printer-test.scm
212$compile record-printer-test.scm
213./a.out
214
215echo "======================================== unicode tests ..."
216$interpret -s unicode-tests.scm
217$compile -specialize unicode-tests.scm
218./a.out
219$interpret -s invalid-utf-test.scm
220$interpret -s file-encoding-test.scm
221
222echo "======================================== reader tests ..."
223$interpret -s reader-tests.scm
224
225echo "======================================== dynamic-wind tests ..."
226$interpret -s dwindtst.scm >dwindtst.out
227diff $DIFF_OPTS dwindtst.expected dwindtst.out
228$compile dwindtst.scm
229./a.out >dwindtst.out
230diff $DIFF_OPTS dwindtst.expected dwindtst.out
231
232echo "======================================== lolevel tests ..."
233$interpret -s lolevel-tests.scm
234$compile -specialize lolevel-tests.scm
235./a.out
236
237echo "======================================== arithmetic tests ..."
238$interpret -D check -s arithmetic-test.scm
239
240echo "======================================== pretty-printer tests ..."
241$interpret -s pp-test.scm
242
243echo "======================================== evaluation environment tests ..."
244$interpret -s environment-tests.scm
245
246echo "======================================== syntax tests ..."
247$interpret -s syntax-tests.scm
248
249echo "======================================== syntax tests (compiled) ..."
250$compile syntax-tests.scm
251./a.out
252
253echo "======================================== syntax tests (v2, compiled) ..."
254$compile syntax-tests-2.scm
255./a.out
256
257echo "======================================== meta-syntax tests ..."
258$interpret -bnq meta-syntax-test.scm -e '(import foo)' -e '(assert (equal? (quote ((1))) (bar 1 2)))' -e '(assert (equal? (quote (list 1 2 3)) (listify)))' -e '(import test-import-syntax-for-syntax)' -e '(assert (equal? (quote (1)) (test)))' -e '(import test-begin-for-syntax)' -e '(assert (equal? (quote (1)) (test)))'
259$compile_s meta-syntax-test.scm -j foo
260$compile_s foo.import.scm
261$interpret -bnq meta-syntax-test.scm -e '(import foo)' -e '(assert (equal? (quote ((1))) (bar 1 2)))' -e '(assert (equal? (quote (list 1 2 3)) (listify)))' -e '(import test-import-syntax-for-syntax)' -e '(assert (equal? (quote (1)) (test)))' -e '(import test-begin-for-syntax)' -e '(assert (equal? (quote (1)) (test)))'
262
263echo "======================================== reexport tests ..."
264$interpret -bnq reexport-tests.scm
265$compile reexport-tests.scm
266./a.out
267rm -f reexport-m*.import*
268$compile_s reexport-m1.scm -J
269$compile_s reexport-m1.import.scm
270$interpret -s reexport-m2.scm
271$compile reexport-m2.scm
272./a.out
273$compile_s reexport-m3.scm -J
274$compile_s reexport-m4.scm -J
275$compile_s reexport-m5.scm -J
276$compile_s reexport-m6.scm -J
277$compile_s reexport-m7.scm -J
278$compile_s reexport-m8.scm -J
279$compile_s reexport-m9.scm -J
280$compile_s reexport-m10.scm -J
281$compile reexport-tests-2.scm
282./a.out
283
284echo "======================================== functor tests ..."
285$interpret -bnq simple-functors-test.scm
286$compile simple-functors-test.scm
287./a.out
288$interpret -bnq functor-tests.scm
289$compile functor-tests.scm
290./a.out
291$compile -s square-functor.scm -J
292$compile -s square-functor.import.scm
293$interpret -bnq use-square-functor.scm
294$compile use-square-functor.scm
295./a.out
296$compile -s use-square-functor.scm -J
297$interpret -nqe '(require-library use-square-functor)' -e '(import sf1)' -e '(import sf2)'
298rm -f sf1.import.* sf2.import.* lst.import.* mod.import.*
299
300echo "======================================== compiler syntax tests ..."
301$compile compiler-syntax-tests.scm
302./a.out
303
304echo "======================================== import tests ..."
305$interpret -bnq import-tests.scm
306
307echo "======================================== import library tests ..."
308rm -f ../foo.import.* foo.import.*
309$compile import-library-test1.scm -emit-import-library foo
310$interpret -s import-library-test2.scm
311$compile_s foo.import.scm -o foo.import.so
312$interpret -s import-library-test2.scm
313$compile import-library-test2.scm
314./a.out
315rm -f foo.import.*
316
317echo "======================================== optionals test ..."
318$interpret -s test-optional.scm
319$compile test-optional.scm
320./a.out
321
322echo "======================================== syntax tests (matchable) ..."
323$interpret matchable.scm -s match-test.scm
324
325echo "======================================== syntax tests (loopy-loop) ..."
326$interpret -s loopy-test.scm
327
328echo "======================================== r4rstest ..."
329echo "(expect mult-float-print-test to fail)"
330$interpret -e '(set! ##sys#procedure->string (constantly "#<procedure>"))' \
331  -i -s r4rstest.scm >r4rstest.out
332
333diff $DIFF_OPTS r4rstest.expected r4rstest.out
334
335echo "======================================== syntax tests (r5rs_pitfalls) ..."
336echo "(expect two failures)"
337$interpret -i -s r5rs_pitfalls.scm
338
339echo "======================================== r7rs tests ..."
340$interpret -s r7rs-tests.scm
341$interpret -s r7rs-tests-2.scm
342$interpret -s r7rs-library-tests.scm
343$interpret -s life.scm
344
345echo "======================================== module tests ..."
346$interpret -include-path ${TEST_DIR}/.. -s module-tests.scm
347$interpret -include-path ${TEST_DIR}/.. -s module-tests-2.scm
348
349echo "======================================== module tests (command line options) ..."
350module="test-$(date +%s)"
351$compile test.scm -A -w -j "$module" -module "$module"
352$interpret -e "(import-syntax $module)"
353rm -f "$module.import.scm"
354
355echo "======================================== module tests (compiled) ..."
356$compile module-tests-compiled.scm
357./a.out
358$compile module-static-eval-compiled.scm
359./a.out
360$compile -static module-static-eval-compiled.scm
361./a.out
362
363echo "======================================== module tests (chained) ..."
364rm -f m*.import.* test-chained-modules.so
365$interpret -bnq test-chained-modules.scm
366$compile_s test-chained-modules.scm -j m3
367$compile_s m3.import.scm
368$interpret -bn test-chained-modules.so
369$interpret -bn test-chained-modules.so -e '(import m3) (s3)'
370
371echo "======================================== module tests (ec) ..."
372rm -f ec.so ec.import.*
373$interpret -bqn ec.scm ec-tests.scm
374$compile_s ec.scm -emit-import-library ec -o ec.so
375$compile_s ec.import.scm -o ec.import.so
376$interpret -bnq ec.so ec-tests.scm
377# $compile ec-tests.scm
378# ./a.out        # takes ages to compile
379
380echo "======================================== module tests (static link) ..."
381$compile_r -static -unit sample-module -J -c sample-module.scm
382mv sample-module.link sample-module.import.scm sample-module.o* "$CHICKEN_INSTALL_REPOSITORY"
383$compile_r -static module-static-link.scm -o a.out
384./a.out
385
386echo "======================================== port tests ..."
387$interpret -s port-tests.scm
388
389echo "======================================== read-lines tests ..."
390$interpret -s read-lines-tests.scm
391
392echo "======================================== fixnum tests ..."
393$compile fixnum-tests.scm
394./a.out
395$compile -unsafe fixnum-tests.scm
396./a.out
397
398echo "======================================== random number tests ..."
399$interpret -s random-tests.scm
400
401echo "======================================== string->number tests ..."
402$interpret -s numbers-string-conversion-tests.scm
403$compile -specialize numbers-string-conversion-tests.scm
404./a.out
405
406echo "======================================== basic numeric ops tests ..."
407$interpret -s numbers-test.scm
408$compile -specialize numbers-test.scm
409./a.out
410
411echo "======================================== Alex Shinn's numeric ops tests ..."
412$interpret -s numbers-test-ashinn.scm
413$compile -specialize numbers-test-ashinn.scm
414./a.out
415
416echo "======================================== Gauche's numeric ops tests ..."
417$interpret -s numbers-test-gauche.scm
418$compile -specialize numbers-test-gauche.scm
419./a.out
420
421echo "======================================== srfi-4 tests ..."
422$interpret -s srfi-4-tests.scm
423
424echo "======================================== condition tests ..."
425$interpret -s condition-tests.scm
426
427echo "======================================== data-structures tests ..."
428$interpret -s data-structures-tests.scm
429
430echo "======================================== path tests ..."
431$interpret -bnq path-tests.scm
432
433echo "======================================== srfi-45 tests ..."
434$interpret -s srfi-45-tests.scm
435
436echo "======================================== posix tests ..."
437$compile posix-tests.scm
438./a.out
439
440echo "======================================== file access tests ..."
441$interpret -s file-access-tests.scm
442
443echo "======================================== find-files tests ..."
444$interpret -bnq test-find-files.scm
445
446echo "======================================== create-temporary-file tests ..."
447$interpret -bnq test-create-temporary-file.scm
448
449echo "======================================== record-renaming tests ..."
450$interpret -bnq record-rename-test.scm
451
452echo "======================================== regular expression tests ..."
453$interpret -bnq test-irregex.scm
454$interpret -bnq test-glob.scm
455
456echo "======================================== compiler/nursery stress test ..."
457for s in 100000 120000 200000 250000 300000 350000 400000 450000 500000; do
458    echo "  $s"
459    ${CHICKEN} -ignore-repository ../port.scm -:s$s -output-file tmp.c -include-path ${TEST_DIR}/..
460done
461
462echo "======================================== heap literal stress test ..."
463$compile heap-literal-stress-test.scm
464for s in 100000 120000 200000 250000 300000 350000 400000 450000 500000; do
465  echo "  $s"
466  ./a.out -:d -:g -:hi$s
467done
468
469echo "======================================== weak pointer test ..."
470$compile weak-pointer-test.scm
471./a.out
472
473echo "======================================== symbol-GC tests ..."
474$compile symbolgc-tests.scm
475./a.out
476
477echo "======================================== finalizer tests ..."
478$interpret -s test-finalizers.scm
479$compile test-finalizers.scm
480./a.out
481$compile finalizer-error-test.scm
482echo "expect an error message here:"
483./a.out -:hg101
484$compile test-finalizers-2.scm
485./a.out
486
487echo "======================================== locative stress test ..."
488$compile locative-stress-test.scm
489./a.out
490
491echo "======================================== syntax-rules stress test ..."
492$time $interpret -bnq syntax-rule-stress-test.scm
493
494echo "======================================== include test ..."
495mkdir -p a/b
496echo > a/b/ok.scm
497echo '(include "a/b/ok.scm")' > a/b/include.scm
498$compile -analyze-only a/b/include.scm
499echo '(include "b/ok.scm")' > a/b/include.scm
500$compile -analyze-only a/b/include.scm -include-path a
501echo '(include-relative "ok.scm")' > a/b/include.scm
502$compile -analyze-only a/b/include.scm
503echo '(include-relative "b/ok.scm")' > a/include.scm
504$compile -analyze-only a/include.scm
505echo '(include-relative "b/ok.scm")' > a/b/include.scm
506$compile -analyze-only a/b/include.scm -include-path a
507echo > a/b/other.scm
508# make sure first include doesn't change state for second:
509echo '(include-relative "b/ok.scm") (include-relative "b/other.scm")' > a/include.scm
510$compile -analyze-only a/include.scm
511echo '(include-relative "ok.scm")' > a/b/other.scm
512echo '(include-relative "b/other.scm")' > a/include.scm
513$compile -analyze-only a/include.scm
514echo '(include-relative "b/other.scm") (let () (include-relative "b/ok.scm") (include-relative "b/ok.scm"))' > a/include.scm
515$compile -analyze-only a/include.scm
516rm -r a
517
518echo "======================================== executable tests ..."
519$compile executable-tests.scm
520./a.out "$TEST_DIR/a.out"
521
522echo "======================================== user pass tests ..."
523$compile -extend user-pass-tests.scm null.scm
524
525echo "======================================== embedding (1) ..."
526$compile embedded1.c
527./a.out
528
529echo "======================================== embedding (2) ..."
530$compile -e embedded2.scm
531./a.out
532
533echo "======================================== embedding (3) ..."
534$compile -e embedded3.c embedded4.scm
535./a.out
536
537echo "======================================== linking tests ..."
538$compile_r -unit reverser reverser/tags/1.0/reverser.scm -J -c
539mv reverser/tags/1.0/reverser.o* ./
540$compile_r -link reverser linking-tests.scm -o a.out
541./a.out
542$compile_r -link reverser linking-tests.scm -o a.out -static
543./a.out
544mv reverser.o* reverser.import.scm "$CHICKEN_INSTALL_REPOSITORY"
545$compile_r -link reverser linking-tests.scm -o a.out
546./a.out
547$compile_r -link reverser linking-tests.scm -o a.out -static
548./a.out
549
550echo "======================================== private repository test ..."
551mkdir -p tmp
552$compile private-repository-test.scm -private-repository -o tmp/xxx
553tmp/xxx ${TEST_DIR}/tmp
554# This MUST be `pwd`: ${PWD} is not portable, and ${TEST_DIR} breaks mingw
555PATH=`pwd`/tmp:$PATH xxx ${TEST_DIR}/tmp
556# this may crash, if the PATH contains a non-matching libchicken.dll on Windows:
557#PATH=$PATH:${TEST_DIR}/tmp xxx ${TEST_DIR}/tmp
558
559echo "======================================== multiple return values tests ..."
560$interpret -s multiple-values.scm
561$compile multiple-values.scm
562./a.out
563
564echo "======================================== version module tests ..."
565$interpret -bnq version-module-tests.scm
566
567echo "======================================== done. All tests passed."
Trap