Commit bc9365e4 authored by steinbac's avatar steinbac

refactored more general tests out

parent a9e638fd
......@@ -9,10 +9,11 @@ cmake_host_system_information(RESULT CURRENT_HOSTNAME QUERY HOSTNAME)
if(${CURRENT_HOSTNAME} MATCHES ".*(falcon2|talisker|schorle|scicomp-pc-3|recovery-station).*")
message(">> hostname (${CURRENT_HOSTNAME}): added compass test ")
add_test(NAME compass_impl COMMAND test_compass_impl)
add_test(NAME compass_sizes COMMAND test_compass_sizes)
add_test(NAME machine COMMAND test_machine)
else()
message(">> unknown host (${CURRENT_HOSTNAME}): no tests were written for your host ")
endif()
add_test(NAME compass_impl COMMAND test_compass_impl)
add_test(NAME bitview COMMAND test_bitview)
......@@ -26,14 +26,11 @@ add_dependencies(catcho catch2)
cmake_host_system_information(RESULT CURRENT_HOSTNAME QUERY HOSTNAME)
if(${CURRENT_HOSTNAME} MATCHES ".*(falcon2|talisker|schorle|scicomp-pc-3|recovery-station).*")
add_executable(test_compass_impl test_compass_impl.cpp $<TARGET_OBJECTS:catcho>)
add_dependencies(test_compass_impl catcho compass)
target_include_directories(test_compass_impl PRIVATE ${CATCH2_HEADER_PATH} ${COMPASS_INCLUDE_BUILD_DIR})
# add_executable(test_compass_sizes test_compass_sizes.cpp $<TARGET_OBJECTS:catcho>)
# target_include_directories(test_compass_sizes PRIVATE ${PROJECT_SOURCE_DIR}/include ${CATCH2_HEADER_PATH})
add_executable(test_machine test_machine.cpp $<TARGET_OBJECTS:catcho>)
target_include_directories(test_machine PRIVATE ${CATCH2_HEADER_PATH} ${COMPASS_INCLUDE_BUILD_DIR})
add_executable(test_compass_sizes test_compass_sizes.cpp $<TARGET_OBJECTS:catcho>)
add_dependencies(test_compass_sizes catcho compass)
target_include_directories(test_compass_sizes PRIVATE ${CATCH2_HEADER_PATH} ${COMPASS_INCLUDE_BUILD_DIR})
endif()
......@@ -42,6 +39,8 @@ endif()
#Windows 7: use `wmic cpu GET Name` to obtain clearname of CPU model
#Linux : use `lscpu` or `/proc/cpuinfo` to obtain more data about
#macOS : not sure yet what to use
add_executable(test_compass_impl test_compass_impl.cpp $<TARGET_OBJECTS:catcho>)
target_include_directories(test_compass_impl PRIVATE ${CATCH2_HEADER_PATH} ${COMPASS_INCLUDE_BUILD_DIR})
add_executable(test_bitview test_bitview.cpp $<TARGET_OBJECTS:catcho>)
target_include_directories(test_bitview PRIVATE ${PROJECT_SOURCE_DIR}/include ${CATCH2_HEADER_PATH})
......
#include "catch.hpp"
#include "compass_fixture.hpp"
#include "compass.hpp"
......@@ -25,110 +24,20 @@ TEST_CASE( "compass_fundamentals" ){
REQUIRE(value.size()!=0u);
}
}
TEST_CASE_METHOD( host_reference, "machine_specific" ){
SECTION( "vendor_right" ){
auto value = compass::runtime::vendor();
REQUIRE(value.size()!=0u);
std::transform(value.begin(), value.end(),
value.begin(),
::tolower);
REQUIRE(value.find(expected_vendor)!=std::string::npos);
}
SECTION( "brand_right" ){
auto value = compass::runtime::brand();
REQUIRE(value.empty()!=true);
REQUIRE_THAT(value, Catch::Matchers::Contains(expected_brand) );
}
SECTION( "device_name_right" ){
auto value = compass::runtime::device_name();
REQUIRE(value.empty()!=true);
REQUIRE_THAT(value, Catch::Matchers::Contains(expected_device_name) );
}
SECTION( "ncores_right" ){
SECTION( "compass_yields_non_zero_corecount" ){
auto value = compass::runtime::threads();
REQUIRE(value>0u);
REQUIRE(value!=0);
REQUIRE(value==expected_ncores);
}
// SECTION( "physical_cores_right" ){
// auto value = compass::runtime::physical_threads();
// REQUIRE(value!=0);
// REQUIRE(value==expected_nphyscores);
// }
SECTION( "has_sse_right" ){
auto value = compass::runtime::has(compass::feature::sse());
SECTION( "compass_yields_non_zero_L1size" ){
REQUIRE(value==expected_has_sse);
}
SECTION( "has_sse2_right" ){
auto value = compass::runtime::has(compass::feature::sse2());
REQUIRE(value==expected_has_sse2);
}
SECTION( "has_sse3_right" ){
auto value = compass::runtime::has(compass::feature::sse3());
REQUIRE(value==expected_has_sse3);
}
SECTION( "has_sse4_right" ){
auto value = compass::runtime::has(compass::feature::sse4());
REQUIRE(value==expected_has_sse4);
}
SECTION( "has_avx_right" ){
auto value = compass::runtime::has(compass::feature::avx());
REQUIRE(value==expected_has_avx);
}
SECTION( "has_avx2_right" ){
auto value = compass::runtime::has(compass::feature::avx2());
REQUIRE(value==expected_has_avx2);
auto value = compass::runtime::size::cacheline::level(1);
REQUIRE(value>0u);
}
}
}
#include "catch.hpp"
#include "compass_fixture.hpp"
#include "compass.hpp"
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
TEST_CASE_METHOD( host_reference, "machine_specific" ){
SECTION( "vendor_right" ){
auto value = compass::runtime::vendor();
REQUIRE(value.size()!=0u);
std::transform(value.begin(), value.end(),
value.begin(),
::tolower);
REQUIRE(value.find(expected_vendor)!=std::string::npos);
}
SECTION( "brand_right" ){
auto value = compass::runtime::brand();
REQUIRE(value.empty()!=true);
REQUIRE_THAT(value, Catch::Matchers::Contains(expected_brand) );
}
SECTION( "device_name_right" ){
auto value = compass::runtime::device_name();
REQUIRE(value.empty()!=true);
REQUIRE_THAT(value, Catch::Matchers::Contains(expected_device_name) );
}
SECTION( "ncores_right" ){
auto value = compass::runtime::threads();
REQUIRE(value!=0);
REQUIRE(value==expected_ncores);
}
// SECTION( "physical_cores_right" ){
// auto value = compass::runtime::physical_threads();
// REQUIRE(value!=0);
// REQUIRE(value==expected_nphyscores);
// }
SECTION( "has_sse_right" ){
auto value = compass::runtime::has(compass::feature::sse());
REQUIRE(value==expected_has_sse);
}
SECTION( "has_sse2_right" ){
auto value = compass::runtime::has(compass::feature::sse2());
REQUIRE(value==expected_has_sse2);
}
SECTION( "has_sse3_right" ){
auto value = compass::runtime::has(compass::feature::sse3());
REQUIRE(value==expected_has_sse3);
}
SECTION( "has_sse4_right" ){
auto value = compass::runtime::has(compass::feature::sse4());
REQUIRE(value==expected_has_sse4);
}
SECTION( "has_avx_right" ){
auto value = compass::runtime::has(compass::feature::avx());
REQUIRE(value==expected_has_avx);
}
SECTION( "has_avx2_right" ){
auto value = compass::runtime::has(compass::feature::avx2());
REQUIRE(value==expected_has_avx2);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment