diff options
Diffstat (limited to 'test/xdsserver_test.go')
-rw-r--r-- | test/xdsserver_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/xdsserver_test.go b/test/xdsserver_test.go index 5722d31..76c54ea 100644 --- a/test/xdsserver_test.go +++ b/test/xdsserver_test.go @@ -17,9 +17,11 @@ package xdsservertest import ( + "io" "log" "os" "os/exec" + "path" "testing" "time" @@ -32,6 +34,26 @@ var HTTPCli *common.HTTPClient var logDir string var sdkDir string +func Copy(src, dst string) error { + in, err := os.Open(src) + if err != nil { + return err + } + defer in.Close() + + out, err := os.Create(dst) + if err != nil { + return err + } + defer out.Close() + + _, err = io.Copy(out, in) + if err != nil { + return err + } + return out.Close() +} + func initEnv(launchProcess bool) { if launchProcess { cmd := exec.Command("killall", "-9", "xds-server") @@ -62,6 +84,13 @@ func initEnv(launchProcess bool) { logDir = rootTestLog + "/logs/" os.MkdirAll(logDir, 0755) os.MkdirAll(sdkDir, 0755) + currentDir, err := os.Getwd() + if err != nil { + log.Fatal(err) + } + if err := Copy(path.Join(currentDir, sdkFile), path.Join(sdkDir, sdkFileName)); err != nil { + log.Fatal(err) + } } func launchXdsServer(proc **os.Process) *os.File { |