Find file History
laanwj Merge #14151: windows: Fix remaining compiler warnings (MSVC)
b9dafe7 Fix remaining compiler warnings (MSVC). Move disabling of specific warnings from /nowarn to project file. (practicalswift)

Pull request description:

  Fix remaining compiler warnings (MSVC).

  Before:

  ```
  $ msbuild /p:TrackFileAccess=false /p:CLToolExe=clcache.exe build_msvc\bitcoin.sln /m /v:q /nowarn:C4244;C4267;C4715 /nologo
  …\script\script.cpp(272): warning C4018: '>': signed/unsigned mismatch
  …\test\allocator_tests.cpp(147): warning C4312: 'reinterpret_cast': conversion from 'int' to 'void *' of greater size
  …\boost\test\tools\old\impl.hpp(107): warning C4805: '==': unsafe mix of type 'const Left' and type 'const Right' in operation
  …\test\crypto_tests.cpp(535): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
  …\test\script_tests.cpp(188): warning C4805: '==': unsafe mix of type 'int' and type 'bool' in operation
  …\test\script_tests.cpp(190): warning C4805: '==': unsafe mix of type 'int' and type 'bool' in operation
  …\test\script_tests.cpp(191): warning C4805: '==': unsafe mix of type 'int' and type 'bool' in operation
  $
  ```

  After:

  ```
  $ msbuild /p:TrackFileAccess=false /p:CLToolExe=clcache.exe build_msvc\bitcoin.sln /m /v:q /nowarn:C4244;C4267;C4715;C4805 /nologo
  $
  ```

Tree-SHA512: 5b30334d3804e869779e77dad75a799e8e5e7eb2e08634cd40035cce140edd623cbb6c8b5806d2158c3df97888d3ea9ff4b8b6a5a83de3fe2cb361e29588c115
Latest commit 19c60ca Jan 16, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
data blockfilter: Omit empty scripts from filter contents. Aug 28, 2018
gen Integration of property based testing into Bitcoin Core Aug 27, 2018
Makefile build: add stub makefiles for easier subdir builds Jun 5, 2014
README.md scripted-diff: Remove trailing whitespaces Jul 24, 2018
addrman_tests.cpp Use C++11 default member initializers Jan 5, 2019
allocator_tests.cpp Merge #14151: windows: Fix remaining compiler warnings (MSVC) Jan 16, 2019
amount_tests.cpp Improve CAmount tests Oct 10, 2018
arith_uint256_tests.cpp Update copyright headers to 2018 Jul 27, 2018
base32_tests.cpp scripted-diff: Move util files to separate directory. Nov 5, 2018
base58_tests.cpp scripted-diff: Move util files to separate directory. Nov 5, 2018
base64_tests.cpp scripted-diff: Move util files to separate directory. Nov 5, 2018
bech32_tests.cpp Merge #12881: Minor optimizations to bech32::Decode(); add tests. May 15, 2018
bip32_tests.cpp scripted-diff: Move util files to separate directory. Nov 5, 2018
blockchain_tests.cpp rpc: Specify chain tip instead of chain in GetDifficulty Sep 9, 2018
blockencodings_tests.cpp test: Add missing validation locks Dec 17, 2018
blockfilter_tests.cpp blockfilter: Additional constructors for BlockFilter. Nov 6, 2018
bloom_tests.cpp scripted-diff: Move util files to separate directory. Nov 5, 2018
bswap_tests.cpp Update copyright headers to 2018 Jul 27, 2018
checkqueue_tests.cpp Fix cuckoocache_tests TSAN failure introduced in #14935. Fixes #14967. Dec 15, 2018
coins_tests.cpp tests: Test for expected return values when calling functions returni… Dec 13, 2018
compress_tests.cpp scripted-diff: Move util files to separate directory. Nov 5, 2018
crypto_tests.cpp Fix remaining compiler warnings (MSVC). Move disabling of specific wa… Jan 15, 2019
cuckoocache_tests.cpp Fix cuckoocache_tests TSAN failure introduced in #14935. Fixes #14967. Dec 15, 2018
dbwrapper_tests.cpp tests: Test for expected return values when calling functions returni… Dec 13, 2018
denialofservice_tests.cpp Merge #14935: tests: Test for expected return values when calling fun… Dec 14, 2018
descriptor_tests.cpp Add comments to descriptor tests Nov 28, 2018
fs_tests.cpp tests: Add test case for std::ios_base::ate Sep 26, 2018
getarg_tests.cpp Merge #14599: Use functions guaranteed to be locale independent (IsDi… Jan 9, 2019
hash_tests.cpp Extract CSipHasher to it's own file in crypto/ directory. Nov 5, 2018
key_io_tests.cpp Update copyright headers to 2018 Dec 29, 2018
key_properties.cpp scripted-diff: Move util files to separate directory. Nov 5, 2018
key_tests.cpp tests: Test for expected return values when calling functions returni… Dec 13, 2018
limitedmap_tests.cpp Update copyright headers to 2018 Jul 27, 2018
main_tests.cpp Update copyright headers to 2018 Jul 27, 2018
mempool_tests.cpp test: Add missing validation locks Dec 17, 2018
merkle_tests.cpp Replace use of BEGIN and END macros on uint256 Jan 10, 2019
merkleblock_tests.cpp Update copyright headers to 2018 Jul 27, 2018
miner_tests.cpp test: Add missing validation locks Dec 17, 2018
multisig_tests.cpp tests: Test for expected return values when calling functions returni… Dec 13, 2018
net_tests.cpp Drop IsLimited in favor of IsReachable Jan 14, 2019
netbase_tests.cpp scripted-diff: Move util files to separate directory. Nov 5, 2018
pmt_tests.cpp Update copyright headers to 2018 Jul 27, 2018
policyestimator_tests.cpp test: Add missing validation locks Dec 17, 2018
pow_tests.cpp [doc] conf: Remove deprecated options from docs, Other cleanup Nov 7, 2018
prevector_tests.cpp Simplify testing RNG code Dec 12, 2018
raii_event_tests.cpp Update copyright headers to 2018 Jul 27, 2018
random_tests.cpp Bugfix: randbytes should seed when needed (non reachable issue) Dec 12, 2018
reverselock_tests.cpp Update copyright headers to 2018 Jul 27, 2018
rpc_tests.cpp rpc: Avoid creating non-standard raw transactions Dec 6, 2018
sanity_tests.cpp Update copyright headers to 2018 Jul 27, 2018
scheduler_tests.cpp scripted-diff: Replace boost::bind with std::bind Oct 19, 2018
script_p2sh_tests.cpp Use std::vector API for construction of test data. Jan 4, 2019
script_standard_tests.cpp tests: Test for expected return values when calling functions returni… Dec 13, 2018
script_tests.cpp Fix remaining compiler warnings (MSVC). Move disabling of specific wa… Jan 15, 2019
scriptnum10.h Update copyright headers to 2018 Jul 27, 2018
scriptnum_tests.cpp Update copyright headers to 2018 Jul 27, 2018
serialize_tests.cpp Use std::numeric_limits<UNSIGNED>::max()) instead of (UNSIGNED)-1 Dec 4, 2018
sighash_tests.cpp Removed implicit CTransaction constructor from tests Dec 12, 2018
sigopcount_tests.cpp Removed implicit CTransaction constructor from tests Dec 12, 2018
skiplist_tests.cpp Merge #14636: Avoid using numeric_limits for sequence numbers and loc… Nov 7, 2018
streams_tests.cpp streams: Remove unused seek(size_t) Nov 23, 2018
sync_tests.cpp scripted-diff: Small locking rename Aug 31, 2018
test_bitcoin.cpp Merge #13743: refactor: Replace boost::bind with std::bind Dec 29, 2018
test_bitcoin.h test: Add comment to g_insecure_rand_ctx Dec 17, 2018
test_bitcoin_fuzzy.cpp tests: Use MakeUnique to construct objects owned by unique_ptrs Sep 21, 2018
test_bitcoin_main.cpp Update copyright headers to 2018 Jul 27, 2018
timedata_tests.cpp Update copyright headers to 2018 Jul 27, 2018
torcontrol_tests.cpp Declare TorReply parsing functions in torcontrol_tests May 21, 2018
transaction_tests.cpp Merge #14855: test: Correct ineffectual WithOrVersion from transactio… Jan 4, 2019
txindex_tests.cpp Merge #14085: index: Fix for indexers skipping genesis block. Jan 9, 2019
txvalidation_tests.cpp Update copyright headers to 2018 Dec 29, 2018
txvalidationcache_tests.cpp tests: Test for expected return values when calling functions returni… Dec 13, 2018
uint256_tests.cpp Drop unused GetType() from CSizeComputer Sep 11, 2018
util_tests.cpp util: Make ToLower and ToUpper take a char Jan 10, 2019
validation_block_tests.cpp Merge #14811: Mining: Enforce that segwit option must be set in GBT Dec 21, 2018
versionbits_tests.cpp Update copyright headers to 2018 Jul 27, 2018

README.md

Compiling/running unit tests

Unit tests will be automatically compiled if dependencies were met in ./configure and tests weren't explicitly disabled.

After configuring, they can be run with make check.

To run the bitcoind tests manually, launch src/test/test_bitcoin. To recompile after a test file was modified, run make and then run the test again. If you modify a non-test file, use make -C src/test to recompile only what's needed to run the bitcoind tests.

To add more bitcoind tests, add BOOST_AUTO_TEST_CASE functions to the existing .cpp files in the test/ directory or add new .cpp files that implement new BOOST_AUTO_TEST_SUITE sections.

To run the bitcoin-qt tests manually, launch src/qt/test/test_bitcoin-qt

To add more bitcoin-qt tests, add them to the src/qt/test/ directory and the src/qt/test/test_main.cpp file.

Running individual tests

test_bitcoin has some built-in command-line arguments; for example, to run just the getarg_tests verbosely:

test_bitcoin --log_level=all --run_test=getarg_tests

... or to run just the doubledash test:

test_bitcoin --run_test=getarg_tests/doubledash

Run test_bitcoin --help for the full list.

Note on adding test cases

The sources in this directory are unit test cases. Boost includes a unit testing framework, and since bitcoin already uses boost, it makes sense to simply use this framework rather than require developers to configure some other framework (we want as few impediments to creating unit tests as possible).

The build system is setup to compile an executable called test_bitcoin that runs all of the unit tests. The main source file is called test_bitcoin.cpp. To add a new unit test file to our test suite you need to add the file to src/Makefile.test.include. The pattern is to create one test file for each class or source file for which you want to create unit tests. The file naming convention is <source_filename>_tests.cpp and such files should wrap their tests in a test suite called <source_filename>_tests. For an example of this pattern, examine uint256_tests.cpp.

For further reading, I found the following website to be helpful in explaining how the boost unit test framework works: http://www.alittlemadness.com/2009/03/31/c-unit-testing-with-boosttest/.