diff options
author | fanquake <fanquake@gmail.com> | 2021-06-07 13:20:11 +0800 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2021-06-07 13:20:57 +0800 |
commit | 791f985a60726febca3053453c2710407529fd0a (patch) | |
tree | 4cf1aa3e8e53f239e96abd857a78917357fb8e95 /src/test | |
parent | 260b1d74fee17b64f7a69eca30e4811b961325b5 (diff) | |
parent | fa910b47656d0e69cccb1f31804f2b11aa45d053 (diff) | |
download | bitcoin-791f985a60726febca3053453c2710407529fd0a.tar.xz |
Merge bitcoin/bitcoin#22137: util: Properly handle -noincludeconf on command line (take 2)
fa910b47656d0e69cccb1f31804f2b11aa45d053 util: Properly handle -noincludeconf on command line (MarcoFalke)
Pull request description:
Before:
```
$ ./src/qt/bitcoin-qt -noincludeconf
(memory violation, can be observed with valgrind or similar)
```
After:
```
$ ./src/qt/bitcoin-qt -noincludeconf
(passes startup)
```
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34884
ACKs for top commit:
practicalswift:
cr ACK fa910b47656d0e69cccb1f31804f2b11aa45d053: patch looks correct
ryanofsky:
Code review ACK fa910b47656d0e69cccb1f31804f2b11aa45d053. Nice cleanups!
Tree-SHA512: 5dfad82a78bca7a9a6bcc6aead2d7fbde166a09a5300a82f80dd1aee1de00e070bcb30b7472741a5396073b370898696e78c33038f94849219281d99358248ed
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/util_tests.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index d463bcdd8e..7ce38519cf 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -329,6 +329,25 @@ BOOST_FIXTURE_TEST_CASE(util_CheckValue, CheckValueTest) CheckValue(M::ALLOW_ANY, "-value=abc", Expect{"abc"}.String("abc").Int(0).Bool(false).List({"abc"})); } +struct NoIncludeConfTest { + std::string Parse(const char* arg) + { + TestArgsManager test; + test.SetupArgs({{"-includeconf", ArgsManager::ALLOW_ANY}}); + std::array argv{"ignored", arg}; + std::string error; + (void)test.ParseParameters(argv.size(), argv.data(), error); + return error; + } +}; + +BOOST_FIXTURE_TEST_CASE(util_NoIncludeConf, NoIncludeConfTest) +{ + BOOST_CHECK_EQUAL(Parse("-noincludeconf"), ""); + BOOST_CHECK_EQUAL(Parse("-includeconf"), "-includeconf cannot be used from commandline; -includeconf=\"\""); + BOOST_CHECK_EQUAL(Parse("-includeconf=file"), "-includeconf cannot be used from commandline; -includeconf=\"file\""); +} + BOOST_AUTO_TEST_CASE(util_ParseParameters) { TestArgsManager testArgs; |