diff options
-rw-r--r-- | build/all_android.gyp | 2 | ||||
-rw-r--r-- | build/android/pylib/forwarder.py | 1 | ||||
-rw-r--r-- | build/android/pylib/gtest/gtest_config.py | 4 | ||||
-rw-r--r-- | sandbox/linux/sandbox_linux.gypi | 57 | ||||
-rw-r--r-- | sandbox/linux/sandbox_linux_test_sources.gypi | 38 | ||||
-rw-r--r-- | sandbox/linux/services/broker_process_unittest.cc | 9 |
6 files changed, 72 insertions, 39 deletions
diff --git a/build/all_android.gyp b/build/all_android.gyp index f904347..ff0d227 100644 --- a/build/all_android.gyp +++ b/build/all_android.gyp @@ -99,7 +99,7 @@ '../ipc/ipc.gyp:ipc_tests_apk', '../media/media.gyp:media_unittests_apk', '../net/net.gyp:net_unittests_apk', - '../sandbox/sandbox.gyp:sandbox_linux_unittests_apk', + '../sandbox/sandbox.gyp:sandbox_linux_jni_unittests_apk', '../sql/sql.gyp:sql_unittests_apk', '../sync/sync.gyp:sync_unit_tests_apk', '../ui/ui.gyp:ui_unittests_apk', diff --git a/build/android/pylib/forwarder.py b/build/android/pylib/forwarder.py index 460a3dc..137ffe4 100644 --- a/build/android/pylib/forwarder.py +++ b/build/android/pylib/forwarder.py @@ -107,6 +107,7 @@ class Forwarder(object): def KillHost(build_type): logging.info('Killing host_forwarder.') host_forwarder_path = _MakeBinaryPath(build_type, 'host_forwarder') + assert os.path.exists(host_forwarder_path), 'Please build forwarder2' (exit_code, output) = cmd_helper.GetCmdStatusAndOutput( [host_forwarder_path, 'kill-server']) if exit_code != 0: diff --git a/build/android/pylib/gtest/gtest_config.py b/build/android/pylib/gtest/gtest_config.py index 41cb818..8512dc4 100644 --- a/build/android/pylib/gtest/gtest_config.py +++ b/build/android/pylib/gtest/gtest_config.py @@ -6,7 +6,9 @@ # Add new suites here before upgrading them to the stable list below. EXPERIMENTAL_TEST_SUITES = [ - 'sandbox_linux_unittests', + # The JNI version of the sandbox_linux_unittests. Should be changed to + # 'sandbox_linux_unittests' once it can be run with --exe. + 'sandbox_linux_jni_unittests', ] # Do not modify this list without approval of an android owner. diff --git a/sandbox/linux/sandbox_linux.gypi b/sandbox/linux/sandbox_linux.gypi index a223feb..ae7769f 100644 --- a/sandbox/linux/sandbox_linux.gypi +++ b/sandbox/linux/sandbox_linux.gypi @@ -65,41 +65,26 @@ ], }, { + # The main sandboxing test target. 'target_name': 'sandbox_linux_unittests', - 'type': '<(gtest_target_type)', - 'dependencies': [ - 'sandbox', - '../testing/gtest.gyp:gtest', - ], - 'sources': [ - 'tests/main.cc', - 'tests/unit_tests.cc', - 'tests/unit_tests.h', - 'services/broker_process_unittest.cc', + 'includes': [ + 'sandbox_linux_test_sources.gypi', ], - 'include_dirs': [ - '../..', + 'type': 'executable', + }, + { + # This target is the shared library used by Android APK (i.e. + # JNI-friendly) tests. + 'target_name': 'sandbox_linux_jni_unittests', + 'includes': [ + 'sandbox_linux_test_sources.gypi', ], + 'type': 'shared_library', 'conditions': [ - [ 'compile_suid_client==1', { - 'sources': [ - 'suid/client/setuid_sandbox_client_unittest.cc', - ], - }], - [ 'compile_seccomp_bpf==1', { - 'sources': [ - 'seccomp-bpf/bpf_tests.h', - 'seccomp-bpf/codegen_unittest.cc', - 'seccomp-bpf/errorcode_unittest.cc', - 'seccomp-bpf/sandbox_bpf_unittest.cc', - 'seccomp-bpf/syscall_iterator_unittest.cc', - 'seccomp-bpf/syscall_unittest.cc', - ], - }], - ['OS == "android" and gtest_target_type == "shared_library"', { + [ 'OS == "android" and gtest_target_type == "shared_library"', { 'dependencies': [ '../testing/android/native_test.gyp:native_test_native_code', - ] + ], }], ], }, @@ -216,24 +201,24 @@ '..', ], }, - ], 'conditions': [ # Strategy copied from base_unittests_apk in base/base.gyp. [ 'OS=="android" and gtest_target_type == "shared_library"', { 'targets': [ { - 'target_name': 'sandbox_linux_unittests_apk', + 'target_name': 'sandbox_linux_jni_unittests_apk', 'type': 'none', - 'dependencies': [ - 'sandbox_linux_unittests', - ], 'variables': { - 'test_suite_name': 'sandbox_linux_unittests', + 'test_suite_name': 'sandbox_linux_jni_unittests', 'input_shlib_path': - '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)sandbox_linux_unittests' + '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)' + 'sandbox_linux_jni_unittests' '<(SHARED_LIB_SUFFIX)', }, + 'dependencies': [ + 'sandbox_linux_jni_unittests', + ], 'includes': [ '../../build/apk_test.gypi' ], } ], diff --git a/sandbox/linux/sandbox_linux_test_sources.gypi b/sandbox/linux/sandbox_linux_test_sources.gypi new file mode 100644 index 0000000..0bc0aa1 --- /dev/null +++ b/sandbox/linux/sandbox_linux_test_sources.gypi @@ -0,0 +1,38 @@ +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Tests need to be compiled in the same link unit, so we have to list them +# in a separate .gypi file. +{ + 'dependencies': [ + 'sandbox', + '../testing/gtest.gyp:gtest', + ], + 'include_dirs': [ + '../..', + ], + 'sources': [ + 'tests/main.cc', + 'tests/unit_tests.cc', + 'tests/unit_tests.h', + 'services/broker_process_unittest.cc', + ], + 'conditions': [ + [ 'compile_suid_client==1', { + 'sources': [ + 'suid/client/setuid_sandbox_client_unittest.cc', + ], + }], + [ 'compile_seccomp_bpf==1', { + 'sources': [ + 'seccomp-bpf/bpf_tests.h', + 'seccomp-bpf/codegen_unittest.cc', + 'seccomp-bpf/errorcode_unittest.cc', + 'seccomp-bpf/sandbox_bpf_unittest.cc', + 'seccomp-bpf/syscall_iterator_unittest.cc', + 'seccomp-bpf/syscall_unittest.cc', + ], + }], + ], +} diff --git a/sandbox/linux/services/broker_process_unittest.cc b/sandbox/linux/services/broker_process_unittest.cc index 84ba340..4f2a640 100644 --- a/sandbox/linux/services/broker_process_unittest.cc +++ b/sandbox/linux/services/broker_process_unittest.cc @@ -22,6 +22,12 @@ namespace sandbox { +#if defined(OS_ANDROID) + #define DISABLE_ON_ANDROID(function) DISABLED_##function +#else + #define DISABLE_ON_ANDROID(function) function +#endif + TEST(BrokerProcess, CreateAndDestroy) { std::vector<std::string> read_whitelist; read_whitelist.push_back("/proc/cpuinfo"); @@ -188,7 +194,8 @@ TEST(BrokerProcess, OpenCpuinfoNoClientCheck) { // expected. } -TEST(BrokerProcess, OpenFileRW) { +// Disabled until we implement a mkstemp that doesn't require JNI. +TEST(BrokerProcess, DISABLE_ON_ANDROID(OpenFileRW)) { const char basename[] = "BrokerProcessXXXXXX"; char template_name[2048]; #if defined(OS_ANDROID) |