mirror of
https://github.com/bkryza/clang-uml.git
synced 2025-05-17 11:12:20 +08:00
73 lines
3.0 KiB
C++
73 lines
3.0 KiB
C++
/**
|
|
* @file tests/test_query_driver_output_extractor.cc
|
|
*
|
|
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
#define CATCH_CONFIG_MAIN
|
|
|
|
#include "util/query_driver_output_extractor.h"
|
|
|
|
#include "catch.h"
|
|
|
|
TEST_CASE("Test extract system include paths", "[unit-test]")
|
|
{
|
|
|
|
std::string output = R"(###
|
|
Using built-in specs.
|
|
COLLECT_GCC=g++
|
|
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
|
|
OFFLOAD_TARGET_DEFAULT=1
|
|
Target: x86_64-linux-gnu
|
|
Configured with: ../src/configure -v
|
|
Thread model: posix
|
|
Supported LTO compression algorithms: zlib zstd
|
|
gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)
|
|
COLLECT_GCC_OPTIONS='-E' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
|
|
/usr/lib/gcc/x86_64-linux-gnu/11/cc1 -E -quiet -v -imultiarch x86_64-linux-gnu /dev/null -mtune=generic -march=x86-64 -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -dumpbase null
|
|
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
|
|
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/11/include-fixed"
|
|
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include"
|
|
#include "..." search starts here:
|
|
#include <...> search starts here:
|
|
/usr/lib/gcc/x86_64-linux-gnu/11/include
|
|
/usr/local/include
|
|
/usr/include/x86_64-linux-gnu
|
|
/usr/include
|
|
End of search list.
|
|
# 0 "/dev/null"
|
|
# 0 "<built-in>"
|
|
# 0 "<command-line>"
|
|
# 1 "/usr/include/stdc-predef.h" 1 3 4
|
|
# 0 "<command-line>" 2
|
|
# 1 "/dev/null"
|
|
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/
|
|
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../:/lib/:/usr/lib/
|
|
COLLECT_GCC_OPTIONS='-E' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
|
|
###)";
|
|
|
|
clanguml::util::query_driver_output_extractor extractor("g++", "c++");
|
|
|
|
extractor.extract_system_include_paths(output);
|
|
|
|
extractor.extract_target(output);
|
|
|
|
std::vector<std::string> expected = {
|
|
"/usr/lib/gcc/x86_64-linux-gnu/11/include", "/usr/local/include",
|
|
"/usr/include/x86_64-linux-gnu", "/usr/include"};
|
|
|
|
REQUIRE(extractor.system_include_paths() == expected);
|
|
|
|
REQUIRE(extractor.target() == "x86_64-linux-gnu");
|
|
} |