From 10118ab46e2f3a8e32384bbf4bb30091e9b629d4 Mon Sep 17 00:00:00 2001 From: Googler Date: Tue, 13 Feb 2018 07:33:14 -0800 Subject: Route --fdo_optimize information through an implicit dependency instead of CppConfiguration RELNOTES: None. PiperOrigin-RevId: 185527875 --- .../build/lib/rules/cpp/CcToolchainTest.java | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) (limited to 'src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java') diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java index 86414b8cfe..f6c0577ac8 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java @@ -699,4 +699,92 @@ public class CcToolchainTest extends BuildViewTestCase { "cc_toolchain_alias(name='ref')"); assertThat(reference.get(ToolchainInfo.PROVIDER.getKey())).isNotNull(); } + + @Test + public void testFdoOptimizeInvalidUseGeneratedArtifact() throws Exception { + reporter.removeHandler(failFastHandler); + scratch.file( + "a/BUILD", + "filegroup(", + " name='empty')", + "filegroup(", + " name = 'banana',", + " srcs = ['banana1', 'banana2'])", + "cc_toolchain(", + " name = 'b',", + " cpu = 'banana',", + " all_files = ':banana',", + " compiler_files = ':empty',", + " dwp_files = ':empty',", + " linker_files = ':empty',", + " strip_files = ':empty',", + " objcopy_files = ':empty',", + " dynamic_runtime_libs = [':empty'],", + " static_runtime_libs = [':empty'])", + "genrule(", + " name ='gen_artifact',", + " outs=['profile.profdata'],", + " cmd='touch $@')"); + useConfiguration("-c", "opt", "--fdo_optimize=//a:gen_artifact"); + assertThat(getConfiguredTarget("//a:b")).isNull(); + assertContainsEvent("--fdo_optimize points to a target that is not an input file"); + } + + @Test + public void testFdoOptimizeUnexpectedExtension() throws Exception { + reporter.removeHandler(failFastHandler); + scratch.file( + "a/BUILD", + "filegroup(", + " name='empty')", + "filegroup(", + " name = 'banana',", + " srcs = ['banana1', 'banana2'])", + "cc_toolchain(", + " name = 'b',", + " cpu = 'banana',", + " all_files = ':banana',", + " compiler_files = ':empty',", + " dwp_files = ':empty',", + " linker_files = ':empty',", + " strip_files = ':empty',", + " objcopy_files = ':empty',", + " dynamic_runtime_libs = [':empty'],", + " static_runtime_libs = [':empty'])", + "exports_files(['profile.unexpected'])"); + scratch.file("a/profile.unexpected", ""); + useConfiguration("-c", "opt", "--fdo_optimize=//a:profile.unexpected"); + assertThat(getConfiguredTarget("//a:b")).isNull(); + assertContainsEvent("invalid extension for FDO profile file"); + } + + @Test + public void testFdoOptimizeNotInputFile() throws Exception { + reporter.removeHandler(failFastHandler); + scratch.file( + "a/BUILD", + "filegroup(", + " name='empty')", + "filegroup(", + " name = 'banana',", + " srcs = ['banana1', 'banana2'])", + "cc_toolchain(", + " name = 'b',", + " cpu = 'banana',", + " all_files = ':banana',", + " compiler_files = ':empty',", + " dwp_files = ':empty',", + " linker_files = ':empty',", + " strip_files = ':empty',", + " objcopy_files = ':empty',", + " dynamic_runtime_libs = [':empty'],", + " static_runtime_libs = [':empty'])", + "filegroup(", + " name ='profile',", + " srcs=['my_profile.afdo'])"); + scratch.file("my_profile.afdo", ""); + useConfiguration("-c", "opt", "--fdo_optimize=//a:profile"); + assertThat(getConfiguredTarget("//a:b")).isNull(); + assertContainsEvent("--fdo_optimize points to a target that is not an input file"); + } } -- cgit v1.2.3