Changeset 35275 in project


Ignore:
Timestamp:
03/10/18 21:59:56 (3 months ago)
Author:
kon
Message:

use csi+csc test runner, std import

Location:
release/4/timed-resource/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • release/4/timed-resource/trunk/tests/run.scm

    r34417 r35275  
    1 (use test)
    2 (use srfi-4)
    3 (use timed-resource)
    41
    5 (cond-expand
    6   (windows)
    7   (unix
    8     (define-constant ACTIVE-SECONDS 1.0)
     2(define EGG-NAME "timed-resource")
    93
    10     (define +opened+ 0) ;For Testing Only
    11     (define +closed+ 0) ;For Testing Only
     4;chicken-install invokes as "<csi> -s run.scm <eggnam> <eggdir>"
    125
    13     (define random-blob
    14       (let ((tr-random-dev
    15               (make-timed-resource
    16                 (lambda ()
    17                   (set! +opened+ (add1 +opened+)) ;For Testing Only
    18                   (open-input-file "/dev/random" #:binary))
    19                 (lambda (port)
    20                   (set! +closed+ (add1 +closed+)) ;For Testing Only
    21                   (close-output-port port))
    22                 ACTIVE-SECONDS)))
    23         (lambda (#!optional (bits 128))
    24           (let ((bytes (inexact->exact (floor (/ (+ bits 7) 8)))))
    25             (with-timed-resource tr-random-dev
    26               (lambda (port)
    27                 (u8vector->blob (read-u8vector bytes port))))) ) ) )
     6(use files)
    287
    29     (test-group "Simple Timed Resource"
    30       (let ((x (random-blob)))
    31         (test-assert (blob? x))
    32         (test 16 (blob-size x)) )
    33       ;Wait a little longer than the timeout
    34       (thread-sleep! (inexact->exact (round (+ ACTIVE-SECONDS 0.5))))
    35       ;Better be closed now!
    36       (test "Resource Closed" +closed+ +opened+) ) ) )
     8;no -disable-interrupts
     9(define *csc-options* "-inline-global -scrutinize -optimize-leaf-routines -local -inline -specialize -unsafe -no-trace -no-lambda-info -clustering -lfa2")
    3710
    38 (test-exit)
     11(define *args* (argv))
     12
     13(define (test-name #!optional (eggnam EGG-NAME))
     14  (string-append eggnam "-test") )
     15
     16(define (egg-name #!optional (def EGG-NAME))
     17  (cond
     18    ((<= 4 (length *args*))
     19      (cadddr *args*) )
     20    (def
     21      def )
     22    (else
     23      (error 'test "cannot determine egg-name") ) ) )
     24
     25;;;
     26
     27(set! EGG-NAME (egg-name))
     28
     29(define (run-test #!optional (eggnam EGG-NAME) (cscopts *csc-options*))
     30  (let ((tstnam (test-name eggnam)))
     31    (print "*** csi ***")
     32    (system (string-append "csi -s " (make-pathname #f tstnam "scm")))
     33    (newline)
     34    (print "*** csc (" cscopts ") ***")
     35    (system (string-append "csc" " " cscopts " " (make-pathname #f tstnam "scm")))
     36    (system (make-pathname (cond-expand (unix "./") (else #f)) tstnam)) ) )
     37
     38(define (run-tests eggnams #!optional (cscopts *csc-options*))
     39  (for-each (cut run-test <> cscopts) eggnams) )
     40
     41;;;
     42
     43(run-test)
  • release/4/timed-resource/trunk/timed-resource.meta

    r34417 r35275  
    1515        (miscmacros "2.96"))
    1616 (test-depends test)
    17  (files "timed-resource.setup" "timed-resource.scm" "timed-resource.meta" "timed-resource.release-info" "tests/run.scm") )
     17 (files
     18  "timed-resource.setup" "timed-resource.scm"
     19  "timed-resource.meta"
     20  "tests/run.scm" "tests/timed-resource-test.scm") )
  • release/4/timed-resource/trunk/timed-resource.scm

    r34417 r35275  
    1818  with-timed-resource )
    1919
    20 (import scheme)
    21 
    22 (import chicken)
    23 
    24 (import
     20(import scheme chicken)
     21(use
    2522 (only data-structures ->string)
    2623  (only srfi-1 delete!)
     
    3027    thread-sleep! thread-terminate! thread-signal!
    3128    make-mutex mutex-name
    32     terminated-thread-exception? uncaught-exception?) )
    33 (require-library
    34   data-structures srfi-1 srfi-18 )
    35 
    36 (import
     29    terminated-thread-exception? uncaught-exception?)
    3730  (only synch
    3831    make-object/synch object?/synch
     
    4841    thread-reaper-shutdown? thread-reap!)
    4942  (only record-variants
    50     define-record-type-variant) )
    51 (require-library
    52   synch
    53   type-checks
    54   thread-utils thread-reaper
    55   record-variants )
    56 
    57 (require-extension miscmacros)
     43    define-record-type-variant)
     44  miscmacros)
    5845
    5946;;
Note: See TracChangeset for help on using the changeset viewer.