|
|
@@ -7,6 +7,7 @@ import (
|
|
|
"os/exec"
|
|
|
"path/filepath"
|
|
|
|
|
|
+ "bytes"
|
|
|
"v2ray.com/core/common/uuid"
|
|
|
)
|
|
|
|
|
|
@@ -32,3 +33,17 @@ func RunV2Ray(configFile string) *exec.Cmd {
|
|
|
|
|
|
return proc
|
|
|
}
|
|
|
+
|
|
|
+func RunV2RayProtobuf(config []byte) *exec.Cmd {
|
|
|
+ GenTestBinaryPath()
|
|
|
+
|
|
|
+ covDir := filepath.Join(os.Getenv("GOPATH"), "out", "v2ray", "cov")
|
|
|
+ os.MkdirAll(covDir, os.ModeDir)
|
|
|
+ profile := uuid.New().String() + ".out"
|
|
|
+ proc := exec.Command(testBinaryPath, "-config=stdin:", "-format=pb", "-test.run", "TestRunMainForCoverage", "-test.coverprofile", profile, "-test.outputdir", covDir)
|
|
|
+ proc.Stdin = bytes.NewBuffer(config)
|
|
|
+ proc.Stderr = os.Stderr
|
|
|
+ proc.Stdout = os.Stdout
|
|
|
+
|
|
|
+ return proc
|
|
|
+}
|