tests: add a few try/catch in main to shut coverity up

This commit is contained in:
moneromooo-monero 2019-04-03 16:15:55 +00:00
parent 1ef3d05c4a
commit c5d3ea2fef
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
4 changed files with 15 additions and 0 deletions

View File

@ -36,6 +36,7 @@
#include <algorithm> #include <algorithm>
#include <stdexcept> #include <stdexcept>
#include "misc_log_ex.h"
#include "cryptonote_config.h" #include "cryptonote_config.h"
#include "cryptonote_basic/difficulty.h" #include "cryptonote_basic/difficulty.h"
@ -82,6 +83,8 @@ static int test_wide_difficulty(const char *filename)
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
TRY_ENTRY();
if (argc < 2) { if (argc < 2) {
cerr << "Wrong arguments" << endl; cerr << "Wrong arguments" << endl;
return 1; return 1;
@ -136,4 +139,6 @@ int main(int argc, char *argv[]) {
data.clear(fstream::badbit); data.clear(fstream::badbit);
} }
return 0; return 0;
CATCH_ENTRY_L0("main", 1);
} }

View File

@ -32,6 +32,7 @@
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <limits> #include <limits>
#include "misc_log_ex.h"
#include "crypto/hash.h" #include "crypto/hash.h"
#include "cryptonote_basic/difficulty.h" #include "cryptonote_basic/difficulty.h"
@ -39,6 +40,7 @@ using namespace std;
using cryptonote::check_hash; using cryptonote::check_hash;
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
TRY_ENTRY();
crypto::hash h; crypto::hash h;
for (cryptonote::difficulty_type diff = 1;; diff += 1 + (diff >> 8)) { for (cryptonote::difficulty_type diff = 1;; diff += 1 + (diff >> 8)) {
for (uint16_t b = 0; b < 256; b++) { for (uint16_t b = 0; b < 256; b++) {
@ -83,4 +85,5 @@ int main(int argc, char *argv[]) {
} }
} }
return 0; return 0;
CATCH_ENTRY_L0("main", 1);
} }

View File

@ -35,6 +35,7 @@
#include <string> #include <string>
#include <cfenv> #include <cfenv>
#include "misc_log_ex.h"
#include "warnings.h" #include "warnings.h"
#include "crypto/hash.h" #include "crypto/hash.h"
#include "crypto/variant2_int_sqrt.h" #include "crypto/variant2_int_sqrt.h"
@ -89,6 +90,8 @@ int test_variant2_int_sqrt();
int test_variant2_int_sqrt_ref(); int test_variant2_int_sqrt_ref();
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
TRY_ENTRY();
hash_f *f; hash_f *f;
hash_func *hf; hash_func *hf;
fstream input; fstream input;
@ -183,6 +186,7 @@ int main(int argc, char *argv[]) {
} }
} }
return error ? 1 : 0; return error ? 1 : 0;
CATCH_ENTRY_L0("main", 1);
} }
#if defined(__x86_64__) || (defined(_MSC_VER) && defined(_WIN64)) #if defined(__x86_64__) || (defined(_MSC_VER) && defined(_WIN64))

View File

@ -1139,6 +1139,8 @@ TEST_F(WalletManagerMainnetTest, RecoverAndRefreshWalletMainNetAsync)
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
TRY_ENTRY();
tools::on_startup(); tools::on_startup();
// we can override default values for "TESTNET_DAEMON_ADDRESS" and "WALLETS_ROOT_DIR" // we can override default values for "TESTNET_DAEMON_ADDRESS" and "WALLETS_ROOT_DIR"
@ -1173,4 +1175,5 @@ int main(int argc, char** argv)
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
Monero::WalletManagerFactory::setLogLevel(Monero::WalletManagerFactory::LogLevel_Max); Monero::WalletManagerFactory::setLogLevel(Monero::WalletManagerFactory::LogLevel_Max);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
CATCH_ENTRY_L0("main", 1);
} }