aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Carver <anton@google.com>2015-06-30 18:04:36 +0100
committerAnton Carver <anton@google.com>2015-07-06 14:57:39 +0100
commitb1fd7aa580254a589aab2be67ec28f227e727cce (patch)
treea84d9a41e50a7688b9ddf68d63ce233d16f2a108
parentf46f2b5360460d71d012764f7192d8f112f7dfc0 (diff)
downloadgpu-b1fd7aa580254a589aab2be67ec28f227e727cce.tar.gz
Make the local replayd port configurable.
Make it so that testing is done on 9286 and development on 9284. Change-Id: I61f478ee4800463ba653febd13465d1c6c10cdff
-rw-r--r--cc/replayd/main.cpp10
-rw-r--r--integration/replay/utils/find_local_device.go5
-rw-r--r--make.go39
-rw-r--r--replay/README.md15
-rw-r--r--replay/device.go24
-rw-r--r--replay/replayd_default.go2
-rw-r--r--replay/replayd_win.go2
-rw-r--r--server/gapis/main.go13
8 files changed, 72 insertions, 38 deletions
diff --git a/cc/replayd/main.cpp b/cc/replayd/main.cpp
index 3065cef1c..19c23f3e4 100644
--- a/cc/replayd/main.cpp
+++ b/cc/replayd/main.cpp
@@ -111,15 +111,23 @@ int main(int argc, char* argv[]) {
GAPID_LOGGER_INIT("logs/replay.log");
bool useCache = true;
+ const char* portStr = "9284";
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "--nocache") == 0) {
printf("Disabling cache\n");
useCache = false;
}
+ if (strcmp(argv[i], "--port") == 0) {
+ if (i + 1 >= argc) {
+ fprintf(stderr, "Usage: --port <port_num>");
+ exit(1);
+ }
+ portStr = argv[i + 1];
+ }
}
const char* cachePath = useCache ? ("data" PATH_DELIMITER_STR "ccache") : nullptr;
MemoryManager memoryManager(memorySizes);
- listenConnections("9284", cachePath, &memoryManager);
+ listenConnections(portStr, cachePath, &memoryManager);
return EXIT_SUCCESS;
}
diff --git a/integration/replay/utils/find_local_device.go b/integration/replay/utils/find_local_device.go
index a615bcae7..9adaefddd 100644
--- a/integration/replay/utils/find_local_device.go
+++ b/integration/replay/utils/find_local_device.go
@@ -30,8 +30,9 @@ const localDeviceName = "Local machine" // TODO: Remove hard-coded string.
// FindLocalDevice returns the replay Device for the local host. If the local
// host cannot be found then the test fails and nil is returned.
func FindLocalDevice(t *testing.T, mgr *replay.Manager) replay.Device {
- replay.DisableLocalDeviceCache = true // disable disk-cache
- replay.LocalReplayBinary = filepath.Join(os.Getenv("GOPATH"), "bin", filepath.Base(replay.LocalReplayBinary))
+ replay.ConfigureLocalReplayDevice(true, // disable disk-cache
+ filepath.Join(os.Getenv("GOPATH"), "bin", filepath.Base(replay.Replayd)),
+ 9286)
for i := 0; i < findLocalDeviceAttempts; i++ {
for _, d := range mgr.Devices() {
info := d.Info()
diff --git a/make.go b/make.go
index 4b7b63cd4..60c917655 100644
--- a/make.go
+++ b/make.go
@@ -213,25 +213,30 @@ func MarkdownDocs(docs *Step) {
func ShutdownReplayd() Entity {
e := Virtual("shutdownreplayd")
NewStep(func(*Step) error {
- endpoint := "localhost:9284" // TODO: Remove the hardcoded port number.
- for i := 0; i < 10; i++ {
- conn, err := net.Dial("tcp", endpoint)
- if err != nil {
- // Assume this means there is no replayd
- return nil
+ for _, endpoint := range []string{"localhost:9284", "localhost:9286"} {
+ const maxRetries = 10
+ for i := 0; i < maxRetries; i++ {
+ conn, err := net.Dial("tcp", endpoint)
+ if err != nil {
+ // Assume this means there is no replayd
+ break
+ }
+ defer conn.Close()
+ msg := []byte{ReplaydShutdownRequest}
+ n, err := conn.Write(msg)
+ if err != nil {
+ return fmt.Errorf("Failed to send shutdown request to Replayd %v", err)
+ }
+ if n != len(msg) {
+ return fmt.Errorf("Failed to send shutdown request to Replayd (only sent %v bytes", n)
+ }
+ if i == maxRetries-1 {
+ return fmt.Errorf("Replayd at %v did not die", endpoint)
+ }
+ time.Sleep(100 * time.Millisecond)
}
- defer conn.Close()
- msg := []byte{ReplaydShutdownRequest}
- n, err := conn.Write(msg)
- if err != nil {
- return fmt.Errorf("Failed to send shutdown request to Replayd %v", err)
- }
- if n != len(msg) {
- return fmt.Errorf("Failed to send shutdown request to Replayd (only sent %v bytes", n)
- }
- time.Sleep(100 * time.Millisecond)
}
- return fmt.Errorf("Replayd at %v did not die", endpoint)
+ return nil
}).Creates(e)
return e
}
diff --git a/replay/README.md b/replay/README.md
index 79a0a7183..2a9d74d07 100644
--- a/replay/README.md
+++ b/replay/README.md
@@ -7,16 +7,19 @@ Package replay is used to issue replay requests to replay devices.
## Usage
```go
-var DisableLocalDeviceCache = false
+const Replayd = "replayd"
```
-DisableLocalDeviceCache can be used to disable the disk-cache for the local
-device. If true, it is passed as a flag to replayd on spawning. This can be used
-for disabling the cache for tests.
```go
-var LocalReplayBinary = replayd
+const Replayd = "replayd.exe"
```
-LocalReplayBinary is the full path to the local binary.
+
+#### func ConfigureLocalReplayDevice
+
+```go
+func ConfigureLocalReplayDevice(disableCache bool, binary string, port int)
+```
+Allow adjusting the settings for replayd.
#### func Replay
diff --git a/replay/device.go b/replay/device.go
index 023b0ef10..6ba3ecf09 100644
--- a/replay/device.go
+++ b/replay/device.go
@@ -29,10 +29,20 @@ import (
// DisableLocalDeviceCache can be used to disable the disk-cache for the local
// device. If true, it is passed as a flag to replayd on spawning. This can be
// used for disabling the cache for tests.
-var DisableLocalDeviceCache = false
+var disableLocalDeviceCache = false
-// LocalReplayBinary is the full path to the local binary.
-var LocalReplayBinary = replayd
+// localReplayBinary is the full path to the local binary.
+var localReplayBinary = Replayd
+
+// Port number of the "replayd" running on the local device
+var localDevicePort = 9284
+
+// Allow adjusting the settings for replayd.
+func ConfigureLocalReplayDevice(disableCache bool, binary string, port int) {
+ disableLocalDeviceCache = disableCache
+ localReplayBinary = binary
+ localDevicePort = port
+}
// deviceOS is an enumerator of operating systems that the replay target may be
// running on.
@@ -102,10 +112,10 @@ func (androidDevice) Connect() (io.ReadWriteCloser, error) {
}
func (localDevice) Connect() (io.ReadWriteCloser, error) {
- endpoint := "localhost:9284" // TODO: Remove the hardcoded port number.
+ endpoint := fmt.Sprintf("localhost:%d", localDevicePort)
conn, err := net.Dial("tcp", endpoint)
if err != nil {
- if err := spawnChild(LocalReplayBinary); err != nil {
+ if err := spawnChild(localReplayBinary); err != nil {
return nil, err
}
for i := 0; i < 10; i++ {
@@ -129,9 +139,11 @@ func spawnChild(path string) error {
return err
}
args := []string{path}
- if DisableLocalDeviceCache {
+ if disableLocalDeviceCache {
args = append(args, "--nocache")
}
+ args = append(args, "--port")
+ args = append(args, fmt.Sprintf("%d", localDevicePort))
proc, err := os.StartProcess(path, args, &os.ProcAttr{
Files: []*os.File{null, null, null},
})
diff --git a/replay/replayd_default.go b/replay/replayd_default.go
index 59ff50566..f66e05860 100644
--- a/replay/replayd_default.go
+++ b/replay/replayd_default.go
@@ -16,4 +16,4 @@
package replay
-const replayd = "replayd"
+const Replayd = "replayd"
diff --git a/replay/replayd_win.go b/replay/replayd_win.go
index 59b03c2c4..4a9639742 100644
--- a/replay/replayd_win.go
+++ b/replay/replayd_win.go
@@ -16,4 +16,4 @@
package replay
-const replayd = "replayd.exe"
+const Replayd = "replayd.exe"
diff --git a/server/gapis/main.go b/server/gapis/main.go
index 695984687..a231b9644 100644
--- a/server/gapis/main.go
+++ b/server/gapis/main.go
@@ -21,14 +21,16 @@ import (
"runtime"
"android.googlesource.com/platform/tools/gpu/atexit"
+ "android.googlesource.com/platform/tools/gpu/replay"
"android.googlesource.com/platform/tools/gpu/server"
)
var (
- http = flag.String("http", "localhost:8080", "TCP host:port of the server's HTTP listener")
- rpc = flag.String("rpc", "localhost:6700", "TCP host:port of the server's RPC listener")
- dataPath = flag.String("data", "data", "Path to the server's data folder")
- logfilePath = flag.String("logfile", filepath.Join("logs", "server.log"), "Path to the server's logfile")
+ http = flag.String("http", "localhost:8080", "TCP host:port of the server's HTTP listener")
+ rpc = flag.String("rpc", "localhost:6700", "TCP host:port of the server's RPC listener")
+ dataPath = flag.String("data", "data", "Path to the server's data folder")
+ logfilePath = flag.String("logfile", filepath.Join("logs", "server.log"), "Path to the server's logfile")
+ localDevicePort = flag.Int("local_replayd_port", 9284, "Port number of the \"replayd\" running on the local device")
)
func main() {
@@ -43,6 +45,9 @@ func main() {
dataAbsPath, _ := filepath.Abs(*dataPath)
logfileAbsPath, _ := filepath.Abs(*logfilePath)
+ replay.ConfigureLocalReplayDevice(false, // disable disk-cache
+ replay.Replayd, *localDevicePort)
+
server.Run(server.Config{
HttpAddress: *http,
RpcAddress: *rpc,