diff options
author | jbudorick <jbudorick@chromium.org> | 2015-02-27 17:46:17 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-28 01:47:00 +0000 |
commit | 6b2d16b5072558e38155bb727e4de041e176aac8 (patch) | |
tree | 739314628621c6875dfa71bbe6a014a6f622d622 | |
parent | d6d6e51d6ceffc06b883e559b523262fd37c67d3 (diff) | |
download | chromium_src-6b2d16b5072558e38155bb727e4de041e176aac8.zip chromium_src-6b2d16b5072558e38155bb727e4de041e176aac8.tar.gz chromium_src-6b2d16b5072558e38155bb727e4de041e176aac8.tar.bz2 |
[Android] Remove TestServerSpawner dependency from ChromeNativeTestInstrumentationTestRunner.
BUG=462239
Review URL: https://codereview.chromium.org/963643002
Cr-Commit-Position: refs/heads/master@{#318568}
-rw-r--r-- | build/android/pylib/gtest/local_device_gtest_run.py | 29 | ||||
-rw-r--r-- | build/apk_test.gypi | 1 | ||||
-rw-r--r-- | build/config/android/rules.gni | 1 | ||||
-rw-r--r-- | testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java | 51 |
4 files changed, 16 insertions, 66 deletions
diff --git a/build/android/pylib/gtest/local_device_gtest_run.py b/build/android/pylib/gtest/local_device_gtest_run.py index 3ca0374..c48c865 100644 --- a/build/android/pylib/gtest/local_device_gtest_run.py +++ b/build/android/pylib/gtest/local_device_gtest_run.py @@ -24,9 +24,6 @@ _EXTRA_COMMAND_LINE_FILE = ( 'org.chromium.native_test.ChromeNativeTestActivity.CommandLineFile') _EXTRA_COMMAND_LINE_FLAGS = ( 'org.chromium.native_test.ChromeNativeTestActivity.CommandLineFlags') -_EXTRA_ENABLE_TEST_SERVER_SPAWNER = ( - 'org.chromium.native_test.ChromeNativeTestInstrumentationTestRunner' - '.EnableTestServerSpawner') _MAX_SHARD_SIZE = 256 @@ -44,9 +41,6 @@ class _ApkDelegate(object): self._component = '%s/%s' % (self._package, self._runner) self._enable_test_server_spawner = False - def EnableTestServerSpawner(self): - self._enable_test_server_spawner = True - def Install(self, device): device.Install(self._apk) @@ -57,8 +51,6 @@ class _ApkDelegate(object): extras = { _EXTRA_COMMAND_LINE_FILE: command_line_file.name, } - if self._enable_test_server_spawner: - extras[_EXTRA_ENABLE_TEST_SERVER_SPAWNER] = '1' return device.StartInstrumentation( self._component, extras=extras, raw=False, **kwargs) @@ -81,9 +73,6 @@ class _ExeDelegate(object): self._deps_host_path = None self._test_run = tr - def EnableTestServerSpawner(self): - pass - def Install(self, device): # TODO(jbudorick): Look into merging this with normal data deps pushing if # executables become supported on nonlocal environments. @@ -143,6 +132,8 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun): elif self._test_instance.exe: self._delegate = _ExeDelegate(self, self._test_instance.exe) + self._servers = {} + #override def TestPackage(self): return self._test_instance._suite @@ -161,8 +152,14 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun): for h, d in host_device_tuples] dev.PushChangedFiles(host_device_tuples) + self._servers[str(dev)] = [] if self.TestPackage() in _SUITE_REQUIRES_TEST_SERVER_SPAWNER: - self._delegate.EnableTestServerSpawner() + self._servers[str(dev)].append( + local_test_server_spawner.LocalTestServerSpawner( + ports.AllocateTestServerPort(), dev, self.GetTool(dev))) + + for s in self._servers[str(dev)]: + s.SetUp() self._env.parallel_devices.pMap(individual_device_set_up, self._test_instance.GetDataDependencies()) @@ -194,6 +191,8 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun): # Run the test. output = self._delegate.RunWithFlags(device, '--gtest_filter=%s' % test, timeout=900, retries=0) + for s in self._servers[str(device)]: + s.Reset() self._delegate.Clear(device) # Parse the output. @@ -203,5 +202,9 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun): #override def TearDown(self): - pass + def individual_device_tear_down(dev): + for s in self._servers[str(dev)]: + s.TearDown() + + self._env.parallel_devices.pMap(individual_device_tear_down) diff --git a/build/apk_test.gypi b/build/apk_test.gypi index 5ee494c..05bafab 100644 --- a/build/apk_test.gypi +++ b/build/apk_test.gypi @@ -22,7 +22,6 @@ '<(DEPTH)/base/base.gyp:base_java', '<(DEPTH)/build/android/pylib/device/commands/commands.gyp:chromium_commands', '<(DEPTH)/build/android/pylib/remote/device/dummy/dummy.gyp:remote_device_dummy_apk', - '<(DEPTH)/net/net.gyp:net_java_test_support', '<(DEPTH)/tools/android/android_tools.gyp:android_tools', ], 'conditions': [ diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni index aa1fd2a..c33ea11 100644 --- a/build/config/android/rules.gni +++ b/build/config/android/rules.gni @@ -1499,7 +1499,6 @@ template("unittest_apk") { deps = [ "//base:base_java", "//build/android/pylib/remote/device/dummy:remote_device_dummy_apk", - "//net/android:net_java_test_support", ] if (defined(invoker.deps)) { deps += invoker.deps diff --git a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java index cc89268..4e1a067 100644 --- a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java +++ b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java @@ -12,17 +12,13 @@ import android.os.Bundle; import android.os.Environment; import android.util.Log; -import org.chromium.net.test.TestServerSpawner; - import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; -import java.io.OutputStreamWriter; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; @@ -36,15 +32,11 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation { public static final String EXTRA_ONLY_OUTPUT_FAILURES = "org.chromium.native_test.ChromeNativeTestInstrumentationTestRunner." + "OnlyOutputFailures"; - public static final String EXTRA_ENABLE_TEST_SERVER_SPAWNER = - "org.chromium.native_test.ChromeNativeTestInstrumentationTestRunner." - + "EnableTestServerSpawner"; private static final String TAG = "ChromeNativeTestInstrumentationTestRunner"; private static final int ACCEPT_TIMEOUT_MS = 5000; private static final Pattern RE_TEST_OUTPUT = Pattern.compile("\\[ *([^ ]*) *\\] ?([^ ]+) .*"); - private static final int SERVER_SPAWNER_PORT = 0; private static interface ResultsBundleGenerator { public Bundle generate(Map<String, TestResult> rawResults); @@ -57,10 +49,6 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation { private ResultsBundleGenerator mBundleGenerator; private boolean mOnlyOutputFailures; - private boolean mEnableTestServerSpawner; - private TestServerSpawner mTestServerSpawner; - private Thread mTestServerSpawnerThread; - @Override public void onCreate(Bundle arguments) { mCommandLineFile = arguments.getString(ChromeNativeTestActivity.EXTRA_COMMAND_LINE_FILE); @@ -77,55 +65,16 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation { mLogBundle = new Bundle(); mBundleGenerator = new RobotiumBundleGenerator(); mOnlyOutputFailures = arguments.containsKey(EXTRA_ONLY_OUTPUT_FAILURES); - mEnableTestServerSpawner = arguments.containsKey(EXTRA_ENABLE_TEST_SERVER_SPAWNER); - mTestServerSpawner = null; - mTestServerSpawnerThread = null; start(); } @Override public void onStart() { super.onStart(); - - setUp(); Bundle results = runTests(); - tearDown(); - finish(Activity.RESULT_OK, results); } - private void setUp() { - if (mEnableTestServerSpawner) { - Log.i(TAG, "Test server spawner enabled."); - try { - mTestServerSpawner = new TestServerSpawner(SERVER_SPAWNER_PORT, ACCEPT_TIMEOUT_MS); - - File portFile = new File( - Environment.getExternalStorageDirectory(), "net-test-server-ports"); - OutputStreamWriter writer = - new OutputStreamWriter(new FileOutputStream(portFile)); - writer.write(Integer.toString(mTestServerSpawner.getServerPort()) + ":0"); - writer.close(); - - mTestServerSpawnerThread = new Thread(mTestServerSpawner); - mTestServerSpawnerThread.start(); - } catch (IOException e) { - Log.e(TAG, "Error creating TestServerSpawner: " + e.toString()); - } - } - } - - private void tearDown() { - if (mTestServerSpawnerThread != null) { - try { - mTestServerSpawner.stop(); - mTestServerSpawnerThread.join(); - } catch (InterruptedException e) { - Log.e(TAG, "Interrupted while shutting down test server spawner: " + e.toString()); - } - } - } - /** Runs the tests in the ChromeNativeTestActivity and returns a Bundle containing the results. */ private Bundle runTests() { |