Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Copyright (c) 2009-2016 The Bitcoin Core developers
  2. // Distributed under the MIT software license, see the accompanying
  3. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. #if defined(HAVE_CONFIG_H)
  5. #include "config/bitcoin-config.h"
  6. #endif
  7. #include "chainparams.h"
  8. #include "rpcnestedtests.h"
  9. #include "util.h"
  10. #include "uritests.h"
  11. #include "compattests.h"
  12. #ifdef ENABLE_WALLET
  13. #include "paymentservertests.h"
  14. #include "wallettests.h"
  15. #endif
  16. #include <QApplication>
  17. #include <QObject>
  18. #include <QTest>
  19. #include <openssl/ssl.h>
  20. #if defined(QT_STATICPLUGIN)
  21. #include <QtPlugin>
  22. #if QT_VERSION < 0x050000
  23. Q_IMPORT_PLUGIN(qcncodecs)
  24. Q_IMPORT_PLUGIN(qjpcodecs)
  25. Q_IMPORT_PLUGIN(qtwcodecs)
  26. Q_IMPORT_PLUGIN(qkrcodecs)
  27. #else
  28. #if defined(QT_QPA_PLATFORM_MINIMAL)
  29. Q_IMPORT_PLUGIN(QMinimalIntegrationPlugin);
  30. #endif
  31. #if defined(QT_QPA_PLATFORM_XCB)
  32. Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
  33. #elif defined(QT_QPA_PLATFORM_WINDOWS)
  34. Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
  35. #elif defined(QT_QPA_PLATFORM_COCOA)
  36. Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
  37. #endif
  38. #endif
  39. #endif
  40. extern void noui_connect();
  41. // This is all you need to run all the tests
  42. int main(int argc, char *argv[])
  43. {
  44. SetupEnvironment();
  45. SetupNetworking();
  46. SelectParams(CBaseChainParams::MAIN);
  47. noui_connect();
  48. ClearDatadirCache();
  49. fs::path pathTemp = fs::temp_directory_path() / strprintf("test_bitcoin-qt_%lu_%i", (unsigned long)GetTime(), (int)GetRand(100000));
  50. fs::create_directories(pathTemp);
  51. gArgs.ForceSetArg("-datadir", pathTemp.string());
  52. bool fInvalid = false;
  53. // Prefer the "minimal" platform for the test instead of the normal default
  54. // platform ("xcb", "windows", or "cocoa") so tests can't unintentionally
  55. // interfere with any background GUIs and don't require extra resources.
  56. #if defined(WIN32)
  57. _putenv_s("QT_QPA_PLATFORM", "minimal");
  58. #else
  59. setenv("QT_QPA_PLATFORM", "minimal", 0);
  60. #endif
  61. // Don't remove this, it's needed to access
  62. // QApplication:: and QCoreApplication:: in the tests
  63. QApplication app(argc, argv);
  64. app.setApplicationName("Bitcoin-Qt-test");
  65. SSL_library_init();
  66. URITests test1;
  67. if (QTest::qExec(&test1) != 0) {
  68. fInvalid = true;
  69. }
  70. #ifdef ENABLE_WALLET
  71. PaymentServerTests test2;
  72. if (QTest::qExec(&test2) != 0) {
  73. fInvalid = true;
  74. }
  75. #endif
  76. RPCNestedTests test3;
  77. if (QTest::qExec(&test3) != 0) {
  78. fInvalid = true;
  79. }
  80. CompatTests test4;
  81. if (QTest::qExec(&test4) != 0) {
  82. fInvalid = true;
  83. }
  84. #ifdef ENABLE_WALLET
  85. WalletTests test5;
  86. if (QTest::qExec(&test5) != 0) {
  87. fInvalid = true;
  88. }
  89. #endif
  90. fs::remove_all(pathTemp);
  91. return fInvalid;
  92. }