Make a job-utils package for test system
This lets us dynamically create new threads to test features in multithreaded environment.
This commit is contained in:
parent
0f0ed3a879
commit
7e6f6f699c
3 changed files with 23 additions and 11 deletions
|
|
@ -6,4 +6,5 @@
|
|||
(uiop:define-package :stoe/test/all
|
||||
(:nicknames :test)
|
||||
(:use-reexport
|
||||
:stoe/test/job-utils
|
||||
:stoe/test/jobs))
|
||||
|
|
|
|||
20
test/job-utils.lisp
Normal file
20
test/job-utils.lisp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#|
|
||||
This file is a part of stoe project.
|
||||
Copyright (c) 2015 Renaud Casenave-Péré (renaud@casenave-pere.fr)
|
||||
|#
|
||||
|
||||
(uiop:define-package :stoe/test/job-utils
|
||||
(:use :cl :prove
|
||||
:stoe/core/jobs)
|
||||
(:export #:with-new-job-thread))
|
||||
(in-package :stoe/test/job-utils)
|
||||
|
||||
(defmacro with-new-job-thread (count &body body)
|
||||
`(progn
|
||||
(dotimes (i ,count)
|
||||
(push-new-job-thread #'stoe/core/jobs::start-job-thread))
|
||||
,@body
|
||||
(mapc (lambda (thread) (terminate-thread thread))
|
||||
stoe/core/jobs::*thread-list*)
|
||||
(sleep 0.5)
|
||||
(stoe/core/jobs::update 0)))
|
||||
|
|
@ -7,7 +7,8 @@
|
|||
(:use :cl :prove
|
||||
:stoe/core/containers
|
||||
:stoe/core/thread
|
||||
:stoe/core/jobs))
|
||||
:stoe/core/jobs
|
||||
:stoe/test/job-utils))
|
||||
(in-package :stoe/test/jobs)
|
||||
|
||||
(stoe/core/jobs::initialize)
|
||||
|
|
@ -17,16 +18,6 @@
|
|||
(format t "x ~a~%" x)
|
||||
(incf x)))
|
||||
|
||||
(defmacro with-new-job-thread (count &body body)
|
||||
`(progn
|
||||
(dotimes (i ,count)
|
||||
(push-new-job-thread #'stoe/core/jobs::start-job-thread))
|
||||
,@body
|
||||
(mapc (lambda (thread) (terminate-thread thread))
|
||||
stoe/core/jobs::*thread-list*)
|
||||
(sleep 1)
|
||||
(stoe/core/jobs::update 0)))
|
||||
|
||||
(plan 3)
|
||||
|
||||
(with-new-job-thread 1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue