2016-08-08 22:55:36 +00:00
|
|
|
// +build !coverage
|
|
|
|
|
|
|
|
package scenarios
|
|
|
|
|
|
|
|
import (
|
2016-11-17 23:01:37 +00:00
|
|
|
"fmt"
|
2016-08-08 22:55:36 +00:00
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
|
|
|
func BuildV2Ray() error {
|
2016-11-17 23:01:37 +00:00
|
|
|
GenTestBinaryPath()
|
|
|
|
if _, err := os.Stat(testBinaryPath); err == nil {
|
2016-08-08 22:55:36 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-11-17 23:01:37 +00:00
|
|
|
fmt.Printf("Building V2Ray into path (%d)\n", testBinaryPath)
|
|
|
|
cmd := exec.Command("go", "build", "-tags=json", "-o="+testBinaryPath, GetSourcePath())
|
2016-08-08 22:55:36 +00:00
|
|
|
return cmd.Run()
|
|
|
|
}
|
|
|
|
|
|
|
|
func RunV2Ray(configFile string) *exec.Cmd {
|
2016-11-17 23:01:37 +00:00
|
|
|
GenTestBinaryPath()
|
|
|
|
proc := exec.Command(testBinaryPath, "-config", configFile)
|
2016-08-08 22:55:36 +00:00
|
|
|
proc.Stderr = os.Stderr
|
|
|
|
proc.Stdout = os.Stdout
|
|
|
|
|
|
|
|
return proc
|
|
|
|
}
|