carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package host
2
3import (
4 "bytes"
5 "os"
6 "path/filepath"
7 "testing"
8)
9
10// 6b-N2, adopt's half: repairing the system units keeps an enabled control
11// unit when host.env cannot be parsed. A flag-off one is still restored to
12// main's bytes (TestClaimBadUnitSettingsStillRepairSystemUnits).
13func TestPlan9AAdoptKeepsEnabledControlUnitOnHostEnvError(t *testing.T) {
14 for _, env := range plan9aOddHostEnv {
15 t.Run(env, func(t *testing.T) {
16 etc := t.TempDir()
17 plan9aWriteFile(t, filepath.Join(etc, "carlos", "host.env"), []byte(env))
18 installed := plan9aEnabledControl(t)
19 live := filepath.Join(etc, "systemd", "system", claimControlUnit)
20 plan9aWriteFile(t, live, installed)
21 ctl := func(args ...string) (string, error) { return "", nil }
22 probe := func(args ...string) (string, error) { return "inactive\n", nil }
23 ensureSystemUnits(etc, filepath.Join(t.TempDir(), "lock"), ctl, probe, t.Logf)
24 if got, _ := os.ReadFile(live); !bytes.Equal(got, installed) {
25 t.Fatalf("adopt flipped the enabled control unit:\n%s", got)
26 }
27 for _, name := range systemUnitFiles {
28 if _, err := os.Stat(filepath.Join(etc, "systemd", "system", name)); err != nil {
29 t.Fatal(err)
30 }
31 }
32 })
33 }
34}
35