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