From c2fa4537252e008274e684431424116a15390315 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Fri, 23 Jul 2021 01:27:02 +0300 Subject: [PATCH] mdbx-test: fix keygen-related issue. Fixes https://github.com/erthink/libmdbx/issues/127 --- ChangeLog.md | 2 +- test/keygen.cc | 12 +++++++----- test/keygen.h | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index c576dc16..bbd8d539 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -14,7 +14,6 @@ ChangeLog - [Get rid of dirty-pages list in MDBX_WRITEMAP mode](https://github.com/erthink/libmdbx/issues/193). - [Large/Overflow pages accounting for dirty-room](https://github.com/erthink/libmdbx/issues/192). - [Support for RAW devices](https://github.com/erthink/libmdbx/issues/124). - - [Test framework issue](https://github.com/erthink/libmdbx/issues/127). - [Support MessagePack for Keys & Values](https://github.com/erthink/libmdbx/issues/115). - [Engage new terminology](https://github.com/erthink/libmdbx/issues/137). - Finalize C++ API (few typos and trivia bugs are still likely for now). @@ -61,6 +60,7 @@ Fixes: - Fixed [using bad meta-pages if DB was partially/recoverable corrupted](https://github.com/erthink/libmdbx/issues/217). - Fixed extra `noexcept` for `buffer::&assign_reference()`. - Fixed `bootid` generation on Windows for case of change system' time. + - Fixed [test framework keygen-related issue](https://github.com/erthink/libmdbx/issues/127). ## v0.10.1 at 2021-06-01 diff --git a/test/keygen.cc b/test/keygen.cc index 0cbd3299..566e2510 100644 --- a/test/keygen.cc +++ b/test/keygen.cc @@ -243,23 +243,25 @@ void maker::seek2end(serial_t &serial) const { serial = actor_params::serial_mask(mapping.width) - 1; } -bool maker::increment(serial_t &serial, int delta) const { +bool maker::increment(serial_t &serial, int64_t delta) const { if (serial > actor_params::serial_mask(mapping.width)) { log_extra("keygen-increment: %" PRIu64 " > %" PRIu64 ", overflow", serial, actor_params::serial_mask(mapping.width)); return false; } - serial_t target = serial + (int64_t)delta; + serial_t target = serial + delta; if (target > actor_params::serial_mask(mapping.width) || ((delta > 0) ? target < serial : target > serial)) { - log_extra("keygen-increment: %" PRIu64 "%-d => %" PRIu64 ", overflow", + log_extra("keygen-increment: %" PRIu64 "%-" PRId64 " => %" PRIu64 + ", overflow", serial, delta, target); return false; } - log_extra("keygen-increment: %" PRIu64 "%-d => %" PRIu64 ", continue", serial, - delta, target); + log_extra("keygen-increment: %" PRIu64 "%-" PRId64 " => %" PRIu64 + ", continue", + serial, delta, target); serial = target; return true; } diff --git a/test/keygen.h b/test/keygen.h index c7b758ab..2cb619aa 100644 --- a/test/keygen.h +++ b/test/keygen.h @@ -130,8 +130,8 @@ public: bool is_unordered() const; void seek2end(serial_t &serial) const; - bool increment(serial_t &serial, int delta) const; - bool increment_key_part(serial_t &serial, int delta, + bool increment(serial_t &serial, int64_t delta) const; + bool increment_key_part(serial_t &serial, int64_t delta, bool reset_value_part = true) const { if (reset_value_part) { serial_t value_part_bits = ((serial_t(1) << mapping.split) - 1); @@ -139,7 +139,7 @@ public: if (delta >= 0) serial &= ~value_part_bits; } - return increment(serial, delta << mapping.split); + return increment(serial, int64_t(uint64_t(delta) << mapping.split)); } };