mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-06 04:28:32 +00:00
Remove header_files_test.cc
This commit is contained in:
parent
c35b605b8d
commit
fb2a44f642
2 changed files with 1 additions and 88 deletions
|
|
@ -63,11 +63,6 @@ function(AddTest)
|
|||
)
|
||||
endfunction(AddTest)
|
||||
|
||||
#Check whether C++17 header file <filesystem> is present
|
||||
include(CheckIncludeFiles)
|
||||
check_include_files("filesystem" HAS_FILESYSTEM_H LANGUAGE CXX)
|
||||
check_include_files("experimental/filesystem" HAS_EXPERIMENTAL_FILESYSTEM_H LANGUAGE CXX)
|
||||
|
||||
#Do not add '${TEST_SRC_DIR}/util/include' to your include directories directly
|
||||
#Use onnxruntime_add_include_to_target or target_link_libraries, so that compile definitions
|
||||
#can propagate correctly.
|
||||
|
|
@ -162,8 +157,6 @@ set(onnxruntime_test_framework_libs
|
|||
|
||||
if(WIN32)
|
||||
list(APPEND onnxruntime_test_framework_libs Advapi32)
|
||||
elseif(HAS_FILESYSTEM_H OR HAS_EXPERIMENTAL_FILESYSTEM_H)
|
||||
list(APPEND onnxruntime_test_framework_libs stdc++fs)
|
||||
endif()
|
||||
|
||||
|
||||
|
|
@ -216,10 +209,6 @@ if(onnxruntime_USE_TENSORRT)
|
|||
list(APPEND onnxruntime_test_providers_libs onnxruntime_providers_tensorrt)
|
||||
endif()
|
||||
|
||||
if( NOT WIN32 AND (HAS_FILESYSTEM_H OR HAS_EXPERIMENTAL_FILESYSTEM_H))
|
||||
list(APPEND onnxruntime_test_providers_libs stdc++fs)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if (onnxruntime_USE_TVM)
|
||||
list(APPEND disabled_warnings ${DISABLED_WARNINGS_FOR_TVM})
|
||||
|
|
@ -427,7 +416,7 @@ install(TARGETS onnx_test_runner
|
|||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
if(onnxruntime_BUILD_BENCHMARKS AND (HAS_FILESYSTEM_H OR HAS_EXPERIMENTAL_FILESYSTEM_H))
|
||||
if(onnxruntime_BUILD_BENCHMARKS)
|
||||
add_executable(onnxruntime_benchmark ${TEST_SRC_DIR}/onnx/microbenchmark/main.cc ${TEST_SRC_DIR}/onnx/microbenchmark/modeltest.cc ${TEST_SRC_DIR}/onnx/microbenchmark/model_init.cc)
|
||||
target_include_directories(onnxruntime_benchmark PRIVATE ${ONNXRUNTIME_ROOT} ${onnxruntime_graph_header} benchmark)
|
||||
onnxruntime_add_include_to_target(onnxruntime_benchmark gsl)
|
||||
|
|
|
|||
|
|
@ -1,76 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#if defined(__MACH__)
|
||||
#else
|
||||
|
||||
#include <experimental/filesystem>
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using namespace std::experimental::filesystem::v1;
|
||||
|
||||
namespace onnxruntime {
|
||||
namespace test {
|
||||
|
||||
std::set<path> RetrieveAllHeaders(const path& include_folder_root) {
|
||||
std::set<path> headers;
|
||||
std::vector<path> paths{include_folder_root};
|
||||
while (!paths.empty()) {
|
||||
path node_data_root_path = paths.back();
|
||||
paths.pop_back();
|
||||
for (directory_iterator file_entry(node_data_root_path), end; file_entry != end; ++file_entry) {
|
||||
if (is_directory(*file_entry)) {
|
||||
paths.push_back(file_entry->path());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!file_entry->path().has_extension()) continue;
|
||||
if (file_entry->path().extension() != ".h") continue;
|
||||
headers.insert(file_entry->path());
|
||||
}
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
std::vector<path> RetrieveHeaderDependencies(const path& header, const path& include_folder_root) {
|
||||
std::vector<path> header_dependencies;
|
||||
std::ifstream header_stream(header);
|
||||
const std::size_t pos_off = 10; // length of "#include \""
|
||||
if (!header_stream.good()) return header_dependencies;
|
||||
std::string line;
|
||||
while (std::getline(header_stream, line)) {
|
||||
line.erase(line.find_last_not_of(" \r\n\t") + 1);
|
||||
std::size_t pos = line.find("#include \"core/");
|
||||
if (pos != std::string::npos) {
|
||||
header_dependencies.push_back(include_folder_root / line.substr(pos + pos_off, line.length() - pos - pos_off - 1));
|
||||
} else {
|
||||
pos = line.find("#include <core/");
|
||||
if (pos != std::string::npos) {
|
||||
header_dependencies.push_back(include_folder_root / line.substr(pos + pos_off, line.length() - pos - pos_off - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
return header_dependencies;
|
||||
}
|
||||
|
||||
TEST(HeaderFiles, EnsureAllPublicHeadersInIncludeFolder) {
|
||||
path include_folder_path(path(__FILE__).parent_path().parent_path().parent_path().parent_path() / "include" / "onnxruntime");
|
||||
std::set<path> headers(RetrieveAllHeaders(include_folder_path));
|
||||
|
||||
for (auto header_iterator = headers.begin(); header_iterator != headers.end(); header_iterator++) {
|
||||
std::vector<path> header_dependencies(RetrieveHeaderDependencies(*header_iterator, include_folder_path));
|
||||
for (auto dependency_iterator = header_dependencies.begin(); dependency_iterator != header_dependencies.end(); dependency_iterator++) {
|
||||
EXPECT_TRUE(headers.find(*dependency_iterator) != headers.end()) << *header_iterator << " depends on " << *dependency_iterator << " that is not in include folder";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace onnxruntime
|
||||
|
||||
#endif
|
||||
Loading…
Reference in a new issue