39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
//go:build linux
|
|
|
|
package service
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestRenderUnit(t *testing.T) {
|
|
unit := renderUnit("/var/lib/gpu-turnstile/gpu-turnstile", "/etc/gpu-turnstile.env", "")
|
|
for _, want := range []string{
|
|
"Type=notify",
|
|
"WatchdogSec=30s",
|
|
`ExecStart="/var/lib/gpu-turnstile/gpu-turnstile" -config "/etc/gpu-turnstile.env"`,
|
|
"Restart=on-failure",
|
|
"WantedBy=multi-user.target",
|
|
"DynamicUser=yes",
|
|
"StateDirectory=gpu-turnstile",
|
|
"RuntimeDirectory=gpu-turnstile",
|
|
"ProtectSystem=strict",
|
|
"NoNewPrivileges=yes",
|
|
"RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6",
|
|
"SystemCallFilter=@system-service",
|
|
} {
|
|
if !strings.Contains(unit, want) {
|
|
t.Fatalf("unit missing %q:\n%s", want, unit)
|
|
}
|
|
}
|
|
if strings.Contains(unit, "BindPaths") {
|
|
t.Fatalf("unit without COMFY_DIR must not bind anything:\n%s", unit)
|
|
}
|
|
|
|
unit = renderUnit("/var/lib/gpu-turnstile/gpu-turnstile", "/etc/gpu-turnstile.env", "/home/gpu/ComfyUI")
|
|
if !strings.Contains(unit, "BindPaths=/home/gpu/ComfyUI\n") {
|
|
t.Fatalf("unit with COMFY_DIR must bind it:\n%s", unit)
|
|
}
|
|
}
|