Skip to content

Commit

Permalink
Merge pull request #148 from chfast/ci_upgrades
Browse files Browse the repository at this point in the history
CI Upgrades
  • Loading branch information
chfast authored Nov 4, 2019
2 parents 4470b53 + bbd94e7 commit b3397f0
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 88 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ if(NOT WIN32)
endif()

HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.20.35.tar.gz"
SHA1 "6e3cb4c333b76803a83c56fcbca3b0bfd9f96f27"
URL "https://github.com/cpp-pm/hunter/archive/v0.23.224.tar.gz"
SHA1 "18e57a43efc435f2e1dae1291e82e42afbf940be"
)

project(ethash)
Expand Down
28 changes: 8 additions & 20 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ defaults:
if ! brew install -q python3; then
brew upgrade -q python
fi
pip3 install -q requests
pip3 install -q requests gitpython
- checkout
- *configure
- *build
Expand Down Expand Up @@ -181,24 +181,12 @@ jobs:
linux-32bit-asan:
environment:
- BUILD_PARALLEL_JOBS: 2
- CMAKE_OPTIONS: -DTOOLCHAIN=cxx11-32bit
- CMAKE_OPTIONS: -DSANITIZE=address
- BUILD_TYPE: RelWithDebInfo
- CMAKE_OPTIONS: -DTOOLCHAIN=cxx11-32bit -DSANITIZE=address
- GTEST_FILTER: -*_oom
executor: linux
steps:
- checkout
- *install-m32
- *configure
- *build
- *test

linux-32bit-ubsan:
environment:
- BUILD_PARALLEL_JOBS: 2
- CMAKE_OPTIONS: -DTOOLCHAIN=cxx11-32bit
- CMAKE_OPTIONS: -DSANITIZE=undefined
- UBSAN_OPTIONS: halt_on_error=1
executor: linux
- ASAN_OPTIONS: allocator_may_return_null=1
docker:
- image: ethereum/cpp-build-env:12-gcc-9
steps:
- checkout
- *install-m32
Expand All @@ -211,7 +199,8 @@ jobs:
- BUILD_PARALLEL_JOBS: 2
- TEST_PARALLEL_JOBS: 2
- CMAKE_OPTIONS: -DTOOLCHAIN=mips64 -DCMAKE_EXE_LINKER_FLAGS=-static
executor: linux
docker:
- image: ethereum/cpp-build-env:12-gcc-9
steps:
- checkout
- *install-mips64
Expand Down Expand Up @@ -353,7 +342,6 @@ workflows:
- linux-clang-ubsan
- linux-clang-asan
- linux-32bit-asan
- linux-32bit-ubsan
- mips64
- powerpc64
- macos-xcode-tsan
Expand Down
7 changes: 6 additions & 1 deletion test/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ add_executable(

set_source_files_properties(test_version.cpp PROPERTIES COMPILE_DEFINITIONS TEST_PROJECT_VERSION="${PROJECT_VERSION}")

target_link_libraries(ethash-test PRIVATE ethash GTest::gtest GTest::main)
target_link_libraries(ethash-test PRIVATE ethash GTest::gtest_main)
target_include_directories(ethash-test PRIVATE ${ETHASH_PRIVATE_INCLUDE_DIR})
set_target_properties(ethash-test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..)

if(SANITIZE AND CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_CXX_FLAGS MATCHES -m32)
# Workaround for linking with phread when building for 32-bit and with sanitizer.
target_link_libraries(ethash-test PRIVATE pthread)
endif()
106 changes: 53 additions & 53 deletions test/unittests/test_bit_manipulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,80 +8,80 @@

TEST(bit_manipulation, rotl32)
{
EXPECT_EQ(rotl32(0, 0), 0);
EXPECT_EQ(rotl32(0, 4321), 0);
EXPECT_EQ(rotl32(0, 0), 0u);
EXPECT_EQ(rotl32(0, 4321), 0u);

EXPECT_EQ(rotl32(1, 0), 1);
EXPECT_EQ(rotl32(1, 1), 2);
EXPECT_EQ(rotl32(1, 2), 4);
EXPECT_EQ(rotl32(1, 31), 1u << 31);
EXPECT_EQ(rotl32(1, 32), 1);
EXPECT_EQ(rotl32(1, 33), 2);
EXPECT_EQ(rotl32(1, 0), 1u);
EXPECT_EQ(rotl32(1, 1), 2u);
EXPECT_EQ(rotl32(1, 2), 4u);
EXPECT_EQ(rotl32(1, 31), 1u << 31u);
EXPECT_EQ(rotl32(1, 32), 1u);
EXPECT_EQ(rotl32(1, 33), 2u);

EXPECT_EQ(rotl32(3, 0), 3);
EXPECT_EQ(rotl32(3, 1), 6);
EXPECT_EQ(rotl32(3, 30), 3u << 30);
EXPECT_EQ(rotl32(3, 31), (1u << 31) | 1);
EXPECT_EQ(rotl32(3, 32), 3);
EXPECT_EQ(rotl32(3, 33), 6);
EXPECT_EQ(rotl32(3, 0), 3u);
EXPECT_EQ(rotl32(3, 1), 6u);
EXPECT_EQ(rotl32(3, 30), 3u << 30u);
EXPECT_EQ(rotl32(3, 31), (1u << 31u) | 1u);
EXPECT_EQ(rotl32(3, 32), 3u);
EXPECT_EQ(rotl32(3, 33), 6u);
}

TEST(bit_manipulation, rotr32)
{
EXPECT_EQ(rotr32(0, 0), 0);
EXPECT_EQ(rotr32(0, 4321), 0);
EXPECT_EQ(rotr32(0, 0), 0u);
EXPECT_EQ(rotr32(0, 4321), 0u);

EXPECT_EQ(rotr32(1, 0), 1);
EXPECT_EQ(rotr32(1, 1), 1u << 31);
EXPECT_EQ(rotr32(1, 2), 1u << 30);
EXPECT_EQ(rotr32(1, 30), 1u << 2);
EXPECT_EQ(rotr32(1, 31), 1u << 1);
EXPECT_EQ(rotr32(1, 32), 1);
EXPECT_EQ(rotr32(1, 33), 1u << 31);
EXPECT_EQ(rotr32(1, 0), 1u);
EXPECT_EQ(rotr32(1, 1), 1u << 31u);
EXPECT_EQ(rotr32(1, 2), 1u << 30u);
EXPECT_EQ(rotr32(1, 30), 1u << 2u);
EXPECT_EQ(rotr32(1, 31), 1u << 1u);
EXPECT_EQ(rotr32(1, 32), 1u);
EXPECT_EQ(rotr32(1, 33), 1u << 31u);

EXPECT_EQ(rotr32(3, 0), 3);
EXPECT_EQ(rotr32(3, 1), (1u << 31) | 1);
EXPECT_EQ(rotr32(3, 2), (3u << 30));
EXPECT_EQ(rotr32(3, 30), 12);
EXPECT_EQ(rotr32(3, 31), 6);
EXPECT_EQ(rotr32(3, 32), 3);
EXPECT_EQ(rotr32(3, 33), (1u << 31) | 1);
EXPECT_EQ(rotr32(3, 0), 3u);
EXPECT_EQ(rotr32(3, 1), (1u << 31u) | 1u);
EXPECT_EQ(rotr32(3, 2), 3u << 30u);
EXPECT_EQ(rotr32(3, 30), 12u);
EXPECT_EQ(rotr32(3, 31), 6u);
EXPECT_EQ(rotr32(3, 32), 3u);
EXPECT_EQ(rotr32(3, 33), (1u << 31u) | 1u);
}

TEST(bit_manipulation, clz32)
{
EXPECT_EQ(clz32(0), 32);
EXPECT_EQ(clz32(1), 31);
EXPECT_EQ(clz32(1 << 1), 30);
EXPECT_EQ(clz32(1 << 2), 29);
EXPECT_EQ(clz32(1 << 30), 1);
EXPECT_EQ(clz32(1u << 31), 0);
EXPECT_EQ(clz32(4321), 19);
EXPECT_EQ(clz32(0), 32u);
EXPECT_EQ(clz32(1), 31u);
EXPECT_EQ(clz32(1u << 1u), 30u);
EXPECT_EQ(clz32(1u << 2u), 29u);
EXPECT_EQ(clz32(1u << 30u), 1u);
EXPECT_EQ(clz32(1u << 31u), 0u);
EXPECT_EQ(clz32(4321), 19u);
}

TEST(bit_manipulation, popcount32)
{
EXPECT_EQ(popcount32(0), 0);
EXPECT_EQ(popcount32(1), 1);
EXPECT_EQ(popcount32(1 << 16), 1);
EXPECT_EQ(popcount32(3), 2);
EXPECT_EQ(popcount32(3 << 17), 2);
EXPECT_EQ(popcount32(9 << 18), 2);
EXPECT_EQ(popcount32(~0u), 32);
EXPECT_EQ(popcount32(0), 0u);
EXPECT_EQ(popcount32(1), 1u);
EXPECT_EQ(popcount32(1u << 16u), 1u);
EXPECT_EQ(popcount32(3), 2u);
EXPECT_EQ(popcount32(3u << 17u), 2u);
EXPECT_EQ(popcount32(9u << 18u), 2u);
EXPECT_EQ(popcount32(~0u), 32u);
}

TEST(bit_manipulation, mul_hi32)
{
EXPECT_EQ(mul_hi32(0, 0), 0);
EXPECT_EQ(mul_hi32(0, 1), 0);
EXPECT_EQ(mul_hi32(1, 0), 0);
EXPECT_EQ(mul_hi32(1, 1), 0);
EXPECT_EQ(mul_hi32(0, 0), 0u);
EXPECT_EQ(mul_hi32(0, 1), 0u);
EXPECT_EQ(mul_hi32(1, 0), 0u);
EXPECT_EQ(mul_hi32(1, 1), 0u);

EXPECT_EQ(mul_hi32(1 << 16, 1 << 16), 1);
EXPECT_EQ(mul_hi32(1 << 16, (1 << 16) + 1), 1);
EXPECT_EQ(mul_hi32(1u << 16u, 1u << 16u), 1u);
EXPECT_EQ(mul_hi32(1u << 16u, (1u << 16u) + 1u), 1u);

EXPECT_EQ(mul_hi32(1 << 30, 1 << 30), 1 << 28);
EXPECT_EQ(mul_hi32(1u << 31, 1u << 31), 1 << 30);
EXPECT_EQ(mul_hi32(1u << 30u, 1u << 30u), 1u << 28u);
EXPECT_EQ(mul_hi32(1u << 31u, 1u << 31u), 1u << 30u);

EXPECT_EQ(mul_hi32(~0u, ~0u), ~0u - 1);
EXPECT_EQ(mul_hi32(~0u, ~0u), ~0u - 1u);
}
17 changes: 10 additions & 7 deletions test/unittests/test_ethash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#pragma GCC diagnostic ignored "-Wpedantic"
#pragma clang diagnostic ignored "-Wpedantic"
#pragma warning(disable : 4127)

#include <ethash/endianness.hpp>
#include <ethash/ethash-internal.hpp>
Expand Down Expand Up @@ -577,13 +578,15 @@ TEST(ethash, verify_hash)
if (!context || context->epoch_number != epoch_number)
context = create_epoch_context_full(epoch_number);

#if _WIN32 && !_WIN64
// On Windows 32-bit you can only allocate ~ 2GB of memory.
static constexpr uint64_t allocation_size_limit = uint64_t(2) * 1024 * 1024 * 1024;
if (!context && full_dataset_size > allocation_size_limit)
continue;
#endif
ASSERT_NE(context, nullptr);
if (sizeof(void*) == 4)
{
// On 32-bit systems expect failures for allocations > 1GB of memory.
static constexpr auto allocation_size_limit = uint64_t{1} * 1024 * 1024 * 1024;
if (!context && full_dataset_size > allocation_size_limit)
continue;
}

ASSERT_NE(context, nullptr) << full_dataset_size;
EXPECT_GT(full_dataset_size, 0);

result r = hash(*context, header_hash, nonce);
Expand Down
10 changes: 5 additions & 5 deletions test/unittests/test_kiss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ TEST(kiss99, generate)
{
kiss99 rng;

EXPECT_EQ(rng(), 769445856);
EXPECT_EQ(rng(), 742012328);
EXPECT_EQ(rng(), 2121196314);
EXPECT_EQ(rng(), 2805620942);
EXPECT_EQ(rng(), 769445856u);
EXPECT_EQ(rng(), 742012328u);
EXPECT_EQ(rng(), 2121196314u);
EXPECT_EQ(rng(), 2805620942u);

for (int i = 0; i < 100000 - 5; ++i)
rng();

// The 100000th number.
EXPECT_EQ(rng(), 941074834);
EXPECT_EQ(rng(), 941074834u);
}

TEST(kiss99, compare_with_reference)
Expand Down
1 change: 1 addition & 0 deletions test/unittests/test_progpow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ TEST(progpow, hash_and_verify)
TEST(progpow, search)
{
auto ctxp = ethash::create_epoch_context_full(0);
ASSERT_NE(ctxp, nullptr);
auto& ctx = *ctxp;
auto& ctxl = reinterpret_cast<const ethash::epoch_context&>(ctx);

Expand Down

0 comments on commit b3397f0

Please sign in to comment.