kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/cxx/extractor/testdata/alternate_platform_test.cc (about) 1 /* 2 * Copyright 2019 The Kythe Authors. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "absl/strings/string_view.h" 18 #include "gmock/gmock.h" 19 #include "gtest/gtest.h" 20 #include "kythe/cxx/extractor/testlib.h" 21 #include "kythe/proto/analysis.pb.h" 22 #include "protobuf-matchers/protocol-buffer-matchers.h" 23 24 namespace kythe { 25 namespace { 26 using ::kythe::proto::CompilationUnit; 27 using ::protobuf_matchers::EquivToProto; 28 29 CompilationUnit ExpectedCompilation() { 30 return ParseTextCompilationUnitOrDie(R"pb( 31 v_name { language: "c++" } 32 required_input { 33 v_name { path: "kythe/cxx/extractor/testdata/arm.cc" } 34 info { 35 path: "kythe/cxx/extractor/testdata/arm.cc" 36 digest: "122b0dc24be3e4d4360ceffdbc00bdd2d6c4ea0600befbad7fbeac1946a9c677" 37 } 38 details { 39 [type.googleapis.com/kythe.proto.ContextDependentVersion] { 40 row { source_context: "hash0" always_process: true } 41 } 42 } 43 } 44 argument: "arm-none-linux-gnueabi-g++" 45 argument: "-target" 46 argument: "armv4t-none-linux-gnueabi" 47 argument: "-DKYTHE_IS_RUNNING=1" 48 argument: "-resource-dir" 49 argument: "/kythe_builtins" 50 argument: "--target=arm-none-linux-gnueabi" 51 argument: "--driver-mode=g++" 52 argument: "-Ikythe/cxx/extractor" 53 argument: "./kythe/cxx/extractor/testdata/arm.cc" 54 argument: "-fsyntax-only" 55 source_file: "kythe/cxx/extractor/testdata/arm.cc" 56 working_directory: "/root" 57 entry_context: "hash0")pb"); 58 } 59 60 TEST(CxxExtractorTest, TestAlternatePlatformExtraction) { 61 CompilationUnit unit = ExtractSingleCompilationOrDie( 62 {{"--with_executable", "arm-none-linux-gnueabi-g++", "-mcpu=cortex-a15", 63 "-Ikythe/cxx/extractor", "./kythe/cxx/extractor/testdata/arm.cc"}}); 64 65 // Fix up things which may legitmately vary between runs. 66 // TODO(shahms): use gMock protobuf matchers when available. 67 CanonicalizeHashes(&unit); 68 unit.clear_details(); 69 70 EXPECT_THAT(unit, EquivToProto(ExpectedCompilation())); 71 } 72 73 } // namespace 74 } // namespace kythe