Changeset 40375 in project


Ignore:
Timestamp:
08/22/21 07:00:06 (5 weeks ago)
Author:
Kon Lovett
Message:

use "threads" abstraction in continuation-test, new test runner

Location:
release/5/synch/trunk/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/5/synch/trunk/tests/run.scm

    r39824 r40375  
    77    make-pathname pathname-file pathname-replace-directory pathname-strip-extension)
    88  (only (chicken process) system)
    9   (only (chicken process-context) command-line-arguments)
     9  (only (chicken process-context) command-line-arguments get-environment-variable)
    1010  (only (chicken format) format)
    1111  (only (chicken file) file-exists? find-files)
     
    1313
    1414;; Globals
     15
     16(define *csi* (or (get-environment-variable "CHICKEN_CSI") "csi"))
     17(define *csc* (or (get-environment-variable "CHICKEN_CSC") "csc"))
    1518
    1619(define *csc-init-options* '(
     
    7982
    8083(define (run-test-evaluated source)
    81   (format #t "*** csi ~A ***~%" (pathname-file source))
    82   (system-must (string-append "csi -s " source)) )
     84  (format #t "*** ~A ~A ***~%" *csi* (pathname-file source))
     85  (system-must (string-append *csi* " -s " source)) )
    8386
    8487(define (run-test-compiled source csc-options)
    8588  (let ((optstr (apply string-append (intersperse csc-options " "))))
    86     (format #t "*** csc ~A ~A ***~%" (pathname-file source) optstr)
     89    (format #t "*** ~A ~A ~A ***~%" *csc* (pathname-file source) optstr)
    8790    ;csc output is in current directory
    88     (system-must (string-append "csc" " " optstr " " source)) )
     91    (system-must (string-append *csc* " " optstr " " source)) )
    8992  (system-must (pathname-replace-directory (pathname-strip-extension source) *test-directory*)) )
    9093
  • release/5/synch/trunk/tests/synch-continuation-test.scm

    r37019 r40375  
    110110;;
    111111
    112 (define *run-in-threads* '())
    113 
    114 (define-syntax run-in-thread
     112(define add-threads)
     113(define start-threads)
     114(define join-threads)
     115(define randomize-threads)
     116(let ((*run-threads* '()))
     117  (set! add-threads (lambda (th) (set! *run-threads* (cons th *run-threads*))))
     118  (set! start-threads (lambda () (for-each thread-start! *run-threads*)))
     119  (set! join-threads (lambda () (for-each thread-join! *run-threads*)))
     120  (set! randomize-threads (lambda () (set! *run-threads* (shuffle *run-threads*)))) )
     121
     122(define-syntax threads-begin
    115123  (syntax-rules ()
    116     ((run-in-thread body ...)
    117       (let ((th (make-thread (lambda () body ...))))
    118         (set! *run-in-threads* (cons th *run-in-threads*)) ) ) ) )
    119 
    120 (define (start-run-in-threads) (for-each thread-start! *run-in-threads*))
    121 (define (join-run-in-threads) (for-each thread-join! *run-in-threads*))
    122 
    123 (define (randomize-run-in-threads) (set! *run-in-threads* (shuffle *run-in-threads*)))
    124 
    125 (define (run-in-threads)
    126   (randomize-run-in-threads)
    127   (start-run-in-threads)
    128   ;(thread-yield!)
    129   (randomize-run-in-threads)
    130   (join-run-in-threads) )
     124    ((threads-begin body ...)
     125      (add-threads (make-thread (lambda () body ...))) ) ) )
     126
     127(define (threads-run)
     128  #; ;
     129  (randomize-threads)
     130  (start-threads)
     131  #; ;
     132  (thread-yield!)
     133  (randomize-threads)
     134  (join-threads) )
    131135
    132136;; Test
     
    150154;#;
    151155(let ((genny (count-to-coroutine 5)) (end-state #f))
    152 (run-in-thread
     156(threads-begin
    153157  (test-group "Genny"
    154158    ;(let ((genny (count-to-coroutine 5)) (end-state #f))
     
    164168;#;
    165169(let ((iter (count-to-iteration 5)) (end-state #f))
    166 (run-in-thread
     170(threads-begin
    167171  (test-group "Dynamic Context"
    168172    ;(let ((iter (count-to-iteration 5)) (end-state #f))
     
    182186;#;
    183187(let ((genny (count-to-coroutine 5)) (end-state #f))
    184 (run-in-thread
     188(threads-begin
    185189  (test-group "Synch Genny"
    186190    ;(let ((genny (count-to-coroutine 5)) (end-state #f))
     
    199203;#;
    200204(let ((iter (count-to-iteration 5)) (end-state #f))
    201 (run-in-thread
     205(threads-begin
    202206  (test-group "Synch Dynamic Context (Early Exit Handler Call)"
    203207    ;(let ((iter (count-to-iteration 5)) (end-state #f))
     
    216220;(test-begin "Synch Examples") ;interesting: test impl artifact?
    217221
    218 (run-in-threads)
     222(threads-run)
    219223
    220224(test-end "Synch Examples")
Note: See TracChangeset for help on using the changeset viewer.