feat(solver-bootstrap): step 2 — dependency-smoke-tests
This commit is contained in:
@@ -1,3 +1,54 @@
|
||||
include_guard(GLOBAL)
|
||||
|
||||
# Third-party package discovery is added by the dependency smoke-test step.
|
||||
if(NOT WIN32 OR NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
message(FATAL_ERROR "FESA dependencies require a Windows x64 build.")
|
||||
endif()
|
||||
|
||||
set(MKL_ARCH intel64)
|
||||
set(MKL_INTERFACE lp64)
|
||||
set(MKL_LINK dynamic)
|
||||
set(MKL_THREADING tbb_thread)
|
||||
|
||||
find_package(MKL CONFIG REQUIRED)
|
||||
find_package(TBB CONFIG REQUIRED COMPONENTS tbb)
|
||||
find_package(HDF5 CONFIG REQUIRED COMPONENTS C shared)
|
||||
find_package(GTest CONFIG REQUIRED)
|
||||
|
||||
function(fesa_require_imported_target target_name)
|
||||
if(NOT TARGET "${target_name}")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Required imported target '${target_name}' is unavailable. "
|
||||
"Verify the installed x64 package and its runtime DLLs."
|
||||
)
|
||||
endif()
|
||||
|
||||
get_target_property(target_is_imported "${target_name}" IMPORTED)
|
||||
if(NOT target_is_imported)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Dependency target '${target_name}' must be provided by an "
|
||||
"installed package."
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
fesa_require_imported_target(MKL::MKL)
|
||||
fesa_require_imported_target(TBB::tbb)
|
||||
fesa_require_imported_target(hdf5::hdf5-shared)
|
||||
fesa_require_imported_target(GTest::gtest_main)
|
||||
fesa_require_imported_target(GTest::gtest)
|
||||
fesa_require_imported_target(GTest::gmock)
|
||||
|
||||
add_library(HDF5::HDF5 INTERFACE IMPORTED GLOBAL)
|
||||
set_property(
|
||||
TARGET HDF5::HDF5
|
||||
PROPERTY INTERFACE_LINK_LIBRARIES hdf5::hdf5-shared
|
||||
)
|
||||
|
||||
set(
|
||||
FESA_DEPENDENCY_RUNTIME_MODIFICATIONS
|
||||
"PATH=path_list_prepend:${MKL_DLL_DIR}"
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:TBB::tbb>"
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:hdf5::hdf5-shared>"
|
||||
)
|
||||
|
||||
@@ -8,3 +8,31 @@ set_tests_properties(
|
||||
PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION "[0-9]+\\.[0-9]+\\.[0-9]+"
|
||||
)
|
||||
|
||||
add_executable(fesa_dependency_smoke_test
|
||||
unit/dependencies/dependency_smoke_test.cpp
|
||||
)
|
||||
|
||||
target_compile_features(fesa_dependency_smoke_test PRIVATE cxx_std_20)
|
||||
target_compile_options(fesa_dependency_smoke_test PRIVATE /W4 /permissive- /EHsc)
|
||||
|
||||
target_link_libraries(fesa_dependency_smoke_test
|
||||
PRIVATE
|
||||
MKL::MKL
|
||||
TBB::tbb
|
||||
HDF5::HDF5
|
||||
GTest::gtest_main
|
||||
GTest::gtest
|
||||
GTest::gmock
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME DependencySmoke
|
||||
COMMAND "$<TARGET_FILE:fesa_dependency_smoke_test>"
|
||||
)
|
||||
|
||||
set_property(
|
||||
TEST DependencySmoke
|
||||
PROPERTY ENVIRONMENT_MODIFICATION
|
||||
${FESA_DEPENDENCY_RUNTIME_MODIFICATIONS}
|
||||
)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <hdf5.h>
|
||||
#include <mkl.h>
|
||||
#include <oneapi/tbb/global_control.h>
|
||||
#include <oneapi/tbb/parallel_for.h>
|
||||
|
||||
namespace {
|
||||
|
||||
TEST(DependencySmoke, CallsOneMklVectorOperation) {
|
||||
constexpr std::array<double, 3> x{1.0, 2.0, 3.0};
|
||||
std::array<double, 3> y{4.0, 5.0, 6.0};
|
||||
|
||||
cblas_daxpy(
|
||||
static_cast<MKL_INT>(x.size()), 2.0, x.data(), 1, y.data(), 1);
|
||||
|
||||
EXPECT_THAT(y, ::testing::ElementsAre(6.0, 9.0, 12.0));
|
||||
}
|
||||
|
||||
TEST(DependencySmoke, RunsLimitedOneTbbParallelLoop) {
|
||||
std::array<std::size_t, 16> values{};
|
||||
const oneapi::tbb::global_control limit{
|
||||
oneapi::tbb::global_control::max_allowed_parallelism, 2};
|
||||
|
||||
oneapi::tbb::parallel_for(
|
||||
std::size_t{0}, values.size(), [&values](const std::size_t index) {
|
||||
values[index] = index + 1;
|
||||
});
|
||||
|
||||
EXPECT_THAT(values, ::testing::ElementsAre(
|
||||
1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U,
|
||||
9U, 10U, 11U, 12U, 13U, 14U, 15U, 16U));
|
||||
}
|
||||
|
||||
TEST(DependencySmoke, CreatesAndClosesHdf5File) {
|
||||
const auto path =
|
||||
std::filesystem::path{::testing::TempDir()} /
|
||||
"fesa_dependency_smoke.h5";
|
||||
|
||||
const hid_t file = H5Fcreate(
|
||||
path.string().c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
||||
ASSERT_GE(file, 0);
|
||||
EXPECT_GE(H5Fclose(file), 0);
|
||||
|
||||
std::error_code error;
|
||||
std::filesystem::remove(path, error);
|
||||
EXPECT_FALSE(error);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user