- router.dnsProviders: named accounts at DNS providers, used by dynamic DNS and certificates (ddclient and lego provider lists in pkgs/router-webui/providers.json). Schema 2 migrates router.ddns. - router.acme: a Let's Encrypt certificate for the web UI via security.acme (DNS-01, resolver 1.1.1.1), served and reloaded by the web UI; Certificate page. - Web UI: password change (web UI and root), reboot button, HTTP to HTTPS redirect (router.webui.httpPort), grouped menu. - Latest kernel (linuxPackages_latest); 7.3 and 7.3.0 are the same kernel for the reboot hint. - SPECS.md: wanted later (REST API, GraphQL, MCP). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV9dZrK6nipHkPfyM4F
73 lines
2.3 KiB
Go
73 lines
2.3 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestReadSensors(t *testing.T) {
|
|
root := t.TempDir()
|
|
write := func(path, content string) {
|
|
t.Helper()
|
|
p := filepath.Join(root, path)
|
|
os.MkdirAll(filepath.Dir(p), 0o755)
|
|
if err := os.WriteFile(p, []byte(content+"\n"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
write("thermal/thermal_zone0/type", "acpitz")
|
|
write("thermal/thermal_zone0/temp", "47000")
|
|
write("thermal/thermal_zone1/type", "x86_pkg_temp")
|
|
write("thermal/thermal_zone1/temp", "61000")
|
|
write("thermal/thermal_zone2/type", "broken")
|
|
write("thermal/thermal_zone2/temp", "0")
|
|
write("hwmon/hwmon3/name", "coretemp")
|
|
write("hwmon/hwmon3/temp1_input", "62000")
|
|
write("hwmon/hwmon3/temp1_label", "Package id 0")
|
|
write("hwmon/hwmon3/temp2_input", "58500")
|
|
write("hwmon/hwmon3/temp2_label", "Core 0")
|
|
write("hwmon/hwmon4/name", "nvme")
|
|
write("hwmon/hwmon4/temp1_input", "39000")
|
|
write("hwmon/hwmon5/name", "nvme")
|
|
write("hwmon/hwmon5/temp1_input", "41000")
|
|
|
|
got := readSensors(filepath.Join(root, "thermal"), filepath.Join(root, "hwmon"))
|
|
want := map[string]float64{
|
|
"acpitz": 47, "x86_pkg_temp": 61, "coretemp Package id 0": 62, "coretemp Core 0": 58.5,
|
|
"nvme temp1": 39, "nvme temp1 2": 41,
|
|
}
|
|
if len(got) != len(want) {
|
|
t.Fatalf("sensors = %+v", got)
|
|
}
|
|
for _, s := range got {
|
|
if v, ok := want[s.Label]; !ok || v != s.Temp || s.Key != s.Label {
|
|
t.Errorf("unexpected %+v", s)
|
|
}
|
|
}
|
|
if h := hottest(got); h != 62 {
|
|
t.Errorf("hottest = %v", h)
|
|
}
|
|
if got := readSensors(filepath.Join(root, "none"), filepath.Join(root, "none")); len(got) != 0 || hottest(got) == hottest(got) {
|
|
t.Errorf("no sensors: %+v (hottest should be NaN)", got)
|
|
}
|
|
}
|
|
|
|
func TestPendingKernel(t *testing.T) {
|
|
img := "/nix/store/abc123-linux-6.12.5/bzImage"
|
|
for running, want := range map[string]string{"6.12.5": "", "6.12.5-zen1": "", "6.12.5.0": "", "6.12.4": "6.12.5", "": ""} {
|
|
if got := pendingKernel(running, img); got != want {
|
|
t.Errorf("running %q: %q, want %q", running, got, want)
|
|
}
|
|
}
|
|
if got := pendingKernel("7.3.0", "/nix/store/abc-linux-7.3/bzImage"); got != "" {
|
|
t.Errorf("7.3.0 is 7.3: %q", got)
|
|
}
|
|
if got := pendingKernel("6.12.4", "/boot/vmlinuz"); got != "" {
|
|
t.Errorf("an unknown path gave %q", got)
|
|
}
|
|
if k := systemStatus().Kernel; k == "" {
|
|
t.Skip("no /proc/sys/kernel/osrelease")
|
|
}
|
|
}
|