test: Fix failing univalue float test #29892

pull maflcko wants to merge 1 commits into bitcoin:master from maflcko:2404-fix-float-univalue-test- changing 2 files +2 −1
  1. maflcko commented at 2:42 pm on April 16, 2024: member

    Currently the test may fail for some compilers, because 1e-8 may not be possible to represent exactly/consistently.

    0$ ./src/univalue/test/object 
    1object: univalue/test/object.cpp:424: void univalue_readwrite(): Assertion `v.read("0.00000000000000000000000000000000000001e+30 ") && v.get_real() == 1e-8' failed.
    2Aborted (core dumped)
    

    Fixes #27256 (review)

  2. test: Fix failing univalue float test fa4c69669e
  3. DrahtBot commented at 2:42 pm on April 16, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK stickies-v, laanwj

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  4. DrahtBot added the label Tests on Apr 16, 2024
  5. fanquake added the label Needs backport (27.x) on Apr 16, 2024
  6. fanquake requested review from stickies-v on Apr 16, 2024
  7. stickies-v approved
  8. stickies-v commented at 3:40 pm on April 16, 2024: contributor
    ACK fa4c69669e079c38844ecea1ad3394aae3702ae1 , thanks for fixing!
  9. maflcko commented at 3:45 pm on April 16, 2024: member

    For testing, one can use gcc-13 (or later) on i386.

    For example, running the centos CI task on fedora:40:

     0diff --git a/ci/test/00_setup_env_i686_centos.sh b/ci/test/00_setup_env_i686_centos.sh
     1index 5f8391c..dc80e98 100755
     2--- a/ci/test/00_setup_env_i686_centos.sh
     3+++ b/ci/test/00_setup_env_i686_centos.sh
     4@@ -12,6 +12,7 @@ export CI_IMAGE_NAME_TAG="quay.io/centos/amd64:stream9"
     5 export CI_BASE_PACKAGES="gcc-c++ glibc-devel.x86_64 libstdc++-devel.x86_64 glibc-devel.i686 libstdc++-devel.i686 ccache libtool make git python3 python3-pip which patch lbzip2 xz procps-ng dash rsync coreutils bison util-linux e2fsprogs cmake"
     6 export PIP_PACKAGES="pyzmq"
     7 export GOAL="install"
     8+export DEP_OPTS="NO_QT=1"
     9 export NO_WERROR=1  # Suppress error: #warning _FORTIFY_SOURCE > 2 is treated like 2 on this platform [-Werror=cpp]
    10-export BITCOIN_CONFIG="--enable-zmq --with-gui=qt5 --enable-reduce-exports"
    11+export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports"
    12 export CONFIG_SHELL="/bin/dash"
    13diff --git a/ci/test/01_base_install.sh b/ci/test/01_base_install.sh
    14index 25962a5..6f61394 100755
    15--- a/ci/test/01_base_install.sh
    16+++ b/ci/test/01_base_install.sh
    17@@ -20,7 +20,6 @@ if [ -n "$DPKG_ADD_ARCH" ]; then
    18 fi
    19 
    20 if [[ $CI_IMAGE_NAME_TAG == *centos* ]]; then
    21-  bash -c "dnf -y install epel-release"
    22   bash -c "dnf -y --allowerasing install $CI_BASE_PACKAGES $PACKAGES"
    23 elif [ "$CI_OS_NAME" != "macos" ]; then
    24   if [[ -n "${APPEND_APT_SOURCES_LIST}" ]]; then
    

    Or, alternatively, using gcc in the multiprocess task:

     0diff --git a/ci/test/00_setup_env_i686_multiprocess.sh b/ci/test/00_setup_env_i686_multiprocess.sh
     1index 00a4d78..517ca0c 100755
     2--- a/ci/test/00_setup_env_i686_multiprocess.sh
     3+++ b/ci/test/00_setup_env_i686_multiprocess.sh
     4@@ -9,10 +9,10 @@ export LC_ALL=C.UTF-8
     5 export HOST=i686-pc-linux-gnu
     6 export CONTAINER_NAME=ci_i686_multiprocess
     7 export CI_IMAGE_NAME_TAG="docker.io/amd64/ubuntu:24.04"
     8-export PACKAGES="llvm clang g++-multilib"
     9-export DEP_OPTS="DEBUG=1 MULTIPROCESS=1"
    10+export PACKAGES="g++-multilib"
    11+export DEP_OPTS="DEBUG=1 MULTIPROCESS=1 NO_QT=1"
    12 export GOAL="install"
    13 export TEST_RUNNER_EXTRA="--v2transport"
    14-export BITCOIN_CONFIG="--enable-debug CC='clang -m32' CXX='clang++ -m32' \
    15+export BITCOIN_CONFIG="--enable-debug  \
    16 CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE'"
    17 export BITCOIND=bitcoin-node  # Used in functional tests
    
  10. laanwj commented at 5:38 am on April 17, 2024: member

    Right. Direct floating point equality checks are a big nono. It should either use an epsilon comparison, or discretize. Which is what the new test does.

    ACK fa4c69669e079c38844ecea1ad3394aae3702ae1

  11. fanquake merged this on Apr 17, 2024
  12. fanquake closed this on Apr 17, 2024

  13. fanquake referenced this in commit 335fcb56be on Apr 17, 2024
  14. fanquake removed the label Needs backport (27.x) on Apr 17, 2024
  15. fanquake commented at 7:59 am on April 17, 2024: member
    Backported to 27.x in #29888.
  16. maflcko deleted the branch on Apr 17, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-09-28 22:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me