fortify: print synthesised id in ps
All checks were successful
Test / Create distribution (push) Successful in 26s
Test / Sandbox (push) Successful in 1m48s
Test / Fortify (push) Successful in 2m42s
Test / Sandbox (race detector) (push) Successful in 2m53s
Test / Fpkg (push) Successful in 3m30s
Test / Fortify (race detector) (push) Successful in 4m7s
Test / Flake checks (push) Successful in 1m2s

This is not the full synthesised id so it does not get too long.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2025-04-07 21:55:07 +09:00
parent b5eff27c40
commit 50127ed5f9
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
2 changed files with 12 additions and 10 deletions

View File

@ -265,9 +265,11 @@ func printPs(output io.Writer, now time.Time, s state.Store, short, flagJSON boo
as := "(No configuration information)" as := "(No configuration information)"
if e.Config != nil { if e.Config != nil {
as = strconv.Itoa(e.Config.Confinement.AppID) as = strconv.Itoa(e.Config.Confinement.AppID)
if e.Config.ID != "" { id := e.Config.ID
as += " (" + e.Config.ID + ")" if id == "" {
id = "uk.gensokyo.fortify." + e.s[:8]
} }
as += " (" + id + ")"
} }
t.Printf("\t%s\t%d\t%s\t%s\n", t.Printf("\t%s\t%d\t%s\t%s\n",
e.s[:8], e.PID, as, now.Sub(e.Time).Round(time.Second).String()) e.s[:8], e.PID, as, now.Sub(e.Time).Round(time.Second).String())

View File

@ -454,19 +454,19 @@ func Test_printPs(t *testing.T) {
short, json bool short, json bool
want string want string
}{ }{
{"no entries", make(state.Entries), false, false, ` Instance PID Application Uptime {"no entries", make(state.Entries), false, false, " Instance PID Application Uptime\n"},
`}, {"no entries short", make(state.Entries), true, false, ""},
{"no entries short", make(state.Entries), true, false, ``}, {"nil instance", state.Entries{testID: nil}, false, false, " Instance PID Application Uptime\n"},
{"nil instance", state.Entries{testID: nil}, false, false, ` Instance PID Application Uptime {"state corruption", state.Entries{fst.ID{}: testState}, false, false, " Instance PID Application Uptime\n"},
`},
{"state corruption", state.Entries{fst.ID{}: testState}, false, false, ` Instance PID Application Uptime {"valid pd", state.Entries{testID: &state.State{ID: testID, PID: 1 << 8, Config: new(fst.Config), Time: testAppTime}}, false, false, ` Instance PID Application Uptime
8e2c76b0 256 0 (uk.gensokyo.fortify.8e2c76b0) 1h2m32s
`}, `},
{"valid", state.Entries{testID: testState}, false, false, ` Instance PID Application Uptime {"valid", state.Entries{testID: testState}, false, false, ` Instance PID Application Uptime
8e2c76b0 3735928559 9 (org.chromium.Chromium) 1h2m32s 8e2c76b0 3735928559 9 (org.chromium.Chromium) 1h2m32s
`}, `},
{"valid short", state.Entries{testID: testState}, true, false, `8e2c76b0 {"valid short", state.Entries{testID: testState}, true, false, "8e2c76b0\n"},
`},
{"valid json", state.Entries{testID: testState}, false, true, `{ {"valid json", state.Entries{testID: testState}, false, true, `{
"8e2c76b066dabe574cf073bdb46eb5c1": { "8e2c76b066dabe574cf073bdb46eb5c1": {
"instance": [ "instance": [