fix scaling for count and update CI (#328)

This commit is contained in:
Hans Dembinski 2021-06-27 16:58:14 +02:00 committed by GitHub
parent 6cde30a366
commit 90a58d03ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 43 additions and 24 deletions

View File

@ -12,6 +12,7 @@ on:
env:
B2_OPTS: -q -j2 warnings-as-errors=on
GCC_VERSION: 11
jobs:
cov:
@ -49,12 +50,12 @@ jobs:
cd libs/histogram
# don't compile examples in coverage build, coverage must come from tests alone
../../b2 $B2_OPTS toolset=gcc-8 cxxstd=latest coverage=on test//all
../../b2 $B2_OPTS toolset=gcc-${GCC_VERSION} cxxstd=latest coverage=on test//all
- name: Process coverage data
run: |
cd libs/histogram
GCOV=gcov-8 tools/cov.py
GCOV=gcov-${GCC_VERSION} tools/cov.py
- uses: coverallsapp/github-action@v1.1.2
with:

View File

@ -37,4 +37,5 @@ jobs:
- name: ctest
run: |
cd build
cmake --build . -j3 --target tests # temporary workaround (I hope)
ctest -C Debug --output-on-failure

View File

@ -107,7 +107,7 @@ jobs:
cd libs/histogram
../../b2 $B2_OPTS toolset=gcc-10 cxxstd=20 cxxflags="-O3 -funsafe-math-optimizations" test//all examples
clang6:
clang10:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@ -127,4 +127,4 @@ jobs:
- name: Test cxxstd=17 ubsan asan
run: |
cd libs/histogram
../../b2 $B2_OPTS toolset=clang-6 cxxstd=17 variant=histogram_ubasan test//all
../../b2 $B2_OPTS toolset=clang-10 cxxstd=17 variant=histogram_ubasan test//all

View File

@ -45,6 +45,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
include(CTest)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
add_dependencies(check tests) # needed to build the "run" tests
if(BUILD_TESTING)

View File

@ -42,6 +42,12 @@ struct atomic_number : std::atomic<T> {
return *this;
}
// not thread-safe
atomic_number& operator*=(const T& x) noexcept {
this->store(this->load() * x);
return *this;
}
private:
// for integral types
template <class U = T>

View File

@ -279,7 +279,7 @@ public:
detail::sample_args_passed_vs_expected<sample_args_passed,
typename acc_traits::args>();
std::lock_guard<typename mutex_base::type> guard{mutex_base::get()};
mp11::tuple_apply(
mp11::tuple_apply( // LCOV_EXCL_LINE: gcc-11 is missing this line for no reason
[&](const auto&... sargs) {
constexpr bool sample_valid =
std::is_convertible<sample_args_passed, typename acc_traits::args>::value;
@ -309,7 +309,7 @@ public:
detail::sample_args_passed_vs_expected<sample_args_passed,
typename acc_traits::args>();
std::lock_guard<typename mutex_base::type> guard{mutex_base::get()};
mp11::tuple_apply(
mp11::tuple_apply( // LCOV_EXCL_LINE: gcc-11 is missing this line for no reason
[&](const auto&... sargs) {
constexpr bool weight_valid = acc_traits::weight_support;
static_assert(weight_valid, "error: accumulator does not support weights");

View File

@ -17,28 +17,38 @@ template <class T, bool B>
void run_tests() {
using c_t = accumulators::count<T, B>;
c_t c;
++c;
BOOST_TEST_EQ(c.value(), 1);
BOOST_TEST_EQ(str(c), "1"s);
BOOST_TEST_EQ(str(c, 2, false), " 1"s);
BOOST_TEST_EQ(str(c, 2, true), "1 "s);
{
c_t c;
++c;
BOOST_TEST_EQ(c.value(), 1);
BOOST_TEST_EQ(str(c), "1"s);
BOOST_TEST_EQ(str(c, 2, false), " 1"s);
BOOST_TEST_EQ(str(c, 2, true), "1 "s);
c += 2;
BOOST_TEST_EQ(str(c), "3"s);
c += 2;
BOOST_TEST_EQ(str(c), "3"s);
BOOST_TEST_EQ(c, static_cast<T>(3));
BOOST_TEST_NE(c, static_cast<T>(2));
BOOST_TEST_EQ(c, static_cast<T>(3));
BOOST_TEST_NE(c, static_cast<T>(2));
}
c_t one(1), two(2), one_copy(1);
BOOST_TEST_LT(one, two);
BOOST_TEST_LE(one, two);
BOOST_TEST_LE(one, one_copy);
BOOST_TEST_GT(two, one);
BOOST_TEST_GE(two, one);
BOOST_TEST_GE(one, one_copy);
{
c_t one(1), two(2), one_copy(1);
BOOST_TEST_LT(one, two);
BOOST_TEST_LE(one, two);
BOOST_TEST_LE(one, one_copy);
BOOST_TEST_GT(two, one);
BOOST_TEST_GE(two, one);
BOOST_TEST_GE(one, one_copy);
}
BOOST_TEST_EQ(c_t{} += c_t{}, c_t{});
{
c_t two(2);
auto six = two * 3;
BOOST_TEST_EQ(six, static_cast<T>(6));
}
}
int main() {

View File

@ -18,7 +18,7 @@ import sys
LCOV_VERSION = "1.15"
gcov = os.environ.get("GCOV", "gcov-8")
gcov = os.environ.get("GCOV", "gcov")
gcov_version = gcov.split("-")[1] if "-" in gcov else None
gcc_version = f"gcc-{gcov_version}" if gcov_version else "gcc"