dash/src/test/fs_tests.cpp
Wladimir J. van der Laan 6a11e06372 Merge #17086: tests: Fix fs_tests for unknown locales
d48f664440e7bb3ff7a90b6d706a3ac2cfaec95a tests: Fix fs_tests for unknown locales (Daki Carnhof)

Pull request description:

  Fix by removing "L" as suggested by meeDamian in
  https://github.com/bitcoin/bitcoin/issues/14948#issuecomment-522355441

  ```
  # all in .../bitcoin/src/test
  $ uname -m
  x86_64
  $ export LC_ALL=randomnonexistentlocale
  $ ./test_bitcoin
  Running 369 test cases...
  unknown location(0): fatal error: in "fs_tests/fsbridge_fstream": boost::system::system_error: boost::filesystem::path codecvt to string: error
  test/fs_tests.cpp(13): last checkpoint: "fsbridge_fstream" test entry

  *** 1 failure is detected in the test module "Bitcoin Core Test Suite"
  ```

  After the patch is applied, the same test under the same conditions runs fine.

  ```
  $ export LC_ALL=randomnonexistentlocale
  $ ./test_bitcoin
  Running 369 test cases...

  *** No errors detected
  ```

  Co-Authored-By: bugs@meedamian.com

ACKs for top commit:
  laanwj:
    ACK d48f664440e7bb3ff7a90b6d706a3ac2cfaec95a

Tree-SHA512: a9910252b8ce6a05cab5530874549c2999ca2c28e835fc18aa8e5468fb417bd7d245864ec71d9233dd53e02940a9f0691b247430257f27eb0d7c20745d1c846d
2021-06-24 23:43:05 +05:30

57 lines
1.6 KiB
C++

// Copyright (c) 2011-2018 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 <fs.h>
#include <test/test_dash.h>
#include <boost/test/unit_test.hpp>
BOOST_FIXTURE_TEST_SUITE(fs_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(fsbridge_fstream)
{
fs::path tmpfolder = SetDataDir("fsbridge_fstream");
// tmpfile1 should be the same as tmpfile2
fs::path tmpfile1 = tmpfolder / "fs_tests_₿_🏃";
fs::path tmpfile2 = tmpfolder / "fs_tests_₿_🏃";
{
fsbridge::ofstream file(tmpfile1);
file << "bitcoin";
}
{
fsbridge::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::string input_buffer;
file >> input_buffer;
BOOST_CHECK_EQUAL(input_buffer, "");
}
{
fsbridge::ofstream file(tmpfile2, std::ios_base::out | std::ios_base::app);
file << "tests";
}
{
fsbridge::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);
file << "bitcoin";
}
{
fsbridge::ifstream file(tmpfile1);
std::string input_buffer;
file >> input_buffer;
BOOST_CHECK_EQUAL(input_buffer, "bitcoin");
}
}
BOOST_AUTO_TEST_SUITE_END()