~ 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=';'16fi1718DYLD_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 into22# 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}2526export DYLD_LIBRARY_PATH LD_LIBRARY_PATH LIBRARY_PATH PATH2728case `uname` in29 AIX)30 DIFF_OPTS=-b ;;31 *)32 DIFF_OPTS=-bu ;;33esac3435CHICKEN=${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-repository40CHICKEN_REPOSITORY_PATH="${TEST_DIR}/..${PATH_SEP}${CHICKEN_INSTALL_REPOSITORY}"4142export CHICKEN_INSTALL_REPOSITORY CHICKEN_REPOSITORY_PATH4344TYPESDB=../types.db45COMPILE_OPTIONS="-v -compiler ${CHICKEN} -I${TEST_DIR}/.. -L${TEST_DIR}/.. -include-path ${TEST_DIR}/.. -libdir ${TEST_DIR}/.. -rpath ${TEST_DIR}/.."4647compile="../${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=time5253# Check for a "time" command, since some systems don't ship with a54# 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 +e57$time true >/dev/null 2>/dev/null58test $? -eq 127 && time=59set -e6061rm -fr *.exe *.so *.o *.obj *.out *.import.* ../foo.import.* test-repository62mkdir -p test-repository63cp $TYPESDB test-repository/types.db6465echo "======================================== repository search path ..."66if test -z "$MSYSTEM"; then67 export -p >./env.out68 unset CHICKEN_REPOSITORY_PATH69 $interpret -s repository-path-default.scm70 . ./env.out71else72 env -u CHICKEN_REPOSITORY_PATH $interpret -s repository-path-default.scm73fi74$compile_s sample-module.scm -j sample-module75cp sample-module.so $CHICKEN_INSTALL_REPOSITORY76cp sample-module.import.scm $CHICKEN_INSTALL_REPOSITORY77$interpret -s repository-path.scm "${TEST_DIR}/.." "${TEST_DIR}/test-repository"7879echo "======================================== types.db consistency ..."80$interpret -s types-db-consistency.scm ${TYPESDB}8182echo "======================================== version tests ..."83$compile version-tests.scm84./a.out8586echo "======================================== compiler tests ..."87$compile compiler-tests.scm88./a.out8990echo "======================================== FFI tests ..."91$compile ffi-tests.scm92./a.out9394echo "======================================== csc tests ..."95$interpret -s csc-tests.scm9697echo "======================================== compiler inlining tests ..."98$compile_r inline-me.scm -s -J -oi inline-me.inline99$compile inlining-tests.scm -optimize-level 3100./a.out101$compile inline-unroll.scm -optimize-level 3102./a.out103104echo "======================================== compiler message tests ..."105$compile -analyze-only messages-test.scm 2>messages.out106diff $DIFF_OPTS messages.expected messages.out107108echo "======================================== optimizer tests ..."109$compile rest-arg-tests.scm -specialize110./a.out111112echo "======================================== profiler tests ..."113$compile null.scm -profile -profile-name TEST.profile114./a.out115$CHICKEN_PROFILE TEST.profile116117echo "======================================== scrutiny tests ..."118$compile scrutinizer-tests.scm -analyze-only119$compile typematch-tests.scm -specialize -no-warnings120./a.out121122$compile test-scrutinizer-message-format.scm -analyze-only -specialize 2>scrutinizer-message-format.out || true123$compile scrutiny-tests.scm -analyze-only -specialize 2>scrutiny.out124$compile scrutiny-tests-2.scm -analyze-only -specialize 2>scrutiny-2.out125$compile specialization-tests.scm -analyze-only -specialize -specialize 2>specialization.out126127# Replace foo123 -> fooXX so gensyms don't trigger failures128$compile redact-gensyms.scm -o redact-gensyms129./redact-gensyms "tmp,g,scm:,a,b" < scrutinizer-message-format.out > scrutinizer-message-format.redacted130./redact-gensyms < scrutiny-2.out > scrutiny-2.redacted131./redact-gensyms < scrutiny.out > scrutiny.redacted132./redact-gensyms < specialization.out > specialization.redacted133134diff $DIFF_OPTS scrutinizer-message-format.expected scrutinizer-message-format.redacted135diff $DIFF_OPTS scrutiny.expected scrutiny.redacted136diff $DIFF_OPTS scrutiny-2.expected scrutiny-2.redacted137diff $DIFF_OPTS specialization.expected specialization.redacted138139$compile scrutiny-tests-3.scm -specialize -block140./a.out141142$compile scrutiny-tests-strict.scm -strict-types -specialize143./a.out144145echo "======================================== line number database ..."146$compile -O3 test-line-numbers.scm 2> test-line-numbers.out147diff $DIFF_OPTS test-line-numbers.expected test-line-numbers.out148./a.out149150echo "======================================== 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 foo154./a.out155$compile specialization-test-2.scm -types foo.types -types specialization-test-2.types -specialize -debug ox156./a.out157rm -f foo.types foo.import.*158159echo "======================================== specialization benchmark ..."160$compile fft.scm -O2 -local -d0 -disable-interrupts -b -o fft1.out161$compile fft.scm -O2 -local -specialize -debug x -d0 -disable-interrupts -b -o fft2.out -specialize162echo "normal:"163$time ./fft1.out 1000 7164echo "specialized:"165$time ./fft2.out 1000 7166167echo "======================================== unboxing benchmark ..."168$compile fft.scm -O2 -local -d0 -disable-interrupts -b -o fft1.out169$compile fft.scm -O4 -debug x -d0 -disable-interrupts -b -o fft2.out170echo "normal:"171$time ./fft1.out 1000 7172echo "unboxing:"173$time ./fft2.out 1000 7174175echo "======================================== callback tests ..."176$compile -extend c-id-valid.scm callback-tests.scm177./a.out178179if ./a.out twice; then180 echo "double-return from callback didn't fail"181 exit 1182else183 echo "double-return from callback failed as it should."184fi185186echo "======================================== runtime tests ..."187$interpret -s apply-test.scm188$compile apply-test.scm189./a.out190if ./a.out -:A10k; then191 echo "apply test with limited temp stack didn't fail"192 exit 1193else194 echo "apply test with limited temp stack failed as it should."195fi196197$compile test-gc-hooks.scm198./a.out199200echo "======================================== library tests ..."201$interpret -s library-tests.scm202$compile -specialize library-tests.scm203./a.out204$interpret -s records-and-setters-test.scm205$compile records-and-setters-test.scm206./a.out207$interpret -s record-printer-test.scm208$compile record-printer-test.scm209./a.out210211echo "======================================== unicode tests ..."212$interpret -s unicode-tests.scm213$compile -specialize unicode-tests.scm214./a.out215$interpret -s invalid-utf-test.scm216$interpret -s file-encoding-test.scm217218echo "======================================== reader tests ..."219$interpret -s reader-tests.scm220221echo "======================================== dynamic-wind tests ..."222$interpret -s dwindtst.scm >dwindtst.out223diff $DIFF_OPTS dwindtst.expected dwindtst.out224$compile dwindtst.scm225./a.out >dwindtst.out226diff $DIFF_OPTS dwindtst.expected dwindtst.out227228echo "======================================== lolevel tests ..."229$interpret -s lolevel-tests.scm230$compile -specialize lolevel-tests.scm231./a.out232233echo "======================================== arithmetic tests ..."234$interpret -D check -s arithmetic-test.scm235236echo "======================================== pretty-printer tests ..."237$interpret -s pp-test.scm238239echo "======================================== evaluation environment tests ..."240$interpret -s environment-tests.scm241242echo "======================================== syntax tests ..."243$interpret -s syntax-tests.scm244245echo "======================================== syntax tests (compiled) ..."246$compile syntax-tests.scm247./a.out248249echo "======================================== syntax tests (v2, compiled) ..."250$compile syntax-tests-2.scm251./a.out252253echo "======================================== meta-syntax tests ..."254$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)))'255$compile_s meta-syntax-test.scm -j foo256$compile_s foo.import.scm257$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)))'258259echo "======================================== reexport tests ..."260$interpret -bnq reexport-tests.scm261$compile reexport-tests.scm262./a.out263rm -f reexport-m*.import*264$compile_s reexport-m1.scm -J265$compile_s reexport-m1.import.scm266$interpret -s reexport-m2.scm267$compile reexport-m2.scm268./a.out269$compile_s reexport-m3.scm -J270$compile_s reexport-m4.scm -J271$compile_s reexport-m5.scm -J272$compile_s reexport-m6.scm -J273$compile_s reexport-m7.scm -J274$compile_s reexport-m8.scm -J275$compile_s reexport-m9.scm -J276$compile_s reexport-m10.scm -J277$compile reexport-tests-2.scm278./a.out279280echo "======================================== functor tests ..."281$interpret -bnq simple-functors-test.scm282$compile simple-functors-test.scm283./a.out284$interpret -bnq functor-tests.scm285$compile functor-tests.scm286./a.out287$compile -s square-functor.scm -J288$compile -s square-functor.import.scm289$interpret -bnq use-square-functor.scm290$compile use-square-functor.scm291./a.out292$compile -s use-square-functor.scm -J293$interpret -nqe '(require-library use-square-functor)' -e '(import sf1)' -e '(import sf2)'294rm -f sf1.import.* sf2.import.* lst.import.* mod.import.*295296echo "======================================== compiler syntax tests ..."297$compile compiler-syntax-tests.scm298./a.out299300echo "======================================== import tests ..."301$interpret -bnq import-tests.scm302303echo "======================================== import library tests ..."304rm -f ../foo.import.* foo.import.*305$compile import-library-test1.scm -emit-import-library foo306$interpret -s import-library-test2.scm307$compile_s foo.import.scm -o foo.import.so308$interpret -s import-library-test2.scm309$compile import-library-test2.scm310./a.out311rm -f foo.import.*312313echo "======================================== optionals test ..."314$interpret -s test-optional.scm315$compile test-optional.scm316./a.out317318echo "======================================== syntax tests (matchable) ..."319$interpret matchable.scm -s match-test.scm320321echo "======================================== syntax tests (loopy-loop) ..."322$interpret -s loopy-test.scm323324echo "======================================== r4rstest ..."325echo "(expect mult-float-print-test to fail)"326$interpret -e '(set! ##sys#procedure->string (constantly "#<procedure>"))' \327 -i -s r4rstest.scm >r4rstest.out328329diff $DIFF_OPTS r4rstest.expected r4rstest.out330331echo "======================================== syntax tests (r5rs_pitfalls) ..."332echo "(expect two failures)"333$interpret -i -s r5rs_pitfalls.scm334335echo "======================================== r7rs tests ..."336$interpret -s r7rs-tests.scm337$interpret -s r7rs-tests-2.scm338$interpret -s r7rs-library-tests.scm339$interpret -s life.scm340341echo "======================================== module tests ..."342$interpret -include-path ${TEST_DIR}/.. -s module-tests.scm343$interpret -include-path ${TEST_DIR}/.. -s module-tests-2.scm344345echo "======================================== module tests (command line options) ..."346module="test-$(date +%s)"347$compile test.scm -A -w -j "$module" -module "$module"348$interpret -e "(import-syntax $module)"349rm -f "$module.import.scm"350351echo "======================================== module tests (compiled) ..."352$compile module-tests-compiled.scm353./a.out354$compile module-static-eval-compiled.scm355./a.out356$compile -static module-static-eval-compiled.scm357./a.out358359echo "======================================== module tests (chained) ..."360rm -f m*.import.* test-chained-modules.so361$interpret -bnq test-chained-modules.scm362$compile_s test-chained-modules.scm -j m3363$compile_s m3.import.scm364$interpret -bn test-chained-modules.so365$interpret -bn test-chained-modules.so -e '(import m3) (s3)'366367echo "======================================== module tests (ec) ..."368rm -f ec.so ec.import.*369$interpret -bqn ec.scm ec-tests.scm370$compile_s ec.scm -emit-import-library ec -o ec.so371$compile_s ec.import.scm -o ec.import.so372$interpret -bnq ec.so ec-tests.scm373# $compile ec-tests.scm374# ./a.out # takes ages to compile375376echo "======================================== module tests (static link) ..."377$compile_r -static -unit sample-module -J -c sample-module.scm378mv sample-module.link sample-module.import.scm sample-module.o* "$CHICKEN_INSTALL_REPOSITORY"379$compile_r -static module-static-link.scm -o a.out380./a.out381382echo "======================================== port tests ..."383$interpret -s port-tests.scm384385echo "======================================== read-lines tests ..."386$interpret -s read-lines-tests.scm387388echo "======================================== fixnum tests ..."389$compile fixnum-tests.scm390./a.out391$compile -unsafe fixnum-tests.scm392./a.out393394echo "======================================== random number tests ..."395$interpret -s random-tests.scm396397echo "======================================== string->number tests ..."398$interpret -s numbers-string-conversion-tests.scm399$compile -specialize numbers-string-conversion-tests.scm400./a.out401402echo "======================================== basic numeric ops tests ..."403$interpret -s numbers-test.scm404$compile -specialize numbers-test.scm405./a.out406407echo "======================================== Alex Shinn's numeric ops tests ..."408$interpret -s numbers-test-ashinn.scm409$compile -specialize numbers-test-ashinn.scm410./a.out411412echo "======================================== Gauche's numeric ops tests ..."413$interpret -s numbers-test-gauche.scm414$compile -specialize numbers-test-gauche.scm415./a.out416417echo "======================================== srfi-4 tests ..."418$interpret -s srfi-4-tests.scm419420echo "======================================== condition tests ..."421$interpret -s condition-tests.scm422423echo "======================================== data-structures tests ..."424$interpret -s data-structures-tests.scm425426echo "======================================== path tests ..."427$interpret -bnq path-tests.scm428429echo "======================================== srfi-45 tests ..."430$interpret -s srfi-45-tests.scm431432echo "======================================== posix tests ..."433$compile posix-tests.scm434./a.out435436echo "======================================== file access tests ..."437$interpret -s file-access-tests.scm438439echo "======================================== find-files tests ..."440$interpret -bnq test-find-files.scm441442echo "======================================== record-renaming tests ..."443$interpret -bnq record-rename-test.scm444445echo "======================================== regular expression tests ..."446$interpret -bnq test-irregex.scm447$interpret -bnq test-glob.scm448449echo "======================================== compiler/nursery stress test ..."450for s in 100000 120000 200000 250000 300000 350000 400000 450000 500000; do451 echo " $s"452 ${CHICKEN} -ignore-repository ../port.scm -:s$s -output-file tmp.c -include-path ${TEST_DIR}/..453done454455echo "======================================== heap literal stress test ..."456$compile heap-literal-stress-test.scm457for s in 100000 120000 200000 250000 300000 350000 400000 450000 500000; do458 echo " $s"459 ./a.out -:d -:g -:hi$s460done461462echo "======================================== weak pointer test ..."463$compile weak-pointer-test.scm464./a.out465466echo "======================================== symbol-GC tests ..."467$compile symbolgc-tests.scm468./a.out469470echo "======================================== finalizer tests ..."471$interpret -s test-finalizers.scm472$compile test-finalizers.scm473./a.out474$compile finalizer-error-test.scm475echo "expect an error message here:"476./a.out -:hg101477$compile test-finalizers-2.scm478./a.out479480echo "======================================== locative stress test ..."481$compile locative-stress-test.scm482./a.out483484echo "======================================== syntax-rules stress test ..."485$time $interpret -bnq syntax-rule-stress-test.scm486487echo "======================================== include test ..."488mkdir -p a/b489echo > a/b/ok.scm490echo '(include "a/b/ok.scm")' > a/b/include.scm491$compile -analyze-only a/b/include.scm492echo '(include "b/ok.scm")' > a/b/include.scm493$compile -analyze-only a/b/include.scm -include-path a494echo '(include-relative "ok.scm")' > a/b/include.scm495$compile -analyze-only a/b/include.scm496echo '(include-relative "b/ok.scm")' > a/include.scm497$compile -analyze-only a/include.scm498echo '(include-relative "b/ok.scm")' > a/b/include.scm499$compile -analyze-only a/b/include.scm -include-path a500echo > a/b/other.scm501# make sure first include doesn't change state for second:502echo '(include-relative "b/ok.scm") (include-relative "b/other.scm")' > a/include.scm503$compile -analyze-only a/include.scm504echo '(include-relative "ok.scm")' > a/b/other.scm505echo '(include-relative "b/other.scm")' > a/include.scm506$compile -analyze-only a/include.scm507echo '(include-relative "b/other.scm") (let () (include-relative "b/ok.scm") (include-relative "b/ok.scm"))' > a/include.scm508$compile -analyze-only a/include.scm509rm -r a510511echo "======================================== executable tests ..."512$compile executable-tests.scm513./a.out "$TEST_DIR/a.out"514515echo "======================================== user pass tests ..."516$compile -extend user-pass-tests.scm null.scm517518echo "======================================== embedding (1) ..."519$compile embedded1.c520./a.out521522echo "======================================== embedding (2) ..."523$compile -e embedded2.scm524./a.out525526echo "======================================== embedding (3) ..."527$compile -e embedded3.c embedded4.scm528./a.out529530echo "======================================== linking tests ..."531$compile_r -unit reverser reverser/tags/1.0/reverser.scm -J -c532mv reverser/tags/1.0/reverser.o* ./533$compile_r -link reverser linking-tests.scm -o a.out534./a.out535$compile_r -link reverser linking-tests.scm -o a.out -static536./a.out537mv reverser.o* reverser.import.scm "$CHICKEN_INSTALL_REPOSITORY"538$compile_r -link reverser linking-tests.scm -o a.out539./a.out540$compile_r -link reverser linking-tests.scm -o a.out -static541./a.out542543echo "======================================== private repository test ..."544mkdir -p tmp545$compile private-repository-test.scm -private-repository -o tmp/xxx546tmp/xxx ${TEST_DIR}/tmp547# This MUST be `pwd`: ${PWD} is not portable, and ${TEST_DIR} breaks mingw548PATH=`pwd`/tmp:$PATH xxx ${TEST_DIR}/tmp549# this may crash, if the PATH contains a non-matching libchicken.dll on Windows:550#PATH=$PATH:${TEST_DIR}/tmp xxx ${TEST_DIR}/tmp551552echo "======================================== multiple return values tests ..."553$interpret -s multiple-values.scm554$compile multiple-values.scm555./a.out556557echo "======================================== done. All tests passed."