1 ; CGEN testsuite driver.
2 ; Copyright (C) 2009 Doug Evans
3 ; This file is part of CGEN.
5 ; This is a standalone script, we don't load anything until we parse the
6 ; -s argument (keeps reliance off of environment variables, etc.).
8 ; Load the various support routines.
10 (define (load-files srcdir)
11 (load (string-append srcdir "/read.scm"))
12 (load (string-append srcdir "/desc.scm"))
13 (load (string-append srcdir "/desc-cpu.scm"))
14 (load (string-append srcdir "/testsuite.scm"))
17 (define testsuite-arguments
19 (list "-T" "file" "generate $arch-test.h in <file>"
21 (lambda (arg) (file-write arg cgen-test.h)))
25 ; Kept global so it's available to the other .scm files.
28 ; Scan argv for -s srcdir.
29 ; We can't process any other args until we find the cgen source dir.
30 ; The result is srcdir.
31 ; We assume "-s" isn't the argument to another option. Unwise, yes.
32 ; Alternatives are to require it to be the first argument or at least preceed
33 ; any option with a "-s" argument, or to put knowledge of the common argument
34 ; set and common argument parsing code in every top level file.
36 (define (find-srcdir argv)
37 (let loop ((argv argv))
39 (error "`-s srcdir' not present, can't load cgen"))
40 (if (string=? "-s" (car argv))
42 (if (null? (cdr argv))
43 (error "missing srcdir arg to `-s'"))
48 ; Main routine, parses options and calls generators.
50 (define (cgen-testsuite argv)
53 ; Find and set srcdir, then load all Scheme code.
54 ; Drop the first argument, it is the script name (i.e. argv[0]).
55 (set! srcdir (find-srcdir (cdr argv)))
56 (set! %load-path (cons srcdir %load-path))
62 #:app-name "testsuite"
63 #:arg-spec testsuite-arguments
64 #:init testsuite-init!
65 #:finish testsuite-finish!
66 #:analyze testsuite-analyze!)
70 (cgen-testsuite (program-arguments))