csys: allow testing with multiple different neural nets: move env and services setup to individual test

This commit is contained in:
Helmut Merz 2026-03-30 19:28:46 +02:00
parent c04546ffe7
commit de72fe9aaf

View file

@ -43,33 +43,31 @@
(util:lgi nmsg) (util:lgi nmsg)
(actor:send (core:mailbox (tc:receiver t:*test-suite*)) nmsg)))) (actor:send (core:mailbox (tc:receiver t:*test-suite*)) nmsg))))
;;;; test runner
(defun run () (defun run ()
(async:init) (let ((t:*test-suite* (make-instance 'tc:test-suite :name "csys")))
(let* ((t:*test-suite* (make-instance 'tc:test-suite :name "csys"))
(csys:*environment* (make-instance 'test-env :test-suite t:*test-suite*)))
(load (t:test-path "config-csys" "etc")) (load (t:test-path "config-csys" "etc"))
(setup-config) (async:init)
(core:setup-services)
(unwind-protect (unwind-protect
(let ((rcvr (core:find-service :test-receiver))) (test-init)
(setf (tc:receiver t:*test-suite*) rcvr)
(test-init rcvr))
(sleep 0.1) (sleep 0.1)
(core:shutdown)
;(tc:check-expected)
(t:show-result)))) (t:show-result))))
(deftest test-init (rcvr) ;;;; tests
(setf (gethash '(:effect :default) (csys:procs csys:*environment*)) #'eff-proc)
;(csys:make-eff-proc (eff-handler '(1 3 4 5)))) (deftest test-init ()
(csys:init) (let ((csys:*environment* (make-instance 'test-env :test-suite t:*test-suite*))
(csys:send-message '(:csys :sensor :init :zero) '(:std :s1)) rcvr)
(csys:send-message '(:csys :sensor :init :zero) '(:std :s2)) (setf (gethash '(:effect :default) (csys:procs csys:*environment*)) #'eff-proc)
(sleep 0.1) (setup-config)
(csys:send-message '(:csys :add :std :s1) 1) (core:setup-services)
(csys:send-message '(:csys :add :std :s1) 3) (setf (tc:receiver t:*test-suite*) (core:find-service :test-receiver))
(csys:send-message '(:csys :sub :std :s2) 4) (csys:init)
(csys:send-message '(:csys :add :std :s2) 5) (csys:send-message '(:csys :sensor :init :zero) '(:std :s1))
) (csys:send-message '(:csys :sensor :init :zero) '(:std :s2))
(sleep 0.1)
(csys:send-message '(:csys :add :std :s1) 1)
(csys:send-message '(:csys :add :std :s1) 3)
(csys:send-message '(:csys :sub :std :s2) 4)
(csys:send-message '(:csys :add :std :s2) 5)
(core:shutdown)
))