common_regular.go 670 B

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