github.com/EagleQL/Xray-core@v1.4.3/testing/scenarios/common_regular.go (about) 1 // +build !coverage 2 3 package scenarios 4 5 import ( 6 "bytes" 7 "fmt" 8 "os" 9 "os/exec" 10 ) 11 12 func BuildXray() error { 13 genTestBinaryPath() 14 if _, err := os.Stat(testBinaryPath); err == nil { 15 return nil 16 } 17 18 fmt.Printf("Building Xray into path (%s)\n", testBinaryPath) 19 cmd := exec.Command("go", "build", "-o="+testBinaryPath, GetSourcePath()) 20 cmd.Stdout = os.Stdout 21 cmd.Stderr = os.Stderr 22 return cmd.Run() 23 } 24 25 func RunXrayProtobuf(config []byte) *exec.Cmd { 26 genTestBinaryPath() 27 proc := exec.Command(testBinaryPath, "-config=stdin:", "-format=pb") 28 proc.Stdin = bytes.NewBuffer(config) 29 proc.Stderr = os.Stderr 30 proc.Stdout = os.Stdout 31 32 return proc 33 }