MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / TestHelperProcess

Function TestHelperProcess

pkg/funclet/command/command_test.go:82–293  ·  view source on GitHub ↗
(*testing.T)

Source from the content-addressed store, hash-verified

80}
81
82func TestHelperProcess(*testing.T) {
83 if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" {
84 return
85 }
86 defer os.Exit(0)
87
88 // Determine which command to use to display open files.
89 ofcmd := "lsof"
90 switch runtime.GOOS {
91 case "dragonfly", "freebsd", "netbsd", "openbsd":
92 ofcmd = "fstat"
93 case "plan9":
94 ofcmd = "/bin/cat"
95 case "aix":
96 ofcmd = "procfiles"
97 }
98
99 args := os.Args
100 for len(args) > 0 {
101 if args[0] == "--" {
102 args = args[1:]
103 break
104 }
105 args = args[1:]
106 }
107 if len(args) == 0 {
108 fmt.Fprintf(os.Stderr, "No command\n")
109 os.Exit(2)
110 }
111
112 cmd, args := args[0], args[1:]
113 switch cmd {
114 case "echo":
115 iargs := []interface{}{}
116 for _, s := range args {
117 iargs = append(iargs, s)
118 }
119 fmt.Println(iargs...)
120 case "echoenv":
121 for _, s := range args {
122 fmt.Println(os.Getenv(s))
123 }
124 os.Exit(0)
125 case "cat":
126 if len(args) == 0 {
127 io.Copy(os.Stdout, os.Stdin)
128 return
129 }
130 exit := 0
131 for _, fn := range args {
132 f, err := os.Open(fn)
133 if err != nil {
134 fmt.Fprintf(os.Stderr, "Error: %v\n", err)
135 exit = 2
136 } else {
137 defer f.Close()
138 io.Copy(os.Stdout, f)
139 }

Callers

nothing calls this directly

Calls 6

basefdsFunction · 0.85
CloseMethod · 0.65
WriteMethod · 0.65
SleepMethod · 0.65
CopyMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected