~ 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
 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 clustering-tests.scm -clustering
110./a.out
111
112$compile rest-arg-tests.scm -specialize
113./a.out
114
115echo "======================================== profiler tests ..."
116$compile null.scm -profile -profile-name TEST.profile
117./a.out
118$CHICKEN_PROFILE TEST.profile
119
120echo "======================================== scrutiny tests ..."
121$compile scrutinizer-tests.scm -analyze-only
122$compile typematch-tests.scm -specialize -no-warnings
123./a.out
124
125$compile test-scrutinizer-message-format.scm -analyze-only -specialize 2>scrutinizer-message-format.out || true
126$compile scrutiny-tests.scm -analyze-only -specialize 2>scrutiny.out
127$compile scrutiny-tests-2.scm -analyze-only -specialize 2>scrutiny-2.out
128$compile specialization-tests.scm -analyze-only -specialize -specialize 2>specialization.out
129
130# Replace foo123 -> fooXX so gensyms don't trigger failures
131$compile redact-gensyms.scm -o redact-gensyms
132./redact-gensyms "tmp,g,scm:,a,b" < scrutinizer-message-format.out > scrutinizer-message-format.redacted
133./redact-gensyms < scrutiny-2.out > scrutiny-2.redacted
134./redact-gensyms < scrutiny.out > scrutiny.redacted
135./redact-gensyms < specialization.out > specialization.redacted
136
137diff $DIFF_OPTS scrutinizer-message-format.expected scrutinizer-message-format.redacted
138diff $DIFF_OPTS scrutiny.expected scrutiny.redacted
139diff $DIFF_OPTS scrutiny-2.expected scrutiny-2.redacted
140diff $DIFF_OPTS specialization.expected specialization.redacted
141
142$compile scrutiny-tests-3.scm -specialize -block
143./a.out
144
145$compile scrutiny-tests-strict.scm -strict-types -specialize
146./a.out
147
148echo "======================================== line number database ..."
149$compile -O3 test-line-numbers.scm 2> test-line-numbers.out
150diff $DIFF_OPTS test-line-numbers.expected test-line-numbers.out
151./a.out
152
153echo "======================================== specialization tests ..."
154rm -f foo.types foo.import.*
155$compile specialization-test-1.scm -emit-types-file foo.types -specialize \
156  -debug ox -emit-import-library foo
157./a.out
158$compile specialization-test-2.scm -types foo.types -types specialization-test-2.types -specialize -debug ox
159./a.out
160rm -f foo.types foo.import.*
161
162echo "======================================== specialization benchmark ..."
163$compile fft.scm -O2 -local -d0 -disable-interrupts -b -o fft1.out
164$compile fft.scm -O2 -local -specialize -debug x -d0 -disable-interrupts -b -o fft2.out -specialize
165echo "normal:"
166$time ./fft1.out 1000 7
167echo "specialized:"
168$time ./fft2.out 1000 7
169
170echo "======================================== unboxing benchmark ..."
171$compile fft.scm -O2 -local -d0 -disable-interrupts -b -o fft1.out
172$compile fft.scm -O4 -debug x -d0 -disable-interrupts -b -o fft2.out
173echo "normal:"
174$time ./fft1.out 1000 7
175echo "unboxing:"
176$time ./fft2.out 1000 7
177
178echo "======================================== callback tests ..."
179$compile -extend c-id-valid.scm callback-tests.scm
180./a.out
181
182if ./a.out twice; then
183    echo "double-return from callback didn't fail"
184    exit 1
185else
186    echo "double-return from callback failed as it should."
187fi
188
189echo "======================================== runtime tests ..."
190$interpret -s apply-test.scm
191$compile apply-test.scm
192./a.out
193if ./a.out -:A10k; then
194    echo "apply test with limited temp stack didn't fail"
195    exit 1
196else
197    echo "apply test with limited temp stack failed as it should."
198fi
199
200$compile test-gc-hooks.scm
201./a.out
202
203echo "======================================== library tests ..."
204$interpret -s library-tests.scm
205$compile -specialize library-tests.scm
206./a.out
207$interpret -s records-and-setters-test.scm
208$compile records-and-setters-test.scm
209./a.out
210$interpret -s record-printer-test.scm
211$compile record-printer-test.scm
212./a.out
213
214echo "======================================== unicode tests ..."
215$interpret -s unicode-tests.scm
216$compile -specialize unicode-tests.scm
217./a.out
218$interpret -s invalid-utf-test.scm
219$interpret -s file-encoding-test.scm
220
221echo "======================================== reader tests ..."
222$interpret -s reader-tests.scm
223
224echo "======================================== dynamic-wind tests ..."
225$interpret -s dwindtst.scm >dwindtst.out
226diff $DIFF_OPTS dwindtst.expected dwindtst.out
227$compile dwindtst.scm
228./a.out >dwindtst.out
229diff $DIFF_OPTS dwindtst.expected dwindtst.out
230
231echo "======================================== lolevel tests ..."
232$interpret -s lolevel-tests.scm
233$compile -specialize lolevel-tests.scm
234./a.out
235
236echo "======================================== arithmetic tests ..."
237$interpret -D check -s arithmetic-test.scm
238
239echo "======================================== pretty-printer tests ..."
240$interpret -s pp-test.scm
241
242echo "======================================== evaluation environment tests ..."
243$interpret -s environment-tests.scm
244
245echo "======================================== syntax tests ..."
246$interpret -s syntax-tests.scm
247
248echo "======================================== syntax tests (compiled) ..."
249$compile syntax-tests.scm
250./a.out
251
252echo "======================================== syntax tests (v2, compiled) ..."
253$compile syntax-tests-2.scm
254./a.out
255
256echo "======================================== meta-syntax tests ..."
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$compile_s meta-syntax-test.scm -j foo
259$compile_s foo.import.scm
260$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)))"
261
262echo "======================================== reexport tests ..."
263$interpret -bnq reexport-tests.scm
264$compile reexport-tests.scm
265./a.out
266rm -f reexport-m*.import*
267$compile_s reexport-m1.scm -J
268$compile_s reexport-m1.import.scm
269$interpret -s reexport-m2.scm
270$compile reexport-m2.scm
271./a.out
272$compile_s reexport-m3.scm -J
273$compile_s reexport-m4.scm -J
274$compile_s reexport-m5.scm -J
275$compile_s reexport-m6.scm -J
276$compile_s reexport-m7.scm -J
277$compile_s reexport-m8.scm -J
278$compile_s reexport-m9.scm -J
279$compile_s reexport-m10.scm -J
280$compile reexport-tests-2.scm
281./a.out
282
283echo "======================================== functor tests ..."
284$interpret -bnq simple-functors-test.scm
285$compile simple-functors-test.scm
286./a.out
287$interpret -bnq functor-tests.scm
288$compile functor-tests.scm
289./a.out
290$compile -s square-functor.scm -J
291$compile -s square-functor.import.scm
292$interpret -bnq use-square-functor.scm
293$compile use-square-functor.scm
294./a.out
295$compile -s use-square-functor.scm -J
296$interpret -nqe '(require-library use-square-functor)' -e '(import sf1)' -e '(import sf2)'
297rm -f sf1.import.* sf2.import.* lst.import.* mod.import.*
298
299echo "======================================== compiler syntax tests ..."
300$compile compiler-syntax-tests.scm
301./a.out
302
303echo "======================================== import tests ..."
304$interpret -bnq import-tests.scm
305
306echo "======================================== import library tests ..."
307rm -f ../foo.import.* foo.import.*
308$compile import-library-test1.scm -emit-import-library foo
309$interpret -s import-library-test2.scm
310$compile_s foo.import.scm -o foo.import.so
311$interpret -s import-library-test2.scm
312$compile import-library-test2.scm
313./a.out
314rm -f foo.import.*
315
316echo "======================================== optionals test ..."
317$interpret -s test-optional.scm
318$compile test-optional.scm
319./a.out
320
321echo "======================================== syntax tests (matchable) ..."
322$interpret matchable.scm -s match-test.scm
323
324echo "======================================== syntax tests (loopy-loop) ..."
325$interpret -s loopy-test.scm
326
327echo "======================================== r4rstest ..."
328echo "(expect mult-float-print-test to fail)"
329$interpret -e '(set! ##sys#procedure->string (constantly "#<procedure>"))' \
330  -i -s r4rstest.scm >r4rstest.out
331
332diff $DIFF_OPTS r4rstest.expected r4rstest.out
333
334echo "======================================== syntax tests (r5rs_pitfalls) ..."
335echo "(expect two failures)"
336$interpret -i -s r5rs_pitfalls.scm
337
338echo "======================================== r7rs tests ..."
339$interpret -s r7rs-tests.scm
340$interpret -s r7rs-tests-2.scm
341$interpret -s life.scm
342
343echo "======================================== module tests ..."
344$interpret -include-path ${TEST_DIR}/.. -s module-tests.scm
345$interpret -include-path ${TEST_DIR}/.. -s module-tests-2.scm
346
347echo "======================================== module tests (command line options) ..."
348module="test-$(date +%s)"
349$compile test.scm -A -w -j "$module" -module "$module"
350$interpret -e "(import-syntax $module)"
351rm -f "$module.import.scm"
352
353echo "======================================== module tests (compiled) ..."
354$compile module-tests-compiled.scm
355./a.out
356$compile module-static-eval-compiled.scm
357./a.out
358$compile -static module-static-eval-compiled.scm
359./a.out
360
361echo "======================================== module tests (chained) ..."
362rm -f m*.import.* test-chained-modules.so
363$interpret -bnq test-chained-modules.scm
364$compile_s test-chained-modules.scm -j m3
365$compile_s m3.import.scm
366$interpret -bn test-chained-modules.so
367$interpret -bn test-chained-modules.so -e '(import m3) (s3)'
368
369echo "======================================== module tests (ec) ..."
370rm -f ec.so ec.import.*
371$interpret -bqn ec.scm ec-tests.scm
372$compile_s ec.scm -emit-import-library ec -o ec.so
373$compile_s ec.import.scm -o ec.import.so
374$interpret -bnq ec.so ec-tests.scm
375# $compile ec-tests.scm
376# ./a.out        # takes ages to compile
377
378echo "======================================== module tests (static link) ..."
379$compile_r -static -unit sample-module -J -c sample-module.scm
380mv sample-module.link sample-module.import.scm sample-module.o* "$CHICKEN_INSTALL_REPOSITORY"
381$compile_r -static module-static-link.scm -o a.out
382./a.out
383
384echo "======================================== port tests ..."
385$interpret -s port-tests.scm
386
387echo "======================================== read-lines tests ..."
388$interpret -s read-lines-tests.scm
389
390echo "======================================== fixnum tests ..."
391$compile fixnum-tests.scm
392./a.out
393$compile -unsafe fixnum-tests.scm
394./a.out
395
396echo "======================================== random number tests ..."
397$interpret -s random-tests.scm
398
399echo "======================================== string->number tests ..."
400$interpret -s numbers-string-conversion-tests.scm
401$compile -specialize numbers-string-conversion-tests.scm
402./a.out
403
404echo "======================================== basic numeric ops tests ..."
405$interpret -s numbers-test.scm
406$compile -specialize numbers-test.scm
407./a.out
408
409echo "======================================== Alex Shinn's numeric ops tests ..."
410$interpret -s numbers-test-ashinn.scm
411$compile -specialize numbers-test-ashinn.scm
412./a.out
413
414echo "======================================== Gauche's numeric ops tests ..."
415$interpret -s numbers-test-gauche.scm
416$compile -specialize numbers-test-gauche.scm
417./a.out
418
419echo "======================================== srfi-4 tests ..."
420$interpret -s srfi-4-tests.scm
421
422echo "======================================== condition tests ..."
423$interpret -s condition-tests.scm
424
425echo "======================================== data-structures tests ..."
426$interpret -s data-structures-tests.scm
427
428echo "======================================== path tests ..."
429$interpret -bnq path-tests.scm
430
431echo "======================================== srfi-45 tests ..."
432$interpret -s srfi-45-tests.scm
433
434echo "======================================== posix tests ..."
435$compile posix-tests.scm
436./a.out
437
438echo "======================================== file access tests ..."
439if test -n "$MSYSTEM"; then
440  $interpret -s file-access-tests.scm //
441  $interpret -s file-access-tests.scm \\
442else
443  $interpret -s file-access-tests.scm /
444fi
445
446echo "======================================== find-files tests ..."
447$interpret -bnq test-find-files.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 "======================================== done. All tests passed."
Trap