diff --git a/test/e2e/plugins_test.go b/test/e2e/plugins_test.go index e736e9b644..93cd4dbb5f 100644 --- a/test/e2e/plugins_test.go +++ b/test/e2e/plugins_test.go @@ -22,6 +22,7 @@ import ( "fmt" "io/ioutil" "os" + "os/exec" "path/filepath" "syscall" "testing" @@ -99,8 +100,10 @@ func TestPluginWithoutLookup(t *testing.T) { knFlags := []string{fmt.Sprintf("--plugins-dir=%s", pc.knPluginsDir), "--lookup-plugins=false"} t.Log("list plugin in --plugins-dir") - syscall.Exec("ls", []string{ "-l", pc.knPluginPath}, []string{}) - syscall.Exec("ls", []string{ "-l", pc.knPluginPath2}, []string{}) + t.Log("ls pluginPath:\n" + execute("ls", "-l", pc.knPluginPath)) + t.Log("ls pluginPath2:\n" + execute("ls", "-l", pc.knPluginPath2)) + syscall.Exec("ls", []string{"-l", pc.knPluginPath}, []string{}) + syscall.Exec("ls", []string{"-l", pc.knPluginPath2}, []string{}) listPlugin(r, knFlags, []string{pc.knPluginPath}, []string{}) t.Log("execute plugin in --plugins-dir") @@ -110,6 +113,19 @@ func TestPluginWithoutLookup(t *testing.T) { listPlugin(r, knFlags, []string{pc.knPluginPath}, []string{pc.knPluginPath2}) } +func execute(command string, args ...string) string { + cmd := exec.Command(command, args...) + r, w, _ := os.Pipe() + cmd.Stdout = w + cmd.Stderr = os.Stderr + cmd.Stdin = os.Stdin + cmd.Env = os.Environ() + cmd.Run() + w.Close() + ret, _ := ioutil.ReadAll(r) + return string(ret) +} + func TestPluginWithLookup(t *testing.T) { it, err := test.NewKnTest() assert.NilError(t, err) @@ -123,6 +139,8 @@ func TestPluginWithLookup(t *testing.T) { knFlags := []string{fmt.Sprintf("--plugins-dir=%s", pc.knPluginsDir), "--lookup-plugins=true"} + t.Log("ls pluginPath:\n" + execute("ls", "-l", pc.knPluginPath)) + t.Log("ls pluginPath2:\n" + execute("ls", "-l", pc.knPluginPath2)) t.Log("list plugin in --plugins-dir") listPlugin(r, knFlags, []string{pc.knPluginPath}, []string{pc.knPluginPath2})