aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Ulf Adams <ulfjack@google.com>2016-09-12 15:57:06 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-09-12 17:09:41 +0000
commit111006ea81de3cabf1ad30a3fcd83035f8f888a3 (patch)
tree144566b6cb41fbe0a2e651fbe49686fe5f0d5487 /src/test
parent4b0832808ab1260ba75c08342ec359cfdc2c313a (diff)
Automatically detect the setting for --cpu.
In some cases, Bazel has already been doing this. In other cases, Bazel tried to infer the default cpu from the CROSSTOOL, but it did not do so consistently across different configuration fragments. I.e., Bazel ended up with an inconsistent set of toolchains for e.g., Python, C++, and Java. After this change, Bazel ignores any default_cpu setting in the CROSSTOOL. Note that the Jvm is still inconsistent with all others, as it uses "default" as the cpu value and ignores both command-line-specified and CROSSTOOL-specified values. -- MOS_MIGRATED_REVID=132879102
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/config/ConfigSettingTest.java6
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java27
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/CcCompileOnlyTest.java1
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java41
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSuiteTest.java103
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java11
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/LibraryLinkingTest.java1
7 files changed, 45 insertions, 145 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/config/ConfigSettingTest.java b/src/test/java/com/google/devtools/build/lib/analysis/config/ConfigSettingTest.java
index 9e93477c19..12b837ac02 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/config/ConfigSettingTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/config/ConfigSettingTest.java
@@ -31,13 +31,11 @@ import com.google.devtools.build.lib.rules.python.PythonConfiguration;
import com.google.devtools.build.lib.testutil.TestConstants;
import com.google.devtools.common.options.OptionsBase;
import com.google.devtools.common.options.OptionsParser;
-
+import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-import java.util.Map;
-
/**
* Tests for {@link ConfigSetting}.
*/
@@ -176,8 +174,6 @@ public class ConfigSettingTest extends BuildViewTestCase {
" })");
assertTrue(getConfigMatchingProvider("//test:match").matches());
- assertNull(flagDefault("cpu"));
- assertNotNull(crosstoolCpuDefault);
assertNull(flagDefault("compiler"));
assertNotNull(crosstoolCompilerDefault);
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
index 7a703950a0..1fab14fa9b 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
@@ -170,6 +170,7 @@ public class CcCommonTest extends BuildViewTestCase {
*/
@Test
public void testArchiveInCcLibrarySrcs() throws Exception {
+ useConfiguration("--cpu=k8");
ConfiguredTarget archiveInSrcsTest =
scratchConfiguredTarget(
"archive_in_srcs",
@@ -179,9 +180,9 @@ public class CcCommonTest extends BuildViewTestCase {
" deps = [':archive_in_srcs_lib'])",
"cc_library(name = 'archive_in_srcs_lib',",
" srcs = ['libstatic.a', 'libboth.a', 'libboth.so'])");
- Iterable<Artifact> libraries = getLinkerInputs(archiveInSrcsTest);
- assertThat(baseArtifactNames(libraries))
- .containsAllOf("archive_in_srcs_test.pic.o", "libboth.so", "libstatic.a");
+ List<String> artifactNames = baseArtifactNames(getLinkerInputs(archiveInSrcsTest));
+ assertThat(artifactNames).containsAllOf("libboth.so", "libstatic.a");
+ assertThat(artifactNames).doesNotContain("libboth.a");
}
private Iterable<Artifact> getLinkerInputs(ConfiguredTarget target) {
@@ -363,13 +364,10 @@ public class CcCommonTest extends BuildViewTestCase {
@Test
public void testPicModeAssembly() throws Exception {
- CrosstoolConfigurationHelper.overwriteCrosstoolWithToolchain(
- directories.getWorkspace(),
- CrosstoolConfig.CToolchain.newBuilder().setNeedsPic(true).buildPartial());
-
+ useConfiguration("--cpu=k8");
scratch.file("a/BUILD", "cc_library(name='preprocess', srcs=['preprocess.S'])");
-
- assertThat(getCppCompileAction("//a:preprocess").getArgv()).contains("-fPIC");
+ List<String> argv = getCppCompileAction("//a:preprocess").getArgv();
+ assertThat(argv).contains("-fPIC");
}
private CppCompileAction getCppCompileAction(String label) throws Exception {
@@ -588,10 +586,8 @@ public class CcCommonTest extends BuildViewTestCase {
" deps = [ ':sophosengine' ],",
" linkstatic=1)");
- Iterable<Artifact> libraries = getLinkerInputs(wrapsophos);
-
- assertThat(baseArtifactNames(libraries))
- .containsAllOf("wrapsophos.pic.o", "libsophosengine.a", "libsavi.so");
+ List<String> artifactNames = baseArtifactNames(getLinkerInputs(wrapsophos));
+ assertThat(artifactNames).contains("libsavi.so");
}
@Test
@@ -775,9 +771,8 @@ public class CcCommonTest extends BuildViewTestCase {
" deps = [':mylib'])",
"cc_library(name = 'mylib',",
" srcs = ['libshared.so', 'libshared.so.1.1', 'foo.cc'])");
- Iterable<Artifact> libraries = getLinkerInputs(target);
- assertThat(baseArtifactNames(libraries))
- .containsAllOf("mybinary.pic.o", "libmylib.a", "libshared.so", "libshared.so.1.1");
+ List<String> artifactNames = baseArtifactNames(getLinkerInputs(target));
+ assertThat(artifactNames).containsAllOf("libshared.so", "libshared.so.1.1");
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCompileOnlyTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCompileOnlyTest.java
index 4c62ac5448..4b1fe98151 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCompileOnlyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCompileOnlyTest.java
@@ -31,6 +31,7 @@ public class CcCompileOnlyTest extends CompileOnlyTestCase {
@Test
public void testCcCompileOnly() throws Exception {
+ useConfiguration("--cpu=k8");
scratch.file("package/BUILD",
"cc_binary(name='foo', srcs=['foo.cc', ':bar'], deps = [':foolib'])",
"cc_library(name='foolib', srcs=['foolib.cc'])",
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
index 65ec00df24..aabf2dc130 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
@@ -101,12 +101,14 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
@Test
public void testFilesToBuild() throws Exception {
ConfiguredTarget hello = getConfiguredTarget("//hello:hello");
+ String cpu = getTargetConfiguration().getCpu();
Artifact archive = getBinArtifact("libhello.a", hello);
Artifact implSharedObject = getBinArtifact("libhello.so", hello);
Artifact implInterfaceSharedObject = getBinArtifact("libhello.ifso", hello);
- Artifact implSharedObjectLink = getSharedArtifact("_solib_k8/libhello_Slibhello.so", hello);
+ Artifact implSharedObjectLink =
+ getSharedArtifact("_solib_" + cpu + "/libhello_Slibhello.so", hello);
Artifact implInterfaceSharedObjectLink =
- getSharedArtifact("_solib_k8/libhello_Slibhello.ifso", hello);
+ getSharedArtifact("_solib_" + cpu + "/libhello_Slibhello.ifso", hello);
assertThat(getFilesToBuild(hello)).containsExactly(archive, implSharedObject,
implInterfaceSharedObject);
assertThat(LinkerInputs.toLibraryArtifacts(
@@ -157,11 +159,14 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
public void testFilesToBuildWithInterfaceSharedObjects() throws Exception {
useConfiguration("--interface_shared_objects");
ConfiguredTarget hello = getConfiguredTarget("//hello:hello");
+ String cpu = getTargetConfiguration().getCpu();
Artifact archive = getBinArtifact("libhello.a", hello);
Artifact sharedObject = getBinArtifact("libhello.ifso", hello);
Artifact implSharedObject = getBinArtifact("libhello.so", hello);
- Artifact sharedObjectLink = getSharedArtifact("_solib_k8/libhello_Slibhello.ifso", hello);
- Artifact implSharedObjectLink = getSharedArtifact("_solib_k8/libhello_Slibhello.so", hello);
+ Artifact sharedObjectLink =
+ getSharedArtifact("_solib_" + cpu + "/libhello_Slibhello.ifso", hello);
+ Artifact implSharedObjectLink =
+ getSharedArtifact("_solib_" + cpu + "/libhello_Slibhello.so", hello);
assertThat(getFilesToBuild(hello)).containsExactly(archive, sharedObject, implSharedObject);
assertThat(LinkerInputs.toLibraryArtifacts(
hello.getProvider(CcNativeLibraryProvider.class).getTransitiveCcNativeLibraries()))
@@ -367,6 +372,7 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
@Test
public void testArtifactsToAlwaysBuild() throws Exception {
+ useConfiguration("--cpu=k8");
// ArtifactsToAlwaysBuild should apply both for static libraries.
ConfiguredTarget helloStatic = getConfiguredTarget("//hello:hello_static");
assertEquals(ImmutableSet.of("bin hello/_objs/hello_static/hello/hello.pic.o"),
@@ -384,6 +390,7 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
@Test
public void testTransitiveArtifactsToAlwaysBuildStatic() throws Exception {
+ useConfiguration("--cpu=k8");
ConfiguredTarget x = scratchConfiguredTarget(
"foo", "x",
"cc_library(name = 'x', srcs = ['x.cc'], deps = [':y'], linkstatic = 1)",
@@ -402,7 +409,7 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
AnalysisMock.get()
.ccSupport()
.setupCrosstool(mockToolsConfig, MockCcSupport.HEADER_MODULES_FEATURE_CONFIGURATION);
- useConfiguration();
+ useConfiguration("--cpu=k8");
ConfiguredTarget x =
scratchConfiguredTarget(
"foo",
@@ -421,7 +428,7 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
AnalysisMock.get()
.ccSupport()
.setupCrosstool(mockToolsConfig, MockCcSupport.HEADER_MODULES_FEATURE_CONFIGURATION);
- useConfiguration("--collect_code_coverage");
+ useConfiguration("--cpu=k8", "--collect_code_coverage");
ConfiguredTarget x =
scratchConfiguredTarget(
"foo",
@@ -509,7 +516,7 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
+ "feature { name: 'header_modules' implies: 'use_header_modules' }"
+ "feature { name: 'module_maps' }"
+ "feature { name: 'use_header_modules' }");
- useConfiguration();
+ useConfiguration("--cpu=k8");
scratch.file("module/BUILD",
"package(features = ['header_modules'])",
"cc_library(",
@@ -614,7 +621,7 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
AnalysisMock.get()
.ccSupport()
.setupCrosstool(mockToolsConfig, MockCcSupport.HEADER_MODULES_FEATURE_CONFIGURATION);
- useConfiguration();
+ useConfiguration("--cpu=k8");
setupPackagesForModuleTests(/*useHeaderModules=*/false);
// The //nomodule:f target only depends on non-module targets, thus it should be module-free.
@@ -691,7 +698,7 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
mockToolsConfig,
MockCcSupport.HEADER_MODULES_FEATURE_CONFIGURATION
+ "feature { name: 'transitive_module_maps' }");
- useConfiguration("--features=transitive_module_maps");
+ useConfiguration("--cpu=k8", "--features=transitive_module_maps");
setupPackagesForModuleTests(/*useHeaderModules=*/true);
getConfiguredTarget("//nomodule:f");
@@ -740,7 +747,7 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
AnalysisMock.get()
.ccSupport()
.setupCrosstool(mockToolsConfig, MockCcSupport.HEADER_MODULES_FEATURE_CONFIGURATION);
- useConfiguration();
+ useConfiguration("--cpu=k8");
setupPackagesForModuleTests( /*useHeaderModules=*/true);
getConfiguredTarget("//nomodule:f");
@@ -781,7 +788,7 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
mockToolsConfig,
MockCcSupport.HEADER_MODULES_FEATURE_CONFIGURATION
+ "feature { name: 'header_module_includes_dependencies' }");
- useConfiguration();
+ useConfiguration("--cpu=k8");
setupPackagesForModuleTests(/*useHeaderModules=*/false);
getConfiguredTarget("//module:j");
Artifact jObjectArtifact = getBinArtifact("_objs/j/module/j.pic.o", "//module:j");
@@ -804,7 +811,7 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
.ccSupport()
.setupCrosstool(mockToolsConfig,
"feature { name: 'no_legacy_features' }");
- useConfiguration();
+ useConfiguration("--cpu=k8");
writeSimpleCcLibrary();
reporter.removeHandler(failFastHandler);
getConfiguredTarget("//module:map");
@@ -1041,19 +1048,19 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
@Test
public void testCompilationModeFeatures() throws Exception {
List<String> flags;
- flags = getCompilationModeFlags();
+ flags = getCompilationModeFlags("--cpu=k8");
assertThat(flags).contains("-fastbuild");
assertThat(flags).containsNoneOf("-opt", "-dbg");
- flags = getCompilationModeFlags("-c", "fastbuild");
+ flags = getCompilationModeFlags("--cpu=k8", "--compilation_mode=fastbuild");
assertThat(flags).contains("-fastbuild");
assertThat(flags).containsNoneOf("-opt", "-dbg");
- flags = getCompilationModeFlags("-c", "opt");
+ flags = getCompilationModeFlags("--cpu=k8", "--compilation_mode=opt");
assertThat(flags).contains("-opt");
assertThat(flags).containsNoneOf("-fastbuild", "-dbg");
- flags = getCompilationModeFlags("-c", "dbg");
+ flags = getCompilationModeFlags("--cpu=k8", "--compilation_mode=dbg");
assertThat(flags).contains("-dbg");
assertThat(flags).containsNoneOf("-fastbuild", "-opt");
}
@@ -1063,7 +1070,7 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
.ccSupport()
.setupCrosstool(mockToolsConfig, MockCcSupport.HOST_AND_NONHOST_CONFIGURATION);
scratch.overwriteFile("mode/BUILD", "cc_library(name = 'a', srcs = ['a.cc'])");
- useConfiguration();
+ useConfiguration("--cpu=k8");
ConfiguredTarget target;
String objectPath;
if (useHost) {
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSuiteTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSuiteTest.java
index 2ee22fb2b6..21fb62c166 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSuiteTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSuiteTest.java
@@ -21,7 +21,6 @@ import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -175,7 +174,7 @@ public class CcToolchainSuiteTest extends BuildViewTestCase {
scratch.file("a/BUILD",
"genrule(name='a', srcs=[], outs=['ao'], tools=['//tools/defaults:crosstool'], cmd='x')");
invalidatePackages();
- useConfiguration("--crosstool_top=//cc:suite");
+ useConfiguration("--crosstool_top=//cc:suite", "--cpu=k8");
Action action = getGeneratingAction(getConfiguredTarget("//a:a"), "a/ao");
assertThat(ActionsTestUtil.baseArtifactNames(action.getInputs()))
.containsAllOf("k8-marker", "darwin-marker", "windows-marker");
@@ -184,104 +183,4 @@ public class CcToolchainSuiteTest extends BuildViewTestCase {
assertThat(ActionsTestUtil.baseArtifactNames(suiteFiles))
.containsAllOf("k8-marker", "darwin-marker", "windows-marker");
}
-
- @Test
- public void testSmoke() throws Exception {
- scratch.file(
- "cc/BUILD",
- "cc_toolchain_suite(",
- " name = 'suite',",
- " toolchains = { ",
- " 'cpu|cpu-compiler': ':cc-toolchain',",
- " 'k8|k8-compiler': ':cc-toolchain',",
- " 'darwin|cpu-compiler': ':cc-toolchain',",
- " 'x64_windows|cpu-compiler': ':cc-toolchain',",
- " },",
- " proto = \"\"\"",
- "major_version: 'v1'",
- "minor_version: '0'",
- "default_target_cpu: 'cpu'",
- "default_toolchain {",
- " cpu: 'cpu'",
- " toolchain_identifier: 'cpu-toolchain'",
- "}",
- "default_toolchain {",
- " cpu: 'darwin'",
- " toolchain_identifier: 'cpu-toolchain'",
- "}",
- "default_toolchain {",
- " cpu: 'x64_windows'",
- " toolchain_identifier: 'cpu-toolchain'",
- "}",
- "default_toolchain {",
- " cpu: 'k8'",
- " toolchain_identifier: 'k8-toolchain'",
- "}",
- "toolchain {",
- " compiler: 'cpu-compiler'",
- " target_cpu: 'cpu'",
- " toolchain_identifier: 'cpu-toolchain'",
- " host_system_name: 'linux'",
- " target_system_name: 'linux'",
- " abi_version: 'cpu-abi'",
- " abi_libc_version: ''",
- " target_libc: ''",
- " builtin_sysroot: 'sysroot'",
- " default_grte_top: '//cc:grtetop'",
- " tool_path { name: 'cpu-compiler', path: 'cpu/compiler' }",
- " tool_path { name: 'ar', path: 'cpu/ar' }",
- " tool_path { name: 'cpp', path: 'cpu/cpp' }",
- " tool_path { name: 'gcc', path: 'cpu/gcc' }",
- " tool_path { name: 'gcov', path: 'cpu/gcov' }",
- " tool_path { name: 'ld', path: 'cpu/ld' }",
- " tool_path { name: 'nm', path: 'cpu/nm' }",
- " tool_path { name: 'objcopy', path: 'cpu/objcopy' }",
- " tool_path { name: 'objdump', path: 'cpu/objdump' }",
- " tool_path { name: 'strip', path: 'cpu/strip' }",
- "}",
- "toolchain {",
- " compiler: 'k8-compiler'",
- " target_cpu: 'k8'",
- " toolchain_identifier: 'k8-toolchain'",
- " host_system_name: 'linux'",
- " target_system_name: 'linux'",
- " abi_version: ''",
- " abi_libc_version: ''",
- " target_libc: ''",
- " builtin_sysroot: 'sysroot'",
- " default_grte_top: '//cc:grtetop'",
- " tool_path { name: 'k8-compiler', path: 'k8/compiler' }",
- " tool_path { name: 'ar', path: 'k8/ar' }",
- " tool_path { name: 'cpp', path: 'k8/cpp' }",
- " tool_path { name: 'gcc', path: 'k8/gcc' }",
- " tool_path { name: 'gcov', path: 'k8/gcov' }",
- " tool_path { name: 'ld', path: 'k8/ld' }",
- " tool_path { name: 'nm', path: 'k8/nm' }",
- " tool_path { name: 'objcopy', path: 'k8/objcopy' }",
- " tool_path { name: 'objdump', path: 'k8/objdump' }",
- " tool_path { name: 'strip', path: 'k8/strip' }",
- "}",
- "\"\"\")",
- "cc_toolchain(",
- " name = 'cc-toolchain',",
- " module_map = 'map',",
- " cpu = 'cpu',",
- " compiler_files = 'compile',",
- " dwp_files = 'dwp',",
- " linker_files = 'link',",
- " strip_files = ':strip',",
- " objcopy_files = 'objcopy',",
- " all_files = ':every-file',",
- " dynamic_runtime_libs = ['dynamic-runtime-libs'],",
- " static_runtime_libs = ['static-runtime-libs'])",
- "",
- "filegroup(name = 'every-file', srcs = ['//cc:everything'])");
-
- invalidatePackages();
- useConfiguration("--crosstool_top=//cc:suite");
- CppConfiguration cppConfig = getTargetConfiguration().getFragment(CppConfiguration.class);
- assertThat(cppConfig.getTargetCpu()).isEqualTo("cpu");
- assertThat(cppConfig.getAbi()).isEqualTo("cpu-abi");
- assertThat(cppConfig.getCompiler()).isEqualTo("cpu-compiler");
- }
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java
index 7eb0abb087..0787b90034 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java
@@ -795,10 +795,11 @@ public class CrosstoolConfigurationLoaderTest extends AnalysisTestCase {
// Uses the default toolchain for k8.
assertEquals("toolchain-identifier-BB", create(loader, "--cpu=k8").getToolchainIdentifier());
- // Defaults to --cpu=k8.
+ // Does not default to --cpu=k8; if no --cpu flag is present, Bazel defaults to the host cpu!
assertEquals(
"toolchain-identifier-BA",
- create(loader, "--compiler=compiler-A", "--glibc=target-libc-B").getToolchainIdentifier());
+ create(loader, "--cpu=k8", "--compiler=compiler-A", "--glibc=target-libc-B")
+ .getToolchainIdentifier());
// Uses the default toolchain for piii.
assertEquals(
"toolchain-identifier-AA-piii", create(loader, "--cpu=piii").getToolchainIdentifier());
@@ -814,10 +815,10 @@ public class CrosstoolConfigurationLoaderTest extends AnalysisTestCase {
// compiler-C uniquely identifies a toolchain, so we can use it.
assertEquals(
"toolchain-identifier-BC",
- create(loader, "--compiler=compiler-C").getToolchainIdentifier());
+ create(loader, "--cpu=k8", "--compiler=compiler-C").getToolchainIdentifier());
try {
- create(loader, "--compiler=nonexistent-compiler");
+ create(loader, "--cpu=k8", "--compiler=nonexistent-compiler");
fail("Expected an error that no toolchain matched.");
} catch (InvalidConfigurationException e) {
assertThat(e)
@@ -834,7 +835,7 @@ public class CrosstoolConfigurationLoaderTest extends AnalysisTestCase {
}
try {
- create(loader, "--glibc=target-libc-A");
+ create(loader, "--cpu=k8", "--glibc=target-libc-A");
fail("Expected an error that multiple toolchains matched.");
} catch (InvalidConfigurationException e) {
assertThat(e)
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/LibraryLinkingTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/LibraryLinkingTest.java
index c7f862ab9c..3adb69ec75 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/LibraryLinkingTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/LibraryLinkingTest.java
@@ -48,6 +48,7 @@ public final class LibraryLinkingTest extends BuildViewTestCase {
@Test
public void testGeneratedLib() throws Exception {
+ useConfiguration("--cpu=k8");
ConfiguredTarget genlib =
scratchConfiguredTarget(
"genrule",