-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Fix locale fallback and guard tests against invalid locale settings #5950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix locale fallback and guard tests against invalid locale settings #5950
Conversation
The scope of `std::locale::global` appears to be smaller than `setenv("LC_ALL", ...)` and insufficient to fix messed up locale settings for the whole application.
|
This appears to revert part of #5877. Can you add a concrete test case for this? This more and more looks like just some occult incantation to ward off the evil spirits of bad locales :) |
src/test/test_bitcoin.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Wrong indentation, also true for bitdb.MakeMock(); below.
The environment is prepared by the main thread to guard against invalid locale settings and to prevent deinitialization issues of Boost path, which can result in app crashes.
The environment is prepared by the main thread to guard against invalid locale settings.
c2ce063 to
3a3ecc0
Compare
|
@laanwj: Yeah, I'm truely sorry.. :/ I focused on addressing the deinitialization issue, which caused the crashes on Windows, probably with two steps forward, where only one was appropriate, as it seems. I further moved The RPC test is available here: Travis build with the test, based on unfixed master (with delayed error assertion): Travis build with the test, based on the 0.10 branch: Travis build with the test, based on this pull request: May I add the test to @Diapolo: I'd be happy to format |
Sure! Although I'd prefer making the test consume less time, and adding it to the pull tester. What is so time consuming? The environment setup is one of the first things it does, after all, so at least in theory it could be a matter of quickly invoking the executables. In any case you've convinced me enough to merge this, adding the test could be a further PR. |
The test is probably far away from being optimal. :) While Edit: |
|
RE: making the test faster: you can run just one bitcoind test suites or test cases using test_bitcoin --run_test=FOO (run all tests in FOO test suite) or --run_test=FOO/BAR (run the BAR test in the FOO test suite). I believe multiple --run_test's can be given if you want to run more than one. |
|
@gavinandresen: thanks for the hint, this is very useful! But just to clarify: the errors were not visible right after starting the Boost tests, and not all tests fail, but only a few, which use |
|
Yes, may be good idea
|
Unfortually a fallback to "C" locale via
std::locale::globaldoes not cover all scenarios with messed up environment locale settings and on Ubuntu 14.01 (withLANG=en_US.UTF-8, LANGUAGE=en_US, LC_* empty) settingLANG=invalidtriggers a crash right at the start ofbitcoindandbitcoin-qt.This also affects
test_bitcoinandtest_bitcoin-qt, which were not guarded at all.The PR expands the scope of the locale fallback and prevents crashes due to invalid locale settings of
bitcoind,bitcoin-qt,test_bitcoinandtest_bitcoin-qt. I didn't want to create a seperate PR for the 0.10 branch, but a conflict free version is available: 0.10...dexX7:0.10-init-locale-fallback-tests-fix