~ chicken-core (master) /tests/runtests.sh
Trap1#!/bin/sh2# runtests.sh - run CHICKEN testsuite3#4# - Note: this needs a proper shell, so it will not work with plain mingw5# (just the compiler and the Windows shell, without MSYS)67set -e8if [ $(uname) = Windows_NT ]; then9 MSYSTEM=110fi11TEST_DIR=`pwd`12if test -z "$MSYSTEM"; then13 PATH_SEP=':'14else15 PATH_SEP=';'16fi1718unset CSC_OPTIONS1920DYLD_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 into24# 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}2728export DYLD_LIBRARY_PATH LD_LIBRARY_PATH LIBRARY_PATH PATH2930case `uname` in31 AIX)32 DIFF_OPTS=-b ;;33 *)34 DIFF_OPTS=-bu ;;35esac3637CHICKEN=${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-repository42CHICKEN_REPOSITORY_PATH="${TEST_DIR}/..${PATH_SEP}${CHICKEN_INSTALL_REPOSITORY}"4344export CHICKEN_INSTALL_REPOSITORY CHICKEN_REPOSITORY_PATH4546TYPESDB=../types.db47COMPILE_OPTIONS="-v -compiler ${CHICKEN} -I${TEST_DIR}/.. -L${TEST_DIR}/.. -include-path ${TEST_DIR}/.. -libdir ${TEST_DIR}/.. -rpath ${TEST_DIR}/.."4849compile="../${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=time5455# Check for a "time" command, since some systems don't ship with a56# 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 +e59$time true >/dev/null 2>/dev/null60test $? -eq 127 && time=61set -e6263rm -fr *.exe *.so *.o *.obj *.out *.import.* ../foo.import.* test-repository64mkdir -p test-repository65cp $TYPESDB test-repository/types.db6667echo "======================================== repository search path ..."68if test -z "$MSYSTEM"; then69 export -p >./env.out70 unset CHICKEN_REPOSITORY_PATH71 $interpret -s repository-path-default.scm72 . ./env.out73else74 env -u CHICKEN_REPOSITORY_PATH $interpret -s repository-path-default.scm75fi76$compile_s sample-module.scm -j sample-module77cp sample-module.so $CHICKEN_INSTALL_REPOSITORY78cp sample-module.import.scm $CHICKEN_INSTALL_REPOSITORY79$interpret -s repository-path.scm "${TEST_DIR}/.." "${TEST_DIR}/test-repository"8081echo "======================================== types.db consistency ..."82$interpret -s types-db-consistency.scm ${TYPESDB}8384echo "======================================== version tests ..."85$compile version-tests.scm86./a.out8788echo "======================================== compiler tests ..."89$compile compiler-tests.scm90./a.out9192echo "======================================== FFI tests ..."93$compile ffi-tests.scm94./a.out95$compile -d3 ffi-tests-2.scm96./a.out9798echo "======================================== csc tests ..."99$interpret -s csc-tests.scm100101echo "======================================== compiler inlining tests ..."102$compile_r inline-me.scm -s -J -oi inline-me.inline103$compile inlining-tests.scm -optimize-level 3104./a.out105$compile inline-unroll.scm -optimize-level 3106./a.out107108echo "======================================== compiler message tests ..."109$compile -analyze-only messages-test.scm 2>messages.out110diff $DIFF_OPTS messages.expected messages.out111112echo "======================================== optimizer tests ..."113$compile rest-arg-tests.scm -specialize114./a.out115116echo "======================================== profiler tests ..."117$compile null.scm -profile -profile-name TEST.profile118./a.out119$CHICKEN_PROFILE TEST.profile120121echo "======================================== scrutiny tests ..."122$compile scrutinizer-tests.scm -analyze-only123$compile typematch-tests.scm -specialize -no-warnings124./a.out125126$compile test-scrutinizer-message-format.scm -analyze-only -specialize 2>scrutinizer-message-format.out || true127$compile scrutiny-tests.scm -analyze-only -specialize 2>scrutiny.out128$compile scrutiny-tests-2.scm -analyze-only -specialize 2>scrutiny-2.out129$compile specialization-tests.scm -analyze-only -specialize -specialize 2>specialization.out130131# Replace foo123 -> fooXX so gensyms don't trigger failures132$compile redact-gensyms.scm -o redact-gensyms133./redact-gensyms "tmp,g,scm:,a,b" < scrutinizer-message-format.out > scrutinizer-message-format.redacted134./redact-gensyms < scrutiny-2.out > scrutiny-2.redacted135./redact-gensyms < scrutiny.out > scrutiny.redacted136./redact-gensyms < specialization.out > specialization.redacted137138diff $DIFF_OPTS scrutinizer-message-format.expected scrutinizer-message-format.redacted139diff $DIFF_OPTS scrutiny.expected scrutiny.redacted140diff $DIFF_OPTS scrutiny-2.expected scrutiny-2.redacted141diff $DIFF_OPTS specialization.expected specialization.redacted142143$compile scrutiny-tests-3.scm -specialize -block144./a.out145146$compile scrutiny-tests-strict.scm -strict-types -specialize147./a.out148149echo "======================================== line number database ..."150$compile -O3 test-line-numbers.scm 2> test-line-numbers.out151diff $DIFF_OPTS test-line-numbers.expected test-line-numbers.out152./a.out153154echo "======================================== 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 foo158./a.out159$compile specialization-test-2.scm -types foo.types -types specialization-test-2.types -specialize -debug ox160./a.out161rm -f foo.types foo.import.*162163echo "======================================== specialization benchmark ..."164$compile fft.scm -O2 -local -d0 -disable-interrupts -b -o fft1.out165$compile fft.scm -O2 -local -specialize -debug x -d0 -disable-interrupts -b -o fft2.out -specialize166echo "normal:"167$time ./fft1.out 1000 7168echo "specialized:"169$time ./fft2.out 1000 7170171echo "======================================== unboxing benchmark ..."172$compile fft.scm -O2 -local -d0 -disable-interrupts -b -o fft1.out173$compile fft.scm -O4 -debug x -d0 -disable-interrupts -b -o fft2.out174echo "normal:"175$time ./fft1.out 1000 7176echo "unboxing:"177$time ./fft2.out 1000 7178179echo "======================================== callback tests ..."180$compile -extend c-id-valid.scm callback-tests.scm181./a.out182183if ./a.out twice; then184 echo "double-return from callback didn't fail"185 exit 1186else187 echo "double-return from callback failed as it should."188fi189190echo "======================================== runtime tests ..."191$interpret -s apply-test.scm192$compile apply-test.scm193./a.out194if ./a.out -:A10k; then195 echo "apply test with limited temp stack didn't fail"196 exit 1197else198 echo "apply test with limited temp stack failed as it should."199fi200201$compile test-gc-hooks.scm202./a.out203204echo "======================================== library tests ..."205$interpret -s library-tests.scm206$compile -specialize library-tests.scm207./a.out208$interpret -s records-and-setters-test.scm209$compile records-and-setters-test.scm210./a.out211$interpret -s record-printer-test.scm212$compile record-printer-test.scm213./a.out214215echo "======================================== unicode tests ..."216$interpret -s unicode-tests.scm217$compile -specialize unicode-tests.scm218./a.out219$interpret -s invalid-utf-test.scm220$interpret -s file-encoding-test.scm221222echo "======================================== reader tests ..."223$interpret -s reader-tests.scm224225echo "======================================== dynamic-wind tests ..."226$interpret -s dwindtst.scm >dwindtst.out227diff $DIFF_OPTS dwindtst.expected dwindtst.out228$compile dwindtst.scm229./a.out >dwindtst.out230diff $DIFF_OPTS dwindtst.expected dwindtst.out231232echo "======================================== lolevel tests ..."233$interpret -s lolevel-tests.scm234$compile -specialize lolevel-tests.scm235./a.out236237echo "======================================== arithmetic tests ..."238$interpret -D check -s arithmetic-test.scm239240echo "======================================== pretty-printer tests ..."241$interpret -s pp-test.scm242243echo "======================================== evaluation environment tests ..."244$interpret -s environment-tests.scm245246echo "======================================== syntax tests ..."247$interpret -s syntax-tests.scm248249echo "======================================== syntax tests (compiled) ..."250$compile syntax-tests.scm251./a.out252253echo "======================================== syntax tests (v2, compiled) ..."254$compile syntax-tests-2.scm255./a.out256257echo "======================================== 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 foo260$compile_s foo.import.scm261$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)))'262263echo "======================================== reexport tests ..."264$interpret -bnq reexport-tests.scm265$compile reexport-tests.scm266./a.out267rm -f reexport-m*.import*268$compile_s reexport-m1.scm -J269$compile_s reexport-m1.import.scm270$interpret -s reexport-m2.scm271$compile reexport-m2.scm272./a.out273$compile_s reexport-m3.scm -J274$compile_s reexport-m4.scm -J275$compile_s reexport-m5.scm -J276$compile_s reexport-m6.scm -J277$compile_s reexport-m7.scm -J278$compile_s reexport-m8.scm -J279$compile_s reexport-m9.scm -J280$compile_s reexport-m10.scm -J281$compile reexport-tests-2.scm282./a.out283284echo "======================================== functor tests ..."285$interpret -bnq simple-functors-test.scm286$compile simple-functors-test.scm287./a.out288$interpret -bnq functor-tests.scm289$compile functor-tests.scm290./a.out291$compile -s square-functor.scm -J292$compile -s square-functor.import.scm293$interpret -bnq use-square-functor.scm294$compile use-square-functor.scm295./a.out296$compile -s use-square-functor.scm -J297$interpret -nqe '(require-library use-square-functor)' -e '(import sf1)' -e '(import sf2)'298rm -f sf1.import.* sf2.import.* lst.import.* mod.import.*299300echo "======================================== compiler syntax tests ..."301$compile compiler-syntax-tests.scm302./a.out303304echo "======================================== import tests ..."305$interpret -bnq import-tests.scm306307echo "======================================== import library tests ..."308rm -f ../foo.import.* foo.import.*309$compile import-library-test1.scm -emit-import-library foo310$interpret -s import-library-test2.scm311$compile_s foo.import.scm -o foo.import.so312$interpret -s import-library-test2.scm313$compile import-library-test2.scm314./a.out315rm -f foo.import.*316317echo "======================================== optionals test ..."318$interpret -s test-optional.scm319$compile test-optional.scm320./a.out321322echo "======================================== syntax tests (matchable) ..."323$interpret matchable.scm -s match-test.scm324325echo "======================================== syntax tests (loopy-loop) ..."326$interpret -s loopy-test.scm327328echo "======================================== r4rstest ..."329echo "(expect mult-float-print-test to fail)"330$interpret -e '(set! ##sys#procedure->string (constantly "#<procedure>"))' \331 -i -s r4rstest.scm >r4rstest.out332333diff $DIFF_OPTS r4rstest.expected r4rstest.out334335echo "======================================== syntax tests (r5rs_pitfalls) ..."336echo "(expect two failures)"337$interpret -i -s r5rs_pitfalls.scm338339echo "======================================== r7rs tests ..."340$interpret -s r7rs-tests.scm341$interpret -s r7rs-tests-2.scm342$interpret -s r7rs-library-tests.scm343$interpret -s life.scm344345echo "======================================== module tests ..."346$interpret -include-path ${TEST_DIR}/.. -s module-tests.scm347$interpret -include-path ${TEST_DIR}/.. -s module-tests-2.scm348349echo "======================================== 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"354355echo "======================================== module tests (compiled) ..."356$compile module-tests-compiled.scm357./a.out358$compile module-static-eval-compiled.scm359./a.out360$compile -static module-static-eval-compiled.scm361./a.out362363echo "======================================== module tests (chained) ..."364rm -f m*.import.* test-chained-modules.so365$interpret -bnq test-chained-modules.scm366$compile_s test-chained-modules.scm -j m3367$compile_s m3.import.scm368$interpret -bn test-chained-modules.so369$interpret -bn test-chained-modules.so -e '(import m3) (s3)'370371echo "======================================== module tests (ec) ..."372rm -f ec.so ec.import.*373$interpret -bqn ec.scm ec-tests.scm374$compile_s ec.scm -emit-import-library ec -o ec.so375$compile_s ec.import.scm -o ec.import.so376$interpret -bnq ec.so ec-tests.scm377# $compile ec-tests.scm378# ./a.out # takes ages to compile379380echo "======================================== module tests (static link) ..."381$compile_r -static -unit sample-module -J -c sample-module.scm382mv sample-module.link sample-module.import.scm sample-module.o* "$CHICKEN_INSTALL_REPOSITORY"383$compile_r -static module-static-link.scm -o a.out384./a.out385386echo "======================================== port tests ..."387$interpret -s port-tests.scm388389echo "======================================== read-lines tests ..."390$interpret -s read-lines-tests.scm391392echo "======================================== fixnum tests ..."393$compile fixnum-tests.scm394./a.out395$compile -unsafe fixnum-tests.scm396./a.out397398echo "======================================== random number tests ..."399$interpret -s random-tests.scm400401echo "======================================== string->number tests ..."402$interpret -s numbers-string-conversion-tests.scm403$compile -specialize numbers-string-conversion-tests.scm404./a.out405406echo "======================================== basic numeric ops tests ..."407$interpret -s numbers-test.scm408$compile -specialize numbers-test.scm409./a.out410411echo "======================================== Alex Shinn's numeric ops tests ..."412$interpret -s numbers-test-ashinn.scm413$compile -specialize numbers-test-ashinn.scm414./a.out415416echo "======================================== Gauche's numeric ops tests ..."417$interpret -s numbers-test-gauche.scm418$compile -specialize numbers-test-gauche.scm419./a.out420421echo "======================================== srfi-4 tests ..."422$interpret -s srfi-4-tests.scm423424echo "======================================== condition tests ..."425$interpret -s condition-tests.scm426427echo "======================================== data-structures tests ..."428$interpret -s data-structures-tests.scm429430echo "======================================== path tests ..."431$interpret -bnq path-tests.scm432433echo "======================================== srfi-45 tests ..."434$interpret -s srfi-45-tests.scm435436echo "======================================== posix tests ..."437$compile posix-tests.scm438./a.out439440echo "======================================== file access tests ..."441$interpret -s file-access-tests.scm442443echo "======================================== find-files tests ..."444$interpret -bnq test-find-files.scm445446echo "======================================== create-temporary-file tests ..."447$interpret -bnq test-create-temporary-file.scm448449echo "======================================== record-renaming tests ..."450$interpret -bnq record-rename-test.scm451452echo "======================================== regular expression tests ..."453$interpret -bnq test-irregex.scm454$interpret -bnq test-glob.scm455456echo "======================================== compiler/nursery stress test ..."457for s in 100000 120000 200000 250000 300000 350000 400000 450000 500000; do458 echo " $s"459 ${CHICKEN} -ignore-repository ../port.scm -:s$s -output-file tmp.c -include-path ${TEST_DIR}/..460done461462echo "======================================== heap literal stress test ..."463$compile heap-literal-stress-test.scm464for s in 100000 120000 200000 250000 300000 350000 400000 450000 500000; do465 echo " $s"466 ./a.out -:d -:g -:hi$s467done468469echo "======================================== weak pointer test ..."470$compile weak-pointer-test.scm471./a.out472473echo "======================================== symbol-GC tests ..."474$compile symbolgc-tests.scm475./a.out476477echo "======================================== finalizer tests ..."478$interpret -s test-finalizers.scm479$compile test-finalizers.scm480./a.out481$compile finalizer-error-test.scm482echo "expect an error message here:"483./a.out -:hg101484$compile test-finalizers-2.scm485./a.out486487echo "======================================== locative stress test ..."488$compile locative-stress-test.scm489./a.out490491echo "======================================== syntax-rules stress test ..."492$time $interpret -bnq syntax-rule-stress-test.scm493494echo "======================================== include test ..."495mkdir -p a/b496echo > a/b/ok.scm497echo '(include "a/b/ok.scm")' > a/b/include.scm498$compile -analyze-only a/b/include.scm499echo '(include "b/ok.scm")' > a/b/include.scm500$compile -analyze-only a/b/include.scm -include-path a501echo '(include-relative "ok.scm")' > a/b/include.scm502$compile -analyze-only a/b/include.scm503echo '(include-relative "b/ok.scm")' > a/include.scm504$compile -analyze-only a/include.scm505echo '(include-relative "b/ok.scm")' > a/b/include.scm506$compile -analyze-only a/b/include.scm -include-path a507echo > a/b/other.scm508# make sure first include doesn't change state for second:509echo '(include-relative "b/ok.scm") (include-relative "b/other.scm")' > a/include.scm510$compile -analyze-only a/include.scm511echo '(include-relative "ok.scm")' > a/b/other.scm512echo '(include-relative "b/other.scm")' > a/include.scm513$compile -analyze-only a/include.scm514echo '(include-relative "b/other.scm") (let () (include-relative "b/ok.scm") (include-relative "b/ok.scm"))' > a/include.scm515$compile -analyze-only a/include.scm516rm -r a517518echo "======================================== executable tests ..."519$compile executable-tests.scm520./a.out "$TEST_DIR/a.out"521522echo "======================================== user pass tests ..."523$compile -extend user-pass-tests.scm null.scm524525echo "======================================== embedding (1) ..."526$compile embedded1.c527./a.out528529echo "======================================== embedding (2) ..."530$compile -e embedded2.scm531./a.out532533echo "======================================== embedding (3) ..."534$compile -e embedded3.c embedded4.scm535./a.out536537echo "======================================== linking tests ..."538$compile_r -unit reverser reverser/tags/1.0/reverser.scm -J -c539mv reverser/tags/1.0/reverser.o* ./540$compile_r -link reverser linking-tests.scm -o a.out541./a.out542$compile_r -link reverser linking-tests.scm -o a.out -static543./a.out544mv reverser.o* reverser.import.scm "$CHICKEN_INSTALL_REPOSITORY"545$compile_r -link reverser linking-tests.scm -o a.out546./a.out547$compile_r -link reverser linking-tests.scm -o a.out -static548./a.out549550echo "======================================== private repository test ..."551mkdir -p tmp552$compile private-repository-test.scm -private-repository -o tmp/xxx553tmp/xxx ${TEST_DIR}/tmp554# This MUST be `pwd`: ${PWD} is not portable, and ${TEST_DIR} breaks mingw555PATH=`pwd`/tmp:$PATH xxx ${TEST_DIR}/tmp556# this may crash, if the PATH contains a non-matching libchicken.dll on Windows:557#PATH=$PATH:${TEST_DIR}/tmp xxx ${TEST_DIR}/tmp558559echo "======================================== multiple return values tests ..."560$interpret -s multiple-values.scm561$compile multiple-values.scm562./a.out563564echo "======================================== version module tests ..."565$interpret -bnq version-module-tests.scm566567echo "======================================== done. All tests passed."