~ chicken-core (chicken-5) /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 test -z "$MSYSTEM"; then9 TEST_DIR=`pwd`10 PATH_SEP=':'11else12 # Use Windows-native format with drive letters instead of awkward13 # MSYS /c/blabla "pseudo-paths" which break when used in syscalls.14 TEST_DIR=`pwd -W`15 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}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 "======================================== csc tests ..."91$interpret -s csc-tests.scm9293echo "======================================== compiler inlining tests ..."94$compile_r inline-me.scm -s -J -oi inline-me.inline95$compile inlining-tests.scm -optimize-level 396./a.out97$compile inline-unroll.scm -optimize-level 398./a.out99100echo "======================================== compiler message tests ..."101$compile -analyze-only messages-test.scm 2>messages.out102diff $DIFF_OPTS messages.expected messages.out103104echo "======================================== optimizer tests ..."105$compile clustering-tests.scm -clustering106./a.out107108$compile rest-arg-tests.scm -specialize109./a.out110111echo "======================================== profiler tests ..."112$compile null.scm -profile -profile-name TEST.profile113./a.out114$CHICKEN_PROFILE TEST.profile115116echo "======================================== scrutiny tests ..."117$compile scrutinizer-tests.scm -analyze-only118$compile typematch-tests.scm -specialize -no-warnings119./a.out120121$compile test-scrutinizer-message-format.scm -analyze-only -specialize 2>scrutinizer-message-format.out || true122$compile scrutiny-tests.scm -analyze-only -specialize 2>scrutiny.out123$compile scrutiny-tests-2.scm -analyze-only -specialize 2>scrutiny-2.out124$compile specialization-tests.scm -analyze-only -specialize -specialize 2>specialization.out125126# Replace foo123 -> fooXX so gensyms don't trigger failures127$compile redact-gensyms.scm -o redact-gensyms128./redact-gensyms "tmp,g,scm:,a,b" < scrutinizer-message-format.out > scrutinizer-message-format.redacted129./redact-gensyms < scrutiny-2.out > scrutiny-2.redacted130./redact-gensyms < scrutiny.out > scrutiny.redacted131./redact-gensyms < specialization.out > specialization.redacted132133diff $DIFF_OPTS scrutinizer-message-format.expected scrutinizer-message-format.redacted134diff $DIFF_OPTS scrutiny.expected scrutiny.redacted135diff $DIFF_OPTS scrutiny-2.expected scrutiny-2.redacted136diff $DIFF_OPTS specialization.expected specialization.redacted137138$compile scrutiny-tests-3.scm -specialize -block139./a.out140141$compile scrutiny-tests-strict.scm -strict-types -specialize142./a.out143144echo "======================================== line number database ..."145$compile -O3 test-line-numbers.scm 2> test-line-numbers.out146diff $DIFF_OPTS test-line-numbers.expected test-line-numbers.out147./a.out148149echo "======================================== specialization tests ..."150rm -f foo.types foo.import.*151$compile specialization-test-1.scm -emit-types-file foo.types -specialize \152 -debug ox -emit-import-library foo153./a.out154$compile specialization-test-2.scm -types foo.types -types specialization-test-2.types -specialize -debug ox155./a.out156rm -f foo.types foo.import.*157158echo "======================================== specialization benchmark ..."159$compile fft.scm -O2 -local -d0 -disable-interrupts -b -o fft1.out160$compile fft.scm -O2 -local -specialize -debug x -d0 -disable-interrupts -b -o fft2.out -specialize161echo "normal:"162$time ./fft1.out 1000 7163echo "specialized:"164$time ./fft2.out 1000 7165166echo "======================================== unboxing benchmark ..."167$compile fft.scm -O2 -local -d0 -disable-interrupts -b -o fft1.out168$compile fft.scm -O4 -debug x -d0 -disable-interrupts -b -o fft2.out169echo "normal:"170$time ./fft1.out 1000 7171echo "unboxing:"172$time ./fft2.out 1000 7173174echo "======================================== callback tests ..."175$compile -extend c-id-valid.scm callback-tests.scm176./a.out177178if ./a.out twice; then179 echo "double-return from callback didn't fail"180 exit 1181else182 echo "double-return from callback failed as it should."183fi184185echo "======================================== runtime tests ..."186$interpret -s apply-test.scm187$compile apply-test.scm188./a.out189if ./a.out -:A10k; then190 echo "apply test with limited temp stack didn't fail"191 exit 1192else193 echo "apply test with limited temp stack failed as it should."194fi195196$compile test-gc-hooks.scm197./a.out198199echo "======================================== library tests ..."200$interpret -s library-tests.scm201$compile -specialize library-tests.scm202./a.out203$interpret -s records-and-setters-test.scm204$compile records-and-setters-test.scm205./a.out206$interpret -s record-printer-test.scm207$compile record-printer-test.scm208./a.out209210echo "======================================== reader tests ..."211$interpret -s reader-tests.scm212213echo "======================================== dynamic-wind tests ..."214$interpret -s dwindtst.scm >dwindtst.out215diff $DIFF_OPTS dwindtst.expected dwindtst.out216$compile dwindtst.scm217./a.out >dwindtst.out218diff $DIFF_OPTS dwindtst.expected dwindtst.out219220echo "======================================== lolevel tests ..."221$interpret -s lolevel-tests.scm222$compile -specialize lolevel-tests.scm223./a.out224225echo "======================================== arithmetic tests ..."226$interpret -D check -s arithmetic-test.scm227228echo "======================================== pretty-printer tests ..."229$interpret -s pp-test.scm230231echo "======================================== evaluation environment tests ..."232$interpret -s environment-tests.scm233234echo "======================================== syntax tests ..."235$interpret -s syntax-tests.scm236237echo "======================================== syntax tests (compiled) ..."238$compile syntax-tests.scm239./a.out240241echo "======================================== syntax tests (v2, compiled) ..."242$compile syntax-tests-2.scm243./a.out244245echo "======================================== meta-syntax tests ..."246$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)))"247$compile_s meta-syntax-test.scm -j foo248$compile_s foo.import.scm249$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)))"250251echo "======================================== reexport tests ..."252$interpret -bnq reexport-tests.scm253$compile reexport-tests.scm254./a.out255rm -f reexport-m*.import*256$compile_s reexport-m1.scm -J257$compile_s reexport-m1.import.scm258$interpret -s reexport-m2.scm259$compile reexport-m2.scm260./a.out261$compile_s reexport-m3.scm -J262$compile_s reexport-m4.scm -J263$compile_s reexport-m5.scm -J264$compile_s reexport-m6.scm -J265$compile_s reexport-m7.scm -J266$compile_s reexport-m8.scm -J267$compile_s reexport-m9.scm -J268$compile_s reexport-m10.scm -J269$compile reexport-tests-2.scm270./a.out271272echo "======================================== functor tests ..."273$interpret -bnq simple-functors-test.scm274$compile simple-functors-test.scm275./a.out276$interpret -bnq functor-tests.scm277$compile functor-tests.scm278./a.out279$compile -s square-functor.scm -J280$compile -s square-functor.import.scm281$interpret -bnq use-square-functor.scm282$compile use-square-functor.scm283./a.out284$compile -s use-square-functor.scm -J285$interpret -nqe '(require-library use-square-functor)' -e '(import sf1)' -e '(import sf2)'286rm -f sf1.import.* sf2.import.* lst.import.* mod.import.*287288echo "======================================== compiler syntax tests ..."289$compile compiler-syntax-tests.scm290./a.out291292echo "======================================== import tests ..."293$interpret -bnq import-tests.scm294295echo "======================================== import library tests ..."296rm -f ../foo.import.* foo.import.*297$compile import-library-test1.scm -emit-import-library foo298$interpret -s import-library-test2.scm299$compile_s foo.import.scm -o foo.import.so300$interpret -s import-library-test2.scm301$compile import-library-test2.scm302./a.out303rm -f foo.import.*304305echo "======================================== optionals test ..."306$interpret -s test-optional.scm307$compile test-optional.scm308./a.out309310echo "======================================== syntax tests (matchable) ..."311$interpret matchable.scm -s match-test.scm312313echo "======================================== syntax tests (loopy-loop) ..."314$interpret -s loopy-test.scm315316echo "======================================== r4rstest ..."317echo "(expect mult-float-print-test to fail)"318$interpret -e '(set! ##sys#procedure->string (constantly "#<procedure>"))' \319 -i -s r4rstest.scm >r4rstest.out320321diff $DIFF_OPTS r4rstest.expected r4rstest.out322323echo "======================================== syntax tests (r5rs_pitfalls) ..."324echo "(expect two failures)"325$interpret -i -s r5rs_pitfalls.scm326327echo "======================================== r7rs tests ..."328$interpret -i -s r7rs-tests.scm329330echo "======================================== module tests ..."331$interpret -include-path ${TEST_DIR}/.. -s module-tests.scm332$interpret -include-path ${TEST_DIR}/.. -s module-tests-2.scm333334echo "======================================== module tests (command line options) ..."335module="test-$(date +%s)"336$compile test.scm -A -w -j "$module" -module "$module"337$interpret -e "(import-syntax $module)"338rm -f "$module.import.scm"339340echo "======================================== module tests (compiled) ..."341$compile module-tests-compiled.scm342./a.out343$compile module-static-eval-compiled.scm344./a.out345$compile -static module-static-eval-compiled.scm346./a.out347348echo "======================================== module tests (chained) ..."349rm -f m*.import.* test-chained-modules.so350$interpret -bnq test-chained-modules.scm351$compile_s test-chained-modules.scm -j m3352$compile_s m3.import.scm353$interpret -bn test-chained-modules.so354$interpret -bn test-chained-modules.so -e '(import m3) (s3)'355356echo "======================================== module tests (ec) ..."357rm -f ec.so ec.import.*358$interpret -bqn ec.scm ec-tests.scm359$compile_s ec.scm -emit-import-library ec -o ec.so360$compile_s ec.import.scm -o ec.import.so361$interpret -bnq ec.so ec-tests.scm362# $compile ec-tests.scm363# ./a.out # takes ages to compile364365echo "======================================== module tests (static link) ..."366$compile_r -static -unit sample-module -J -c sample-module.scm367mv sample-module.link sample-module.import.scm sample-module.o* "$CHICKEN_INSTALL_REPOSITORY"368$compile_r -static module-static-link.scm -o a.out369./a.out370371echo "======================================== port tests ..."372$interpret -s port-tests.scm373374echo "======================================== read-lines tests ..."375$interpret -s read-lines-tests.scm376377echo "======================================== fixnum tests ..."378$compile fixnum-tests.scm379./a.out380$compile -unsafe fixnum-tests.scm381./a.out382383echo "======================================== random number tests ..."384$interpret -s random-tests.scm385386echo "======================================== string->number tests ..."387$interpret -s numbers-string-conversion-tests.scm388$compile -specialize numbers-string-conversion-tests.scm389./a.out390391echo "======================================== basic numeric ops tests ..."392$interpret -s numbers-test.scm393$compile -specialize numbers-test.scm394./a.out395396echo "======================================== Alex Shinn's numeric ops tests ..."397$interpret -s numbers-test-ashinn.scm398$compile -specialize numbers-test-ashinn.scm399./a.out400401echo "======================================== Gauche's numeric ops tests ..."402$interpret -s numbers-test-gauche.scm403$compile -specialize numbers-test-gauche.scm404./a.out405406echo "======================================== srfi-4 tests ..."407$interpret -s srfi-4-tests.scm408409echo "======================================== condition tests ..."410$interpret -s condition-tests.scm411412echo "======================================== data-structures tests ..."413$interpret -s data-structures-tests.scm414415echo "======================================== path tests ..."416$interpret -bnq path-tests.scm417418echo "======================================== srfi-45 tests ..."419$interpret -s srfi-45-tests.scm420421echo "======================================== posix tests ..."422$compile posix-tests.scm423./a.out424425echo "======================================== file access tests ..."426if test -n "$MSYSTEM"; then427 $interpret -s file-access-tests.scm //428 $interpret -s file-access-tests.scm \\429else430 $interpret -s file-access-tests.scm /431fi432433echo "======================================== find-files tests ..."434$interpret -bnq test-find-files.scm435436echo "======================================== create-temporary-file tests ..."437if test -z "$MSYSTEM"; then438 echo "== SKIPPED due to problematic unsetenv behaviour on Windows =="439else440 $interpret -bnq test-create-temporary-file.scm441fi442443echo "======================================== record-renaming tests ..."444$interpret -bnq record-rename-test.scm445446echo "======================================== regular expression tests ..."447$interpret -bnq test-irregex.scm448$interpret -bnq test-glob.scm449450echo "======================================== compiler/nursery stress test ..."451for s in 100000 120000 200000 250000 300000 350000 400000 450000 500000; do452 echo " $s"453 ${CHICKEN} -ignore-repository ../port.scm -:s$s -output-file tmp.c -include-path ${TEST_DIR}/..454done455456echo "======================================== heap literal stress test ..."457$compile heap-literal-stress-test.scm458for s in 100000 120000 200000 250000 300000 350000 400000 450000 500000; do459 echo " $s"460 ./a.out -:d -:g -:hi$s461done462463echo "======================================== weak pointer test ..."464$compile weak-pointer-test.scm465./a.out466467echo "======================================== symbol-GC tests ..."468$compile symbolgc-tests.scm469./a.out470471echo "======================================== finalizer tests ..."472$interpret -s test-finalizers.scm473$compile test-finalizers.scm474./a.out475$compile finalizer-error-test.scm476echo "expect an error message here:"477./a.out -:hg101478$compile test-finalizers-2.scm479./a.out480481echo "======================================== locative stress test ..."482$compile locative-stress-test.scm483./a.out484485echo "======================================== syntax-rules stress test ..."486$time $interpret -bnq syntax-rule-stress-test.scm487488echo "======================================== include test ..."489mkdir -p a/b490echo > a/b/ok.scm491echo '(include "a/b/ok.scm")' > a/b/include.scm492$compile -analyze-only a/b/include.scm493echo '(include "b/ok.scm")' > a/b/include.scm494$compile -analyze-only a/b/include.scm -include-path a495echo '(include-relative "ok.scm")' > a/b/include.scm496$compile -analyze-only a/b/include.scm497echo '(include-relative "b/ok.scm")' > a/include.scm498$compile -analyze-only a/include.scm499echo '(include-relative "b/ok.scm")' > a/b/include.scm500$compile -analyze-only a/b/include.scm -include-path a501echo > a/b/other.scm502# make sure first include doesn't change state for second:503echo '(include-relative "b/ok.scm") (include-relative "b/other.scm")' > a/include.scm504$compile -analyze-only a/include.scm505echo '(include-relative "ok.scm")' > a/b/other.scm506echo '(include-relative "b/other.scm")' > a/include.scm507$compile -analyze-only a/include.scm508echo '(include-relative "b/other.scm") (let () (include-relative "b/ok.scm") (include-relative "b/ok.scm"))' > a/include.scm509$compile -analyze-only a/include.scm510rm -r a511512echo "======================================== executable tests ..."513$compile executable-tests.scm514./a.out "$TEST_DIR/a.out"515516echo "======================================== user pass tests ..."517$compile -extend user-pass-tests.scm null.scm518519echo "======================================== embedding (1) ..."520$compile embedded1.c521./a.out522523echo "======================================== embedding (2) ..."524$compile -e embedded2.scm525./a.out526527echo "======================================== embedding (3) ..."528$compile -e embedded3.c embedded4.scm529./a.out530531echo "======================================== linking tests ..."532$compile_r -unit reverser reverser/tags/1.0/reverser.scm -J -c533mv reverser/tags/1.0/reverser.o* ./534$compile_r -link reverser linking-tests.scm -o a.out535./a.out536$compile_r -link reverser linking-tests.scm -o a.out -static537./a.out538mv reverser.o* reverser.import.scm "$CHICKEN_INSTALL_REPOSITORY"539$compile_r -link reverser linking-tests.scm -o a.out540./a.out541$compile_r -link reverser linking-tests.scm -o a.out -static542./a.out543544echo "======================================== private repository test ..."545mkdir -p tmp546$compile private-repository-test.scm -private-repository -o tmp/xxx547tmp/xxx ${TEST_DIR}/tmp548# This MUST be `pwd`: ${PWD} is not portable, and ${TEST_DIR} breaks mingw-msys549PATH=`pwd`/tmp:$PATH xxx ${TEST_DIR}/tmp550# this may crash, if the PATH contains a non-matching libchicken.dll on Windows:551#PATH=$PATH:${TEST_DIR}/tmp xxx ${TEST_DIR}/tmp552553echo "======================================== multiple return values tests ..."554$interpret -s multiple-values.scm555$compile multiple-values.scm556./a.out557558echo "======================================== done. All tests passed."