MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / TestParsePsOutput_Linux

Function TestParsePsOutput_Linux

internal/bridge/modules_test.go:291–316  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

289}
290
291func TestParsePsOutput_Linux(t *testing.T) {
292 t.Parallel()
293 resp := parsePsOutput(linuxPsOutput, "Linux")
294
295 if len(resp.Processes) != 5 {
296 t.Fatalf("expected 5 processes, got %d", len(resp.Processes))
297 }
298
299 // Verify systemd PID=1 PPID=0.
300 p := resp.Processes[0]
301 if p.Pid != 1 || p.Ppid != 0 || p.Name != "systemd" {
302 t.Errorf("expected systemd PID=1 PPID=0, got name=%q pid=%d ppid=%d", p.Name, p.Pid, p.Ppid)
303 }
304 if p.Path != "/sbin/init" {
305 t.Errorf("expected path=/sbin/init, got %q", p.Path)
306 }
307
308 // Verify vim process with args.
309 p = resp.Processes[4]
310 if p.Name != "vim" || p.Owner != "john" {
311 t.Errorf("expected vim owner=john, got name=%q owner=%q", p.Name, p.Owner)
312 }
313 if !strings.Contains(p.Args, "/etc/hosts") {
314 t.Errorf("expected args containing /etc/hosts, got %q", p.Args)
315 }
316}
317
318// ===================================================================
319// Parser unit tests — parseLsOutput

Callers

nothing calls this directly

Calls 1

parsePsOutputFunction · 0.85

Tested by

no test coverage detected