WIP add failing test that service starts

This commit is contained in:
Daniel Barlow 2024-03-06 00:32:38 +00:00
parent 570d29c368
commit 5d5dff6729
2 changed files with 34 additions and 2 deletions

View file

@ -2,12 +2,13 @@
; (local { : view} (require :fennel))
(local { : assoc } (require :anoia))
(local { : assoc : system } (require :anoia))
(fn parse-args [args]
(match args
["-v" & rest] (assoc (parse-args rest) :verbose true)
["-t" timeout & rest] (assoc (parse-args rest) :timeout (tonumber timeout))
["-s" service & rest] (assoc (parse-args rest) :service service)
[linkname "up"] {:link linkname :expecting "up"}
[linkname "running"] {:link linkname :expecting "running"}
[linkname "present"] {:link linkname :expecting "present"}

View file

@ -1,4 +1,8 @@
(local fennel (require :fennel))
(local { : view &as fennel } (require :fennel))
(local anoia (require :anoia))
(var fake-system (fn [s] (print "executing " s)))
(tset anoia :system #(fake-system $1))
(fn event-generator [events]
(coroutine.wrap
@ -19,3 +23,30 @@
(match (pcall gen)
(true _) true
(false msg) (error "didn't detect dummy0 up event")))
(var succeeded? false)
(set fake-system
(fn [s]
(print "exec" s)
(if (s:match "addmember") (set succeeded? true))))
(let [events
[{:event "newlink"
:hwaddr "b6:7d:5c:38:89:1d"
:index 21
:mtu 1500
:name "dummy0"
:running "no"
:stamp 857161382
:up "no"}
{:event "newlink"
:hwaddr "52:f0:46:da:0c:0c"
:index 22
:mtu 1500
:name "dummy0"
:running "no"
:stamp 857161383
:up "yes"}]
gen (event-generator events)]
(ifwait.run ["-v" "-s" "addmember" "dummy0" "up"] #gen)
(assert succeeded?))