github.com/v2fly/v2ray-core/v4@v4.45.2/testing/scenarios/common_regular.go (about)

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