aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2022-02-03 15:49:58 +0100
committerMarcoFalke <falke.marco@gmail.com>2022-02-03 15:50:10 +0100
commit3ace3a17c9bce606cea05192f0da3ac62ac69dda (patch)
tree3309668b659ef00da739bfb2e1f5eb2f78796f9c /src/test
parentc194293883fbb656779102309b2cb3e60889feff (diff)
parent07269321f38e46e9e02f16d7cd135ea90692638d (diff)
Merge bitcoin/bitcoin#20744: Use std::filesystem. Remove Boost Filesystem & System
07269321f38e46e9e02f16d7cd135ea90692638d build: remove Boost::system usage (fanquake) b87f9c5edf3895df9650131fcf8551c3ad1d7301 build: remove boost::filesystem usage (Kiminuo) 41d7166c8a598b604aad6c6b1d88ad46e23be247 refactor: replace boost::filesystem with std::filesystem (Kiminuo) ffc89d1f21258553c0087b774a9ea1ce84139d4f build: add support for std::filesystem (fanquake) Pull request description: This PR replaces our Boost Filesystem usage with [`std::filesystem`](https://en.cppreference.com/w/cpp/filesystem) and includes dropping Boost System as a dependency. It includes a squashed down version of the changes from #19245. [A macro has been added](https://github.com/bitcoin/bitcoin/commit/7002c4ade0148c3273659208ae517b79822b289d), modelling how we check for `-latomic` to facilitate linking with `-lstdc++fs` when required. This is ~GCC < 9.1 & ~Clang < 9.0, however not always. i.e you could be using Clang 7 on top of a GCC 9 installation (i.e Ubuntu Focal) and use `<filesystem>` without passing any additional arguments. I've tested this with GCC 8 on Bionic, Clang 7 on Focal & with Apple Clang 12.0.0 on macOS. Guix build: ```bash bash-5.1# find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum c1f9b326f9be4140f00cebeae5ff8de428a2fb8ecced539fcc36c53f53bfecf4 guix-build-07269321f38e/output/aarch64-linux-gnu/SHA256SUMS.part b44aca3bcf5ea92a3a6c48c24d6f85576f425f59b73528d4d00c20e950cf2128 guix-build-07269321f38e/output/aarch64-linux-gnu/bitcoin-07269321f38e-aarch64-linux-gnu-debug.tar.gz 27a5553f7bd14797293fc40c5fb131c91e98a61d5481a283f13a1d0497eb5ed8 guix-build-07269321f38e/output/aarch64-linux-gnu/bitcoin-07269321f38e-aarch64-linux-gnu.tar.gz 99e55a88823f6095864a09c9eaa824e24d9ec527380eb394f751c7205b930f69 guix-build-07269321f38e/output/arm-linux-gnueabihf/SHA256SUMS.part b720b2724fa47fde584f58ed3b587f1d1183523540777fd367ab7e582605cfea guix-build-07269321f38e/output/arm-linux-gnueabihf/bitcoin-07269321f38e-arm-linux-gnueabihf-debug.tar.gz c19c247f4e9e0d7f888ac8ba9de1c12d382f48fa828a685d4fe02818a18abd1f guix-build-07269321f38e/output/arm-linux-gnueabihf/bitcoin-07269321f38e-arm-linux-gnueabihf.tar.gz 55b49ccb38de03bb95101354a16fd8d2190abede5ccc0d9b00b40c0cd526a2f6 guix-build-07269321f38e/output/arm64-apple-darwin/SHA256SUMS.part baa44752470a6be9acae1c2f8fd1b9bc37afb00971787ea11fbaeddc9ab7c4aa guix-build-07269321f38e/output/arm64-apple-darwin/bitcoin-07269321f38e-arm64-apple-darwin.tar.gz ad7df4d8026d5bcce1321cdccc2e1820e8a8bb7e1064ed16e20a7ea354057fd2 guix-build-07269321f38e/output/arm64-apple-darwin/bitcoin-07269321f38e-osx-unsigned.dmg f342066dc34a14d67c47779a2413a14633a996e8e7ddca89ae0184e23ef99efd guix-build-07269321f38e/output/arm64-apple-darwin/bitcoin-07269321f38e-osx-unsigned.tar.gz f6905346a5d48f57805fb062d0247ab5007c89047070a0b3125941dd1a2b8aa6 guix-build-07269321f38e/output/dist-archive/bitcoin-07269321f38e.tar.gz a1f6c4b2b118dbd89770801f0bcffd2218b82df408cd227e34c40493469bb7a2 guix-build-07269321f38e/output/powerpc64-linux-gnu/SHA256SUMS.part ba8359426e523bf013d93579c1bedc57380214c8170a9743b64ec1a8a3bbccbf guix-build-07269321f38e/output/powerpc64-linux-gnu/bitcoin-07269321f38e-powerpc64-linux-gnu-debug.tar.gz b0bb500c274a683ea28ecbc1e8f18c618a9f8acb00045f80ae43c515288402c0 guix-build-07269321f38e/output/powerpc64-linux-gnu/bitcoin-07269321f38e-powerpc64-linux-gnu.tar.gz 38c85e9589e092cd3aa08996aa383c0ccd5c73208943389741355a6eb7f72537 guix-build-07269321f38e/output/powerpc64le-linux-gnu/SHA256SUMS.part 50fcba7942ff48d91e84c093fda0affc17e46167fe1d5137c6e14c5c41f289d1 guix-build-07269321f38e/output/powerpc64le-linux-gnu/bitcoin-07269321f38e-powerpc64le-linux-gnu-debug.tar.gz fa08ef1ceca072e014faa95ffee945954b2976fa28f90926b87ab0e5f15f8ca5 guix-build-07269321f38e/output/powerpc64le-linux-gnu/bitcoin-07269321f38e-powerpc64le-linux-gnu.tar.gz e52dd80a9c306d6aeb544acaa1f4ed560b6b92b5184764a05026d45451aa2e94 guix-build-07269321f38e/output/riscv64-linux-gnu/SHA256SUMS.part 864e0a16c485b4159cec3ee0a83b046f1b1c3bc821670011c5ac5cd09ddfb91f guix-build-07269321f38e/output/riscv64-linux-gnu/bitcoin-07269321f38e-riscv64-linux-gnu-debug.tar.gz 4a061172181322e7ad0cf06405bf74f4c8683eaba3a67ecfd46158cba7627f62 guix-build-07269321f38e/output/riscv64-linux-gnu/bitcoin-07269321f38e-riscv64-linux-gnu.tar.gz 876d82251853205420dffe7237523fc6ee3d09f78bf74cc03dc71f548446f335 guix-build-07269321f38e/output/x86_64-apple-darwin/SHA256SUMS.part 3f82b2e62c60eee68e7b8fc28e4792e069e3c2cd780ee2d67290ca422cdbc47c guix-build-07269321f38e/output/x86_64-apple-darwin/bitcoin-07269321f38e-osx-unsigned.dmg 4ccdd4c410cac9d627e54ce83ee4816608681735da3cb93c60c5eb70ca86337a guix-build-07269321f38e/output/x86_64-apple-darwin/bitcoin-07269321f38e-osx-unsigned.tar.gz 2179d36b2f60e28c15262d4e51f27465b5ae077f60e550345e125683ca611066 guix-build-07269321f38e/output/x86_64-apple-darwin/bitcoin-07269321f38e-osx64.tar.gz b377e72fe84b6a982b8d414d60c85e6319523dff50dc852a0ba907f6d850ddd0 guix-build-07269321f38e/output/x86_64-linux-gnu/SHA256SUMS.part 8547e2f582ce05ae6a6224793b64efb2eb63f2816bf0bed5d53fcc4786274597 guix-build-07269321f38e/output/x86_64-linux-gnu/bitcoin-07269321f38e-x86_64-linux-gnu-debug.tar.gz 83b64805aa39f31a6fa4c2ed41e029c3be084e6dea06b90fac1ebca5c95bce29 guix-build-07269321f38e/output/x86_64-linux-gnu/bitcoin-07269321f38e-x86_64-linux-gnu.tar.gz ``` ACKs for top commit: laanwj: Code review ACK 07269321f38e46e9e02f16d7cd135ea90692638d MarcoFalke: Concept ACK 07269321f38e46e9e02f16d7cd135ea90692638d 🎀 hebasto: ACK 07269321f38e46e9e02f16d7cd135ea90692638d Tree-SHA512: 1f11614467d2013ed799f23c1c14716570f4c798f231671c731a69c7773ef32a0aa2acc69d4ac2f1f176ef6f160f56566c6bd75c9c059a0e82ab4c58d2b2a750
Diffstat (limited to 'src/test')
-rw-r--r--src/test/fs_tests.cpp18
-rw-r--r--src/test/fuzz/fuzz.cpp6
-rw-r--r--src/test/fuzz/utxo_snapshot.cpp1
-rw-r--r--src/test/script_tests.cpp5
-rw-r--r--src/test/settings_tests.cpp8
-rw-r--r--src/test/streams_tests.cpp1
-rw-r--r--src/test/util_tests.cpp4
7 files changed, 32 insertions, 11 deletions
diff --git a/src/test/fs_tests.cpp b/src/test/fs_tests.cpp
index d3389c30eb..1256395849 100644
--- a/src/test/fs_tests.cpp
+++ b/src/test/fs_tests.cpp
@@ -9,6 +9,10 @@
#include <boost/test/unit_test.hpp>
+#include <fstream>
+#include <ios>
+#include <string>
+
BOOST_FIXTURE_TEST_SUITE(fs_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(fsbridge_pathtostring)
@@ -45,37 +49,37 @@ BOOST_AUTO_TEST_CASE(fsbridge_fstream)
fs::path tmpfile1 = tmpfolder / "fs_tests_₿_🏃";
fs::path tmpfile2 = tmpfolder / "fs_tests_₿_🏃";
{
- fsbridge::ofstream file(tmpfile1);
+ std::ofstream file{tmpfile1};
file << "bitcoin";
}
{
- fsbridge::ifstream file(tmpfile2);
+ std::ifstream file{tmpfile2};
std::string input_buffer;
file >> input_buffer;
BOOST_CHECK_EQUAL(input_buffer, "bitcoin");
}
{
- fsbridge::ifstream file(tmpfile1, std::ios_base::in | std::ios_base::ate);
+ std::ifstream file{tmpfile1, std::ios_base::in | std::ios_base::ate};
std::string input_buffer;
file >> input_buffer;
BOOST_CHECK_EQUAL(input_buffer, "");
}
{
- fsbridge::ofstream file(tmpfile2, std::ios_base::out | std::ios_base::app);
+ std::ofstream file{tmpfile2, std::ios_base::out | std::ios_base::app};
file << "tests";
}
{
- fsbridge::ifstream file(tmpfile1);
+ std::ifstream file{tmpfile1};
std::string input_buffer;
file >> input_buffer;
BOOST_CHECK_EQUAL(input_buffer, "bitcointests");
}
{
- fsbridge::ofstream file(tmpfile2, std::ios_base::out | std::ios_base::trunc);
+ std::ofstream file{tmpfile2, std::ios_base::out | std::ios_base::trunc};
file << "bitcoin";
}
{
- fsbridge::ifstream file(tmpfile1);
+ std::ifstream file{tmpfile1};
std::string input_buffer;
file >> input_buffer;
BOOST_CHECK_EQUAL(input_buffer, "bitcoin");
diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp
index 60c48e7c22..a490bbfa1d 100644
--- a/src/test/fuzz/fuzz.cpp
+++ b/src/test/fuzz/fuzz.cpp
@@ -4,6 +4,7 @@
#include <test/fuzz/fuzz.h>
+#include <fs.h>
#include <netaddress.h>
#include <netbase.h>
#include <test/util/setup_common.h>
@@ -12,9 +13,12 @@
#include <cstdint>
#include <exception>
+#include <fstream>
#include <functional>
+#include <map>
#include <memory>
#include <string>
+#include <tuple>
#include <unistd.h>
#include <vector>
@@ -80,7 +84,7 @@ void initialize()
}
if (const char* out_path = std::getenv("WRITE_ALL_FUZZ_TARGETS_AND_ABORT")) {
std::cout << "Writing all fuzz target names to '" << out_path << "'." << std::endl;
- fsbridge::ofstream out_stream{out_path, std::ios::binary};
+ std::ofstream out_stream{out_path, std::ios::binary};
for (const auto& t : FuzzTargets()) {
if (std::get<2>(t.second)) continue;
out_stream << t.first << std::endl;
diff --git a/src/test/fuzz/utxo_snapshot.cpp b/src/test/fuzz/utxo_snapshot.cpp
index 19ca1f0c99..e513f1883c 100644
--- a/src/test/fuzz/utxo_snapshot.cpp
+++ b/src/test/fuzz/utxo_snapshot.cpp
@@ -4,6 +4,7 @@
#include <chainparams.h>
#include <consensus/validation.h>
+#include <fs.h>
#include <node/utxo_snapshot.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index 4906bd2386..c453f22594 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -24,7 +24,8 @@
#include <script/bitcoinconsensus.h>
#endif
-#include <stdint.h>
+#include <cstdint>
+#include <fstream>
#include <string>
#include <vector>
@@ -1727,7 +1728,7 @@ BOOST_AUTO_TEST_CASE(script_assets_test)
bool exists = fs::exists(path);
BOOST_WARN_MESSAGE(exists, "File $DIR_UNIT_TEST_DATA/script_assets_test.json not found, skipping script_assets_test");
if (!exists) return;
- fs::ifstream file(path);
+ std::ifstream file{path};
BOOST_CHECK(file.is_open());
file.seekg(0, std::ios::end);
size_t length = file.tellg();
diff --git a/src/test/settings_tests.cpp b/src/test/settings_tests.cpp
index 3c6e31d311..15ffd068c7 100644
--- a/src/test/settings_tests.cpp
+++ b/src/test/settings_tests.cpp
@@ -4,6 +4,7 @@
#include <util/settings.h>
+#include <fs.h>
#include <test/util/setup_common.h>
#include <test/util/str.h>
@@ -13,6 +14,11 @@
#include <util/strencodings.h>
#include <util/string.h>
#include <util/system.h>
+
+#include <fstream>
+#include <map>
+#include <string>
+#include <system_error>
#include <vector>
inline bool operator==(const util::SettingsValue& a, const util::SettingsValue& b)
@@ -36,7 +42,7 @@ inline std::ostream& operator<<(std::ostream& os, const std::pair<std::string, u
inline void WriteText(const fs::path& path, const std::string& text)
{
- fsbridge::ofstream file;
+ std::ofstream file;
file.open(path);
file << text;
}
diff --git a/src/test/streams_tests.cpp b/src/test/streams_tests.cpp
index af0f86274e..6a69fe9840 100644
--- a/src/test/streams_tests.cpp
+++ b/src/test/streams_tests.cpp
@@ -2,6 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include <fs.h>
#include <streams.h>
#include <test/util/setup_common.h>
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index 20d27a237d..b6479efe7d 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -5,6 +5,7 @@
#include <util/system.h>
#include <clientversion.h>
+#include <fs.h>
#include <hash.h> // For Hash()
#include <key.h> // For CKey
#include <sync.h>
@@ -70,9 +71,12 @@ BOOST_AUTO_TEST_CASE(util_datadir)
args.ClearPathCache();
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
+#ifndef WIN32
+ // Windows does not consider "datadir/.//" to be a valid directory path.
args.ForceSetArg("-datadir", fs::PathToString(dd_norm) + "/.//");
args.ClearPathCache();
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
+#endif
}
BOOST_AUTO_TEST_CASE(util_check)