mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-04 11:10:27 +02:00
object file is too small. * doc/guile-vm.texi: Documented `make-closure'. Improved the documentation of `load-program'. * testsuite: New directory. * configure.in: Added `testsuite/Makefile' to `AC_OUTPUT'. * Makefile.am (SUBDIRS): Added `testsuite'. * src/vm_engine.h (VM_CHECK_OBJECT): New option. (CHECK_OBJECT): New macro. * src/vm_system.c (object-ref): Use VM_CHECK_OBJECT. * module/system/vm/assemble.scm (preprocess): Commented out the debugging code. * benchmark/lib.scm (do-loop): New procedure. git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-2
73 lines
1.8 KiB
Scheme
73 lines
1.8 KiB
Scheme
;;; A simple test-running script.
|
||
|
||
(use-modules (system vm core)
|
||
(system vm disasm)
|
||
(system base compile)
|
||
(system base language)
|
||
|
||
(srfi srfi-1))
|
||
|
||
|
||
(define *scheme* (lookup-language 'scheme))
|
||
|
||
(define (fetch-sexp-from-file file)
|
||
(with-input-from-file file
|
||
(lambda ()
|
||
(let loop ((sexp (read))
|
||
(result '()))
|
||
(if (eof-object? sexp)
|
||
(cons 'begin (reverse result))
|
||
(loop (read) (cons sexp result)))))))
|
||
|
||
(define (compile-to-objcode sexp)
|
||
"Compile the expression @var{sexp} into a VM program and return it."
|
||
(compile-in sexp (current-module) *scheme*))
|
||
|
||
(define (run-vm-program objcode)
|
||
"Run VM program contained into @var{objcode}."
|
||
(vm-load (the-vm) objcode))
|
||
|
||
(define (run-test-from-file file)
|
||
"Run test from source file @var{file} and return a value indicating whether
|
||
it succeeded."
|
||
(run-vm-program (compile-to-objcode (fetch-sexp-from-file file))))
|
||
|
||
|
||
(define-macro (watch-proc proc-name str)
|
||
`(let ((orig-proc ,proc-name))
|
||
(set! ,proc-name
|
||
(lambda args
|
||
(format #t (string-append ,str "... "))
|
||
(apply orig-proc args)))))
|
||
|
||
(watch-proc fetch-sexp-from-file "reading")
|
||
(watch-proc compile-to-objcode "compiling")
|
||
(watch-proc run-vm-program "running")
|
||
|
||
|
||
;; The program.
|
||
|
||
(define (run-vm-tests files)
|
||
(let* ((res (map (lambda (file)
|
||
(format #t "running `~a'... " file)
|
||
(if (catch #t
|
||
(lambda ()
|
||
(run-test-from-file file))
|
||
(lambda (key . args)
|
||
(format #t "[~a/~a] " key args)
|
||
#f))
|
||
(format #t "ok~%")
|
||
(begin (format #t "FAILED~%") #f)))
|
||
files))
|
||
(total (length files))
|
||
(failed (length (filter not res))))
|
||
|
||
(if (= 0 failed)
|
||
(begin
|
||
(format #t "~%All ~a tests passed~%" total)
|
||
(exit 0))
|
||
(begin
|
||
(format #t "~%~a tests failed out of ~a~%"
|
||
failed total)
|
||
(exit failed)))))
|
||
|