package main import ( "os" "path/filepath" "strings" "testing" ) // A relative exit-marker command passes os.Stat and is then refused by systemd when the FIRST run // tries to start — measured on systemd 259: "neither a valid executable name nor an absolute path", // which fails the whole unit. The platform then claims the attempt, fails to spawn, gives the claim // back and repeats on every sweep, so the only symptom is that nothing ever runs (register row // PD-165). Refused at boot instead, where an operator is watching, exactly as StateDir is. // // Mutation caught: dropping the filepath.IsAbs guard and relying on os.Stat. func TestARelativeExitMarkerCommandIsRefusedAtBoot(t *testing.T) { dir := t.TempDir() bin := filepath.Join(dir, "tmplatformctl") if err := os.WriteFile(bin, []byte("#!/bin/sh\n"), 0o755); err != nil { t.Fatal(err) } // The same file, named relatively from a working directory where it really is present: os.Stat // says yes and systemd says no, which is the whole of the defect. t.Chdir(dir) if _, err := markerArgv("./tmplatformctl"); err == nil { t.Fatal("a relative exit-marker command was accepted; systemd refuses it and every run would fail to start") } else if !strings.Contains(err.Error(), "absolute") { t.Errorf("the refusal does not name the cause: %v", err) } argv, err := markerArgv(bin) if err != nil { t.Fatalf("an absolute command was refused: %v", err) } if len(argv) != 2 || argv[0] != bin || argv[1] != "exit-marker" { t.Errorf("argv = %v", argv) } }