Skip to content

Commit

Permalink
tests: Update to catch.hpp v2.13.4 and fix #2178
Browse files Browse the repository at this point in the history
This patch is about fixing a compilation error that we are seeing on
Fedora Rawhide with glibc 2.33.9000, which makes MINSIGSTKSZ not be a
constant value anymore.  Thus, the sigStackSize variable that is
declared constexpr cannot use that MINSIGSTKSZ as initializer anymore.

So as suggested in the issue
catchorg/Catch2#2178 filed against
'catchorg' for this purpose, I am hardwiring the initialization value
of sigStackSize for now.

	* tests/lib/catch.hpp: Update to v2.13.4 and initialize
	sigStackSize to 32768 for now, as suggested by
	catchorg/Catch2#2178.

Signed-off-by: Dodji Seketeli <[email protected]>
  • Loading branch information
Dodji Seketeli committed Feb 24, 2021
1 parent 77bc4b7 commit 8ae8dcb
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions tests/lib/catch.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: BSL-1.0
/*
* Catch v2.13.3
* Generated: 2020-10-31 18:20:31.045274
* Catch v2.13.4
* Generated: 2020-12-29 14:48:00.116107
* ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved.
Expand All @@ -16,7 +15,7 @@

#define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 13
#define CATCH_VERSION_PATCH 3
#define CATCH_VERSION_PATCH 4

#ifdef __clang__
# pragma clang system_header
Expand Down Expand Up @@ -10820,8 +10819,12 @@ namespace Catch {

// 32kb for the alternate stack seems to be sufficient. However, this value
// is experimentally determined, so that's not guaranteed.
static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
//static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;

// Since glibc 2.33.9000 MINSIGSTKSZ is no more a constant. So,
// let's hardwire this for now as suggested by
// https://github.com/catchorg/Catch2/issues/2178.
static constexpr std::size_t sigStackSize = 32768;
static SignalDefs signalDefs[] = {
{ SIGINT, "SIGINT - Terminal interrupt signal" },
{ SIGILL, "SIGILL - Illegal instruction signal" },
Expand Down Expand Up @@ -14127,24 +14130,28 @@ namespace Catch {

namespace {
struct TestHasher {
explicit TestHasher(Catch::SimplePcg32& rng_instance) {
basis = rng_instance();
basis <<= 32;
basis |= rng_instance();
}
using hash_t = uint64_t;

uint64_t basis;
explicit TestHasher( hash_t hashSuffix ):
m_hashSuffix{ hashSuffix } {}

uint64_t operator()(TestCase const& t) const {
// Modified FNV-1a hash
static constexpr uint64_t prime = 1099511628211;
uint64_t hash = basis;
for (const char c : t.name) {
uint32_t operator()( TestCase const& t ) const {
// FNV-1a hash with multiplication fold.
const hash_t prime = 1099511628211u;
hash_t hash = 14695981039346656037u;
for ( const char c : t.name ) {
hash ^= c;
hash *= prime;
}
return hash;
hash ^= m_hashSuffix;
hash *= prime;
const uint32_t low{ static_cast<uint32_t>( hash ) };
const uint32_t high{ static_cast<uint32_t>( hash >> 32 ) };
return low * high;
}

private:
hash_t m_hashSuffix;
};
} // end unnamed namespace

Expand All @@ -14162,9 +14169,9 @@ namespace Catch {

case RunTests::InRandomOrder: {
seedRng( config );
TestHasher h( rng() );
TestHasher h{ config.rngSeed() };

using hashedTest = std::pair<uint64_t, TestCase const*>;
using hashedTest = std::pair<TestHasher::hash_t, TestCase const*>;
std::vector<hashedTest> indexed_tests;
indexed_tests.reserve( unsortedTestCases.size() );

Expand Down Expand Up @@ -15317,7 +15324,7 @@ namespace Catch {
}

Version const& libraryVersion() {
static Version version( 2, 13, 3, "", 0 );
static Version version( 2, 13, 4, "", 0 );
return version;
}

Expand Down

0 comments on commit 8ae8dcb

Please sign in to comment.