AtlatestRepositorysigil-ui
1
#!/usr/bin/env sigil2
(import (sigil shell prelude))3
(define root (realpath (path (script-dir) "..")))4
(define headers (arg 1))5
(define archive (arg 2))6
(define evidence (arg 3))7
(define compiler (or (getenv "CC") "cc"))8
(unless (and (file? (path headers "sigil/sigil.h")) (file? archive))9
(error "Expected matching Sigil runtime headers and static archive"))10
(ensure-directory evidence)11
(define cases '("valid" "reuse-table" "missing" "legacy" "short-table" "oversized-table"12
"odd-table" "bad-device" "bad-index" "odd-index" "duplicate-pair"13
"duplicate-flags" "missing-main" "unfinished-tranche" "format-limit" "tranche-limit"14
"close-active" "close-partial" "disconnect"))15
(each variant '("plain" "sanitized")16
(define executable (path evidence (str "feedback-" variant)))17
(define flags18
(append '("-std=c11" "-D_GNU_SOURCE" "-O1" "-g" "-Wall" "-Wextra" "-Werror" "-Wno-unused-parameter")19
(if (equal? variant "sanitized") '("-fsanitize=address,undefined" "-fno-omit-frame-pointer") '())20
(list (str "-I" headers) (str "-I" (path root "native"))21
(str "-I" (path root "native/wayland")) (str "-I" (path root "native/wayland/include")))))22
(define compiled ($? ,compiler ,@flags ,(path root "test/wayland/dmabuf-feedback-peer.c")23
,archive -lm -ldl -lpthread -o ,executable24
out: ,(path evidence (str variant "-compile.log")) err: 'merge timeout: 40))25
(unless (ok? compiled)26
(display (read-text (path evidence (str variant "-compile.log"))))27
(error "Feedback fixture did not compile" variant))28
(each case cases29
(define log (path evidence (str variant "-" case ".log")))30
(define result ($? ,executable ,case31
env: '(("ASAN_OPTIONS" . "detect_leaks=1:abort_on_error=1")32
("UBSAN_OPTIONS" . "halt_on_error=1:print_stacktrace=1"))33
out: ,log err: 'merge timeout: 10))34
(display (read-text log))35
(unless (and (ok? result) (contains? (read-text log) (str "PASS: feedback wire " case ",")))36
(error "Feedback wire check failed" variant case (format-outcome result)))))37
(println "PASS: 19 feedback wire cases in plain and ASan/UBSan builds")