Commit 209256f5 authored by James Cook's avatar James Cook Committed by Commit Bot

Don't allow chromeos unit tests to build in "cros chrome-sdk" shell

The chromeos_* unit test suites are designed to run on Linux, not on
real hardware or in VMs. On the Chromium waterfall they are built
with the linux-chromeos configuration.

Developers using the "cros chrome-sdk" sometimes think they need to
build these targets and run them, either on their host workstation
or on device. The tests aren't expected to work in these environments,
so prevent them from being built.

Bug: 909073, 865693
Test: ninja -C out_eve/Release chromeos_unittests won't compile
Change-Id: Idf8c366f7001ea5bbc744ccba6e627d70f5efebb
Reviewed-on: https://chromium-review.googlesource.com/c/1358509
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarBen Pastene <bpastene@chromium.org>
Cr-Commit-Position: refs/heads/master@{#614763}
parent 1c086040
......@@ -12,7 +12,14 @@ declare_args() {
# Ensure that if one is set, the other is as well.
assert(cros_board == "" == (cros_sdk_version == ""))
is_chromeos_chrome = cros_board != ""
# The build is using the Simple Chrome "cros chrome-sdk" to target real hardware
# or a VM, not linux-chromeos.
# NOTE: Most test targets in Chrome expect to run under linux-chromeos, so some
# have compile-time asserts that intentionally fail when this build flag is set.
# Build and run the tests for linux-chromeos instead.
# https://chromium.googlesource.com/chromium/src/+/master/docs/chromeos_build_instructions.md
# https://chromium.googlesource.com/chromiumos/docs/+/master/simple_chrome_workflow.md
is_cros_chrome_sdk = cros_board != ""
# Creates a script at $generated_script that can be used to launch a cros VM
# and optionally run a test within it.
......
......@@ -13,7 +13,7 @@ import("//build_overrides/build.gni")
if (is_chromeos) {
import("//build/config/chromeos/rules.gni")
} else {
is_chromeos_chrome = false
is_cros_chrome_sdk = false
}
if (is_android) {
......@@ -206,7 +206,7 @@ if (symbol_level == -1) {
# If you use is_win_fastlink = true or lld or clang then you can set
# symbol_level = 2 when using goma.
symbol_level = 1
} else if (is_chromeos_chrome) {
} else if (is_cros_chrome_sdk) {
# Use lower symbol level in Simple Chrome build for faster link time.
# For Simple Chrome, this should take precedence over is_official_build,
# turned on by --internal.
......
......@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/buildflag_header.gni")
import("//build/config/chromeos/rules.gni")
import("//build/config/ui.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
......@@ -15,6 +16,11 @@ config("chromeos_implementation") {
defines = [ "CHROMEOS_IMPLEMENTATION" ]
}
buildflag_header("chromeos_buildflags") {
header = "chromeos_buildflags.h"
flags = [ "IS_CROS_CHROME_SDK=$is_cros_chrome_sdk" ]
}
component("chromeos") {
configs += [
":chromeos_implementation",
......@@ -315,6 +321,7 @@ test("chromeos_unittests") {
":attestation_proto",
":authpolicy_proto",
":biod_proto",
":chromeos_buildflags",
":cryptohome_proto",
":oobe_config_proto",
":power_manager_proto",
......@@ -386,7 +393,7 @@ test("chromeos_unittests") {
# linux-chromeos). See the following for reference:
# https://chromium.googlesource.com/chromium/src/+/master/docs/chromeos_build_instructions.md
# https://chromium.googlesource.com/chromiumos/docs/+/master/simple_chrome_workflow.md
if (is_chromeos_chrome) {
if (is_cros_chrome_sdk) {
generate_vm_runner_script("cros_vm_launcher") {
generated_script = "$root_build_dir/bin/launch_cros_vm"
......
......@@ -16,6 +16,7 @@ test("chromeos_components_unittests") {
deps = [
"//base",
"//base/test:test_support",
"//chromeos:chromeos_buildflags",
"//chromeos/components/drivefs:unit_tests",
"//chromeos/components/multidevice:unit_tests",
"//chromeos/components/nearby:unit_tests",
......
......@@ -5,8 +5,14 @@
#include "base/bind.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
#include "chromeos/chromeos_buildflags.h"
#include "mojo/core/embedder/embedder.h"
#if BUILDFLAG(IS_CROS_CHROME_SDK)
#error This test target only builds with linux-chromeos, not cros chrome-sdk.\
See comment in build/config/chromeos/rules.gni.
#endif
int main(int argc, char** argv) {
// Some unit tests make Mojo calls.
mojo::core::Init();
......
......@@ -5,8 +5,14 @@
#include "base/bind.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
#include "chromeos/chromeos_buildflags.h"
#include "mojo/core/embedder/embedder.h"
#if BUILDFLAG(IS_CROS_CHROME_SDK)
#error This test target only builds with linux-chromeos, not cros chrome-sdk.\
See comment in build/config/chromeos/rules.gni.
#endif
int main(int argc, char** argv) {
// Some unit tests make Mojo calls.
mojo::core::Init();
......
......@@ -91,23 +91,6 @@
},
"test": "chrome_all_tast_tests"
},
{
"args": [
"--dbus-stub",
"--test-launcher-filter-file=../../testing/buildbot/filters/chromeos.chromeos_unittests.filter"
],
"swarming": {
"can_use_on_swarming_builders": true,
"dimension_sets": [
{
"kvm": "1",
"os": "Ubuntu-14.04",
"pool": "Chrome-CrOS-VM"
}
]
},
"test": "chromeos_unittests"
},
{
"swarming": {
"can_use_on_swarming_builders": true,
......
......@@ -3838,25 +3838,6 @@
},
"test": "chrome_login_tast_tests"
},
{
"args": [
"--dbus-stub",
"--test-launcher-filter-file=../../testing/buildbot/filters/chromeos.chromeos_unittests.filter"
],
"swarming": {
"can_use_on_swarming_builders": true,
"dimension_sets": [
{
"kvm": "1",
"os": "Ubuntu-14.04",
"pool": "Chrome-CrOS-VM"
}
],
"hard_timeout": 3600,
"io_timeout": 3600
},
"test": "chromeos_unittests"
},
{
"swarming": {
"can_use_on_swarming_builders": true,
......
......@@ -40,7 +40,6 @@ source_set("browser_tests_filters") {
source_set("chromeos_filters") {
data = [
"//testing/buildbot/filters/chromeos.chromeos_unittests.filter",
"//testing/buildbot/filters/chromeos.media_unittests.filter",
"//testing/buildbot/filters/chromeos.services_unittests.filter",
]
......
# TODO(crbug.com/865693): Fix this.
-NetworkConnectionHandlerImplTest.ConnectWithCertificateSuccess
......@@ -371,7 +371,11 @@
'chromedriver_replay_unittests': {},
},
'chromeos_gtests': {
# Tests that run in Chrome OS VMs.
# NOTE: We only want a small subset of test suites here, because most
# suites assume that they stub out the underlying device hardware.
# https://crbug.com/865693
'chromeos_device_friendly_gtests': {
'aura_unittests': {
'args': [
'--ozone-platform=headless',
......@@ -389,13 +393,6 @@
},
'cc_unittests': {},
'chrome_all_tast_tests': {},
'chromeos_unittests': {
'args': [
# TODO(crbug.com/865693): Don't stub out dbus clients.
'--dbus-stub',
'--test-launcher-filter-file=../../testing/buildbot/filters/chromeos.chromeos_unittests.filter',
],
},
'cros_vm_sanity_test': {},
'crypto_unittests': {},
'display_unittests': {},
......@@ -441,16 +438,9 @@
'url_unittests': {},
},
'chromeos_gtests_experimental': {
'chromeos_device_friendly_gtests_experimental': {
'base_unittests': {},
'chrome_login_tast_tests': {},
'chromeos_unittests': {
'args': [
# TODO(crbug.com/865693): Don't stub out dbus clients.
'--dbus-stub',
'--test-launcher-filter-file=../../testing/buildbot/filters/chromeos.chromeos_unittests.filter',
],
},
'cros_vm_sanity_test': {},
'services_unittests': {
'args': [
......
......@@ -666,7 +666,7 @@
'chromiumos_preflight',
],
'test_suites': {
'gtest_tests': 'chromeos_gtests',
'gtest_tests': 'chromeos_device_friendly_gtests',
'isolated_scripts': 'chromeos_isolated_scripts',
},
'swarming': {
......@@ -1371,7 +1371,7 @@
'chromiumos_preflight',
],
'test_suites': {
'gtest_tests': 'chromeos_gtests_experimental',
'gtest_tests': 'chromeos_device_friendly_gtests_experimental',
},
'swarming': {
'dimension_sets': [
......
......@@ -8,15 +8,15 @@
if (is_android) {
import("//build/config/android/config.gni")
import("//build/config/android/extract_unwind_tables.gni")
import("//build/config/android/rules.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/android/extract_unwind_tables.gni")
}
if (is_fuchsia) {
import("//build/config/chromecast_build.gni")
import("//build/config/fuchsia/rules.gni")
import("//build/config/fuchsia/package.gni")
import("//build/config/fuchsia/rules.gni")
}
if (is_chromeos) {
......@@ -322,7 +322,7 @@ template("test") {
}
bundle_deps += [ ":$_resources_bundle_data" ]
}
} else if (is_chromeos && is_chromeos_chrome) {
} else if (is_chromeos && is_cros_chrome_sdk) {
# Building for a cros board (ie: not linux-chromeos).
_gen_runner_target = "${target_name}__runner"
......
......@@ -69,6 +69,7 @@ test("ui_chromeos_unittests") {
":chromeos",
"//base/test:test_support",
"//chromeos",
"//chromeos:chromeos_buildflags",
"//mojo/core/embedder",
"//skia",
"//testing/gtest",
......
......@@ -10,6 +10,7 @@
#include "base/path_service.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
#include "chromeos/chromeos_buildflags.h"
#include "mojo/core/embedder/embedder.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/env.h"
......@@ -17,6 +18,11 @@
#include "ui/base/ui_base_paths.h"
#include "ui/gl/test/gl_surface_test_support.h"
#if BUILDFLAG(IS_CROS_CHROME_SDK)
#error This test target only builds with linux-chromeos, not cros chrome-sdk.\
See comment in build/config/chromeos/rules.gni.
#endif
namespace {
class UIChromeOSTestSuite : public base::TestSuite {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment