github.com/Uhtred009/v2ray-core-1@v4.31.2+incompatible/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 BuildV2Ray() error {
    13  	genTestBinaryPath()
    14  	if _, err := os.Stat(testBinaryPath); err == nil {
    15  		return nil
    16  	}
    17  
    18  	fmt.Printf("Building V2Ray into path (%s)\n", testBinaryPath)
    19  	cmd := exec.Command("go", "build", "-o="+testBinaryPath, GetSourcePath())
    20  	return cmd.Run()
    21  }
    22  
    23  func RunV2RayProtobuf(config []byte) *exec.Cmd {
    24  	genTestBinaryPath()
    25  	proc := exec.Command(testBinaryPath, "-config=stdin:", "-format=pb")
    26  	proc.Stdin = bytes.NewBuffer(config)
    27  	proc.Stderr = os.Stderr
    28  	proc.Stdout = os.Stdout
    29  
    30  	return proc
    31  }