mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-15 14:22:37 -03:00
faec28252c
-BEGIN VERIFY SCRIPT- # Move files for f in $(git ls-files src/test/lib/); do git mv $f src/test/util/; done git mv src/test/setup_common.cpp src/test/util/ git mv src/test/setup_common.h src/test/util/ # Replace Windows paths sed -i -e 's|\\setup_common|\\util\\setup_common|g' $(git grep -l '\\setup_common') sed -i -e 's|src\\test\\lib\\|src\\test\\util\\|g' build_msvc/test_bitcoin/test_bitcoin.vcxproj # Everything else sed -i -e 's|/setup_common|/util/setup_common|g' $(git grep -l 'setup_common') sed -i -e 's|test/lib/|test/util/|g' $(git grep -l 'test/lib/') # Fix include guard sed -i -e 's|BITCOIN_TEST_SETUP_COMMON_H|BITCOIN_TEST_UTIL_SETUP_COMMON_H|g' ./src/test/util/setup_common.h sed -i -e 's|BITCOIN_TEST_LIB_|BITCOIN_TEST_UTIL_|g' $(git grep -l 'BITCOIN_TEST_LIB_') -END VERIFY SCRIPT-
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
// Copyright (c) 2019 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <test/util/setup_common.h>
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
BOOST_FIXTURE_TEST_SUITE(compilerbug_tests, BasicTestingSetup)
|
|
|
|
#if defined(__GNUC__)
|
|
// This block will also be built under clang, which is fine (as it supports noinline)
|
|
void __attribute__ ((noinline)) set_one(unsigned char* ptr)
|
|
{
|
|
*ptr = 1;
|
|
}
|
|
|
|
int __attribute__ ((noinline)) check_zero(unsigned char const* in, unsigned int len)
|
|
{
|
|
for (unsigned int i = 0; i < len; ++i) {
|
|
if (in[i] != 0) return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
void set_one_on_stack() {
|
|
unsigned char buf[1];
|
|
set_one(buf);
|
|
}
|
|
|
|
BOOST_AUTO_TEST_CASE(gccbug_90348) {
|
|
// Test for GCC bug 90348. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90348
|
|
for (int i = 0; i <= 4; ++i) {
|
|
unsigned char in[4];
|
|
for (int j = 0; j < i; ++j) {
|
|
in[j] = 0;
|
|
set_one_on_stack(); // Apparently modifies in[0]
|
|
}
|
|
BOOST_CHECK(check_zero(in, i));
|
|
}
|
|
}
|
|
#endif
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|