MCPcopy Index your code
hub / github.com/kubernetes/node-problem-detector / TestExec

Function TestExec

pkg/util/exec_test.go:26–64  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestExec(t *testing.T) {
27 var cmds [][]string
28
29 if runtime.GOOS == "windows" {
30 cmds = [][]string{
31 {"powershell.exe"},
32 {"cmd.exe", "/C", "set", "/p", "$="},
33 {"cmd.exe", "/K", "set", "/p", "$="},
34 {"testdata/hello-world.cmd"},
35 {"testdata/hello-world.bat"},
36 {"testdata/hello-world.ps1"},
37 }
38 } else {
39 cmds = [][]string{
40 {"/bin/sh"},
41 {"/bin/bash"},
42 }
43 }
44
45 ctx := context.TODO()
46 for _, v := range cmds {
47 args := v
48 t.Run(fmt.Sprintf("%v", args), func(t *testing.T) {
49 cmd := Exec(ctx, args[0], args[1:]...)
50
51 if err := Kill(cmd); err == nil {
52 t.Error("Kill(cmd) expected to have error because of empty handle, got none")
53 }
54
55 if err := cmd.Start(); err != nil {
56 t.Errorf("Start() got error, %v", err)
57 }
58
59 if err := Kill(cmd); err != nil {
60 t.Errorf("Kill(cmd) for %s %v got error, %v", cmd.Path, cmd.Args, err)
61 }
62 })
63 }
64}

Callers

nothing calls this directly

Calls 4

ExecFunction · 0.70
KillFunction · 0.70
RunMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected