about summary refs log tree commit diff
path: root/src/tools/remote-test-server
diff options
context:
space:
mode:
authorMátyás Mustoha <mmatyas@inf.u-szeged.hu>2017-04-11 12:10:05 +0200
committerMátyás Mustoha <mmatyas@inf.u-szeged.hu>2017-05-04 12:43:22 +0200
commitb194def3a24e5d95c3f8eb7667b24e1237d823d3 (patch)
tree6527039d85f7ac1246c5c1564b456cb7202b4c94 /src/tools/remote-test-server
parentb16c7a235fa0f57fed6b7ec13ffd3cff1bcdd9ad (diff)
downloadrust-b194def3a24e5d95c3f8eb7667b24e1237d823d3.tar.gz
rust-b194def3a24e5d95c3f8eb7667b24e1237d823d3.zip
Add remote device testing support
Diffstat (limited to 'src/tools/remote-test-server')
-rw-r--r--src/tools/remote-test-server/src/main.rs55
1 files changed, 49 insertions, 6 deletions
diff --git a/src/tools/remote-test-server/src/main.rs b/src/tools/remote-test-server/src/main.rs
index 308ccdbef77..ae13acd58bb 100644
--- a/src/tools/remote-test-server/src/main.rs
+++ b/src/tools/remote-test-server/src/main.rs
@@ -8,10 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-/// This is a small server which is intended to run inside of an emulator. This
-/// server pairs with the `remote-test-client` program in this repository. The
-/// `remote-test-client` connects to this server over a TCP socket and performs
-/// work such as:
+/// This is a small server which is intended to run inside of an emulator or
+/// on a remote test device. This server pairs with the `remote-test-client`
+/// program in this repository. The `remote-test-client` connects to this
+/// server over a TCP socket and performs work such as:
 ///
 /// 1. Pushing shared libraries to the server
 /// 2. Running tests through the server
@@ -21,6 +21,7 @@
 /// basically custom format suiting our needs.
 
 use std::cmp;
+use std::env;
 use std::fs::{self, File, Permissions};
 use std::io::prelude::*;
 use std::io::{self, BufReader};
@@ -42,12 +43,54 @@ macro_rules! t {
 
 static TEST: AtomicUsize = ATOMIC_USIZE_INIT;
 
+struct Config {
+    pub remote: bool,
+    pub verbose: bool,
+}
+
+impl Config {
+    pub fn default() -> Config {
+        Config {
+            remote: false,
+            verbose: false,
+        }
+    }
+
+    pub fn parse_args() -> Config {
+        let mut config = Config::default();
+
+        let args = env::args().skip(1);
+        for argument in args {
+            match &argument[..] {
+                "remote" => {
+                    config.remote = true;
+                },
+                "verbose" | "-v" => {
+                    config.verbose = true;
+                }
+                arg => panic!("unknown argument: {}", arg),
+            }
+        }
+
+        config
+    }
+}
+
 fn main() {
     println!("starting test server");
+
+    let config = Config::parse_args();
+
+    let bind_addr = if cfg!(target_os = "android") || config.remote {
+        "0.0.0.0:12345"
+    } else {
+        "10.0.2.15:12345"
+    };
+
     let (listener, work) = if cfg!(target_os = "android") {
-        (t!(TcpListener::bind("0.0.0.0:12345")), "/data/tmp/work")
+        (t!(TcpListener::bind(bind_addr)), "/data/tmp/work")
     } else {
-        (t!(TcpListener::bind("10.0.2.15:12345")), "/tmp/work")
+        (t!(TcpListener::bind(bind_addr)), "/tmp/work")
     };
     println!("listening!");