2018-01-07 05:05:16 +00:00
// Copyright (c) 2014-2018, The Monero Project
2014-07-23 13:03:52 +00:00
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
2014-03-03 22:07:58 +00:00
# include "chaingen.h"
# include "chaingen_tests_list.h"
2018-07-06 18:10:39 +00:00
# include "common/util.h"
2014-03-03 22:07:58 +00:00
# include "common/command_line.h"
# include "transaction_tests.h"
namespace po = boost : : program_options ;
namespace
{
const command_line : : arg_descriptor < std : : string > arg_test_data_path = { " test_data_path " , " " , " " } ;
const command_line : : arg_descriptor < bool > arg_generate_test_data = { " generate_test_data " , " " } ;
const command_line : : arg_descriptor < bool > arg_play_test_data = { " play_test_data " , " " } ;
const command_line : : arg_descriptor < bool > arg_generate_and_play_test_data = { " generate_and_play_test_data " , " " } ;
const command_line : : arg_descriptor < bool > arg_test_transactions = { " test_transactions " , " " } ;
2018-07-06 18:10:39 +00:00
const command_line : : arg_descriptor < std : : string > arg_filter = { " filter " , " Regular expression filter for which tests to run " } ;
2014-03-03 22:07:58 +00:00
}
int main ( int argc , char * argv [ ] )
{
TRY_ENTRY ( ) ;
2017-10-21 09:09:51 +00:00
tools : : on_startup ( ) ;
2014-05-25 17:06:40 +00:00
epee : : string_tools : : set_module_name_and_folder ( argv [ 0 ] ) ;
2014-03-03 22:07:58 +00:00
//set up logging options
Change logging to easylogging++
This replaces the epee and data_loggers logging systems with
a single one, and also adds filename:line and explicit severity
levels. Categories may be defined, and logging severity set
by category (or set of categories). epee style 0-4 log level
maps to a sensible severity configuration. Log files now also
rotate when reaching 100 MB.
To select which logs to output, use the MONERO_LOGS environment
variable, with a comma separated list of categories (globs are
supported), with their requested severity level after a colon.
If a log matches more than one such setting, the last one in
the configuration string applies. A few examples:
This one is (mostly) silent, only outputting fatal errors:
MONERO_LOGS=*:FATAL
This one is very verbose:
MONERO_LOGS=*:TRACE
This one is totally silent (logwise):
MONERO_LOGS=""
This one outputs all errors and warnings, except for the
"verify" category, which prints just fatal errors (the verify
category is used for logs about incoming transactions and
blocks, and it is expected that some/many will fail to verify,
hence we don't want the spam):
MONERO_LOGS=*:WARNING,verify:FATAL
Log levels are, in decreasing order of priority:
FATAL, ERROR, WARNING, INFO, DEBUG, TRACE
Subcategories may be added using prefixes and globs. This
example will output net.p2p logs at the TRACE level, but all
other net* logs only at INFO:
MONERO_LOGS=*:ERROR,net*:INFO,net.p2p:TRACE
Logs which are intended for the user (which Monero was using
a lot through epee, but really isn't a nice way to go things)
should use the "global" category. There are a few helper macros
for using this category, eg: MGINFO("this shows up by default")
or MGINFO_RED("this is red"), to try to keep a similar look
and feel for now.
Existing epee log macros still exist, and map to the new log
levels, but since they're used as a "user facing" UI element
as much as a logging system, they often don't map well to log
severities (ie, a log level 0 log may be an error, or may be
something we want the user to see, such as an important info).
In those cases, I tried to use the new macros. In other cases,
I left the existing macros in. When modifying logs, it is
probably best to switch to the new macros with explicit levels.
The --log-level options and set_log commands now also accept
category settings, in addition to the epee style log levels.
2017-01-01 16:34:23 +00:00
mlog_configure ( mlog_get_default_log_path ( " core_tests.log " ) , true ) ;
2017-01-28 09:02:19 +00:00
mlog_set_log_level ( 2 ) ;
2014-03-03 22:07:58 +00:00
po : : options_description desc_options ( " Allowed options " ) ;
command_line : : add_arg ( desc_options , command_line : : arg_help ) ;
command_line : : add_arg ( desc_options , arg_test_data_path ) ;
command_line : : add_arg ( desc_options , arg_generate_test_data ) ;
command_line : : add_arg ( desc_options , arg_play_test_data ) ;
command_line : : add_arg ( desc_options , arg_generate_and_play_test_data ) ;
command_line : : add_arg ( desc_options , arg_test_transactions ) ;
2018-07-06 18:10:39 +00:00
command_line : : add_arg ( desc_options , arg_filter ) ;
2014-03-03 22:07:58 +00:00
po : : variables_map vm ;
bool r = command_line : : handle_error_helper ( desc_options , [ & ] ( )
{
po : : store ( po : : parse_command_line ( argc , argv , desc_options ) , vm ) ;
po : : notify ( vm ) ;
return true ;
} ) ;
if ( ! r )
return 1 ;
if ( command_line : : get_arg ( vm , command_line : : arg_help ) )
{
std : : cout < < desc_options < < std : : endl ;
return 0 ;
}
2018-07-06 18:10:39 +00:00
const std : : string filter = tools : : glob_to_regex ( command_line : : get_arg ( vm , arg_filter ) ) ;
boost : : smatch match ;
2014-03-03 22:07:58 +00:00
size_t tests_count = 0 ;
std : : vector < std : : string > failed_tests ;
std : : string tests_folder = command_line : : get_arg ( vm , arg_test_data_path ) ;
if ( command_line : : get_arg ( vm , arg_generate_test_data ) )
{
GENERATE ( " chain001.dat " , gen_simple_chain_001 ) ;
}
else if ( command_line : : get_arg ( vm , arg_play_test_data ) )
{
PLAY ( " chain001.dat " , gen_simple_chain_001 ) ;
}
else if ( command_line : : get_arg ( vm , arg_generate_and_play_test_data ) )
{
GENERATE_AND_PLAY ( gen_simple_chain_001 ) ;
GENERATE_AND_PLAY ( gen_simple_chain_split_1 ) ;
GENERATE_AND_PLAY ( one_block ) ;
GENERATE_AND_PLAY ( gen_chain_switch_1 ) ;
GENERATE_AND_PLAY ( gen_ring_signature_1 ) ;
GENERATE_AND_PLAY ( gen_ring_signature_2 ) ;
//GENERATE_AND_PLAY(gen_ring_signature_big); // Takes up to XXX hours (if CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW == 10)
// Block verification tests
GENERATE_AND_PLAY ( gen_block_big_major_version ) ;
GENERATE_AND_PLAY ( gen_block_big_minor_version ) ;
GENERATE_AND_PLAY ( gen_block_ts_not_checked ) ;
GENERATE_AND_PLAY ( gen_block_ts_in_past ) ;
GENERATE_AND_PLAY ( gen_block_ts_in_future ) ;
GENERATE_AND_PLAY ( gen_block_invalid_prev_id ) ;
GENERATE_AND_PLAY ( gen_block_invalid_nonce ) ;
GENERATE_AND_PLAY ( gen_block_no_miner_tx ) ;
GENERATE_AND_PLAY ( gen_block_unlock_time_is_low ) ;
GENERATE_AND_PLAY ( gen_block_unlock_time_is_high ) ;
GENERATE_AND_PLAY ( gen_block_unlock_time_is_timestamp_in_past ) ;
GENERATE_AND_PLAY ( gen_block_unlock_time_is_timestamp_in_future ) ;
GENERATE_AND_PLAY ( gen_block_height_is_low ) ;
GENERATE_AND_PLAY ( gen_block_height_is_high ) ;
GENERATE_AND_PLAY ( gen_block_miner_tx_has_2_tx_gen_in ) ;
GENERATE_AND_PLAY ( gen_block_miner_tx_has_2_in ) ;
GENERATE_AND_PLAY ( gen_block_miner_tx_with_txin_to_key ) ;
GENERATE_AND_PLAY ( gen_block_miner_tx_out_is_small ) ;
GENERATE_AND_PLAY ( gen_block_miner_tx_out_is_big ) ;
GENERATE_AND_PLAY ( gen_block_miner_tx_has_no_out ) ;
GENERATE_AND_PLAY ( gen_block_miner_tx_has_out_to_alice ) ;
GENERATE_AND_PLAY ( gen_block_has_invalid_tx ) ;
GENERATE_AND_PLAY ( gen_block_is_too_big ) ;
GENERATE_AND_PLAY ( gen_block_invalid_binary_format ) ; // Takes up to 3 hours, if CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW == 500, up to 30 minutes, if CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW == 10
// Transaction verification tests
GENERATE_AND_PLAY ( gen_tx_big_version ) ;
GENERATE_AND_PLAY ( gen_tx_unlock_time ) ;
GENERATE_AND_PLAY ( gen_tx_input_is_not_txin_to_key ) ;
GENERATE_AND_PLAY ( gen_tx_no_inputs_no_outputs ) ;
GENERATE_AND_PLAY ( gen_tx_no_inputs_has_outputs ) ;
GENERATE_AND_PLAY ( gen_tx_has_inputs_no_outputs ) ;
GENERATE_AND_PLAY ( gen_tx_invalid_input_amount ) ;
GENERATE_AND_PLAY ( gen_tx_input_wo_key_offsets ) ;
GENERATE_AND_PLAY ( gen_tx_sender_key_offest_not_exist ) ;
GENERATE_AND_PLAY ( gen_tx_key_offest_points_to_foreign_key ) ;
GENERATE_AND_PLAY ( gen_tx_mixed_key_offest_not_exist ) ;
GENERATE_AND_PLAY ( gen_tx_key_image_not_derive_from_tx_key ) ;
GENERATE_AND_PLAY ( gen_tx_key_image_is_invalid ) ;
GENERATE_AND_PLAY ( gen_tx_check_input_unlock_time ) ;
GENERATE_AND_PLAY ( gen_tx_txout_to_key_has_invalid_key ) ;
GENERATE_AND_PLAY ( gen_tx_output_with_zero_amount ) ;
GENERATE_AND_PLAY ( gen_tx_output_is_not_txout_to_key ) ;
GENERATE_AND_PLAY ( gen_tx_signatures_are_invalid ) ;
// Double spend
GENERATE_AND_PLAY ( gen_double_spend_in_tx < false > ) ;
GENERATE_AND_PLAY ( gen_double_spend_in_tx < true > ) ;
GENERATE_AND_PLAY ( gen_double_spend_in_the_same_block < false > ) ;
GENERATE_AND_PLAY ( gen_double_spend_in_the_same_block < true > ) ;
GENERATE_AND_PLAY ( gen_double_spend_in_different_blocks < false > ) ;
GENERATE_AND_PLAY ( gen_double_spend_in_different_blocks < true > ) ;
GENERATE_AND_PLAY ( gen_double_spend_in_different_chains ) ;
GENERATE_AND_PLAY ( gen_double_spend_in_alt_chain_in_the_same_block < false > ) ;
GENERATE_AND_PLAY ( gen_double_spend_in_alt_chain_in_the_same_block < true > ) ;
GENERATE_AND_PLAY ( gen_double_spend_in_alt_chain_in_different_blocks < false > ) ;
GENERATE_AND_PLAY ( gen_double_spend_in_alt_chain_in_different_blocks < true > ) ;
GENERATE_AND_PLAY ( gen_uint_overflow_1 ) ;
GENERATE_AND_PLAY ( gen_uint_overflow_2 ) ;
GENERATE_AND_PLAY ( gen_block_reward ) ;
2016-02-08 18:47:56 +00:00
GENERATE_AND_PLAY ( gen_v2_tx_mixable_0_mixin ) ;
GENERATE_AND_PLAY ( gen_v2_tx_mixable_low_mixin ) ;
2016-05-01 18:40:14 +00:00
// GENERATE_AND_PLAY(gen_v2_tx_unmixable_only);
// GENERATE_AND_PLAY(gen_v2_tx_unmixable_one);
// GENERATE_AND_PLAY(gen_v2_tx_unmixable_two);
2016-02-08 18:47:56 +00:00
GENERATE_AND_PLAY ( gen_v2_tx_dust ) ;
2016-06-27 17:56:19 +00:00
GENERATE_AND_PLAY ( gen_rct_tx_valid_from_pre_rct ) ;
GENERATE_AND_PLAY ( gen_rct_tx_valid_from_rct ) ;
GENERATE_AND_PLAY ( gen_rct_tx_valid_from_mixed ) ;
GENERATE_AND_PLAY ( gen_rct_tx_pre_rct_bad_real_dest ) ;
GENERATE_AND_PLAY ( gen_rct_tx_pre_rct_bad_real_mask ) ;
GENERATE_AND_PLAY ( gen_rct_tx_pre_rct_bad_fake_dest ) ;
GENERATE_AND_PLAY ( gen_rct_tx_pre_rct_bad_fake_mask ) ;
GENERATE_AND_PLAY ( gen_rct_tx_rct_bad_real_dest ) ;
GENERATE_AND_PLAY ( gen_rct_tx_rct_bad_real_mask ) ;
GENERATE_AND_PLAY ( gen_rct_tx_rct_bad_fake_dest ) ;
GENERATE_AND_PLAY ( gen_rct_tx_rct_bad_fake_mask ) ;
GENERATE_AND_PLAY ( gen_rct_tx_rct_spend_with_zero_commit ) ;
GENERATE_AND_PLAY ( gen_rct_tx_pre_rct_zero_vin_amount ) ;
GENERATE_AND_PLAY ( gen_rct_tx_rct_non_zero_vin_amount ) ;
GENERATE_AND_PLAY ( gen_rct_tx_non_zero_vout_amount ) ;
GENERATE_AND_PLAY ( gen_rct_tx_pre_rct_duplicate_key_image ) ;
GENERATE_AND_PLAY ( gen_rct_tx_rct_duplicate_key_image ) ;
GENERATE_AND_PLAY ( gen_rct_tx_pre_rct_wrong_key_image ) ;
GENERATE_AND_PLAY ( gen_rct_tx_rct_wrong_key_image ) ;
GENERATE_AND_PLAY ( gen_rct_tx_pre_rct_wrong_fee ) ;
GENERATE_AND_PLAY ( gen_rct_tx_rct_wrong_fee ) ;
GENERATE_AND_PLAY ( gen_rct_tx_pre_rct_remove_vin ) ;
GENERATE_AND_PLAY ( gen_rct_tx_rct_remove_vin ) ;
GENERATE_AND_PLAY ( gen_rct_tx_pre_rct_add_vout ) ;
GENERATE_AND_PLAY ( gen_rct_tx_rct_add_vout ) ;
GENERATE_AND_PLAY ( gen_rct_tx_pre_rct_increase_vin_and_fee ) ;
2016-06-28 15:03:28 +00:00
GENERATE_AND_PLAY ( gen_rct_tx_pre_rct_altered_extra ) ;
GENERATE_AND_PLAY ( gen_rct_tx_rct_altered_extra ) ;
2016-06-27 17:56:19 +00:00
2017-09-26 22:16:25 +00:00
GENERATE_AND_PLAY ( gen_multisig_tx_valid_22_1_2 ) ;
2017-11-23 13:24:26 +00:00
GENERATE_AND_PLAY ( gen_multisig_tx_valid_22_1_2_many_inputs ) ;
2017-09-26 22:16:25 +00:00
GENERATE_AND_PLAY ( gen_multisig_tx_valid_22_2_1 ) ;
GENERATE_AND_PLAY ( gen_multisig_tx_valid_33_1_23 ) ;
GENERATE_AND_PLAY ( gen_multisig_tx_valid_33_3_21 ) ;
GENERATE_AND_PLAY ( gen_multisig_tx_valid_23_1_2 ) ;
GENERATE_AND_PLAY ( gen_multisig_tx_valid_23_1_3 ) ;
GENERATE_AND_PLAY ( gen_multisig_tx_valid_23_2_1 ) ;
GENERATE_AND_PLAY ( gen_multisig_tx_valid_23_2_3 ) ;
GENERATE_AND_PLAY ( gen_multisig_tx_valid_45_1_234 ) ;
2017-11-23 13:24:26 +00:00
GENERATE_AND_PLAY ( gen_multisig_tx_valid_45_4_135_many_inputs ) ;
2017-09-26 22:16:25 +00:00
GENERATE_AND_PLAY ( gen_multisig_tx_valid_89_3_1245789 ) ;
GENERATE_AND_PLAY ( gen_multisig_tx_invalid_23_1__no_threshold ) ;
GENERATE_AND_PLAY ( gen_multisig_tx_invalid_45_5_23_no_threshold ) ;
GENERATE_AND_PLAY ( gen_multisig_tx_invalid_22_1__no_threshold ) ;
GENERATE_AND_PLAY ( gen_multisig_tx_invalid_33_1__no_threshold ) ;
GENERATE_AND_PLAY ( gen_multisig_tx_invalid_33_1_2_no_threshold ) ;
GENERATE_AND_PLAY ( gen_multisig_tx_invalid_33_1_3_no_threshold ) ;
2018-03-30 19:29:42 +00:00
GENERATE_AND_PLAY ( gen_bp_tx_valid_1 ) ;
2018-03-31 09:49:53 +00:00
GENERATE_AND_PLAY ( gen_bp_tx_invalid_1_1 ) ;
2018-03-30 19:29:42 +00:00
GENERATE_AND_PLAY ( gen_bp_tx_valid_2 ) ;
GENERATE_AND_PLAY ( gen_bp_tx_valid_4_2_1 ) ;
GENERATE_AND_PLAY ( gen_bp_tx_valid_16_16 ) ;
GENERATE_AND_PLAY ( gen_bp_txs_valid_2_and_2 ) ;
2018-03-31 09:49:53 +00:00
GENERATE_AND_PLAY ( gen_bp_txs_valid_2_and_8_2_and_16_16_1 ) ;
2018-03-30 19:29:42 +00:00
GENERATE_AND_PLAY ( gen_bp_tx_invalid_not_enough_proofs ) ;
GENERATE_AND_PLAY ( gen_bp_tx_invalid_too_many_proofs ) ;
GENERATE_AND_PLAY ( gen_bp_tx_invalid_wrong_amount ) ;
GENERATE_AND_PLAY ( gen_bp_tx_invalid_switched ) ;
Change logging to easylogging++
This replaces the epee and data_loggers logging systems with
a single one, and also adds filename:line and explicit severity
levels. Categories may be defined, and logging severity set
by category (or set of categories). epee style 0-4 log level
maps to a sensible severity configuration. Log files now also
rotate when reaching 100 MB.
To select which logs to output, use the MONERO_LOGS environment
variable, with a comma separated list of categories (globs are
supported), with their requested severity level after a colon.
If a log matches more than one such setting, the last one in
the configuration string applies. A few examples:
This one is (mostly) silent, only outputting fatal errors:
MONERO_LOGS=*:FATAL
This one is very verbose:
MONERO_LOGS=*:TRACE
This one is totally silent (logwise):
MONERO_LOGS=""
This one outputs all errors and warnings, except for the
"verify" category, which prints just fatal errors (the verify
category is used for logs about incoming transactions and
blocks, and it is expected that some/many will fail to verify,
hence we don't want the spam):
MONERO_LOGS=*:WARNING,verify:FATAL
Log levels are, in decreasing order of priority:
FATAL, ERROR, WARNING, INFO, DEBUG, TRACE
Subcategories may be added using prefixes and globs. This
example will output net.p2p logs at the TRACE level, but all
other net* logs only at INFO:
MONERO_LOGS=*:ERROR,net*:INFO,net.p2p:TRACE
Logs which are intended for the user (which Monero was using
a lot through epee, but really isn't a nice way to go things)
should use the "global" category. There are a few helper macros
for using this category, eg: MGINFO("this shows up by default")
or MGINFO_RED("this is red"), to try to keep a similar look
and feel for now.
Existing epee log macros still exist, and map to the new log
levels, but since they're used as a "user facing" UI element
as much as a logging system, they often don't map well to log
severities (ie, a log level 0 log may be an error, or may be
something we want the user to see, such as an important info).
In those cases, I tried to use the new macros. In other cases,
I left the existing macros in. When modifying logs, it is
probably best to switch to the new macros with explicit levels.
The --log-level options and set_log commands now also accept
category settings, in addition to the epee style log levels.
2017-01-01 16:34:23 +00:00
el : : Level level = ( failed_tests . empty ( ) ? el : : Level : : Info : el : : Level : : Error ) ;
MLOG ( level , " \n REPORT: " ) ;
MLOG ( level , " Test run: " < < tests_count ) ;
MLOG ( level , " Failures: " < < failed_tests . size ( ) ) ;
2014-03-03 22:07:58 +00:00
if ( ! failed_tests . empty ( ) )
{
Change logging to easylogging++
This replaces the epee and data_loggers logging systems with
a single one, and also adds filename:line and explicit severity
levels. Categories may be defined, and logging severity set
by category (or set of categories). epee style 0-4 log level
maps to a sensible severity configuration. Log files now also
rotate when reaching 100 MB.
To select which logs to output, use the MONERO_LOGS environment
variable, with a comma separated list of categories (globs are
supported), with their requested severity level after a colon.
If a log matches more than one such setting, the last one in
the configuration string applies. A few examples:
This one is (mostly) silent, only outputting fatal errors:
MONERO_LOGS=*:FATAL
This one is very verbose:
MONERO_LOGS=*:TRACE
This one is totally silent (logwise):
MONERO_LOGS=""
This one outputs all errors and warnings, except for the
"verify" category, which prints just fatal errors (the verify
category is used for logs about incoming transactions and
blocks, and it is expected that some/many will fail to verify,
hence we don't want the spam):
MONERO_LOGS=*:WARNING,verify:FATAL
Log levels are, in decreasing order of priority:
FATAL, ERROR, WARNING, INFO, DEBUG, TRACE
Subcategories may be added using prefixes and globs. This
example will output net.p2p logs at the TRACE level, but all
other net* logs only at INFO:
MONERO_LOGS=*:ERROR,net*:INFO,net.p2p:TRACE
Logs which are intended for the user (which Monero was using
a lot through epee, but really isn't a nice way to go things)
should use the "global" category. There are a few helper macros
for using this category, eg: MGINFO("this shows up by default")
or MGINFO_RED("this is red"), to try to keep a similar look
and feel for now.
Existing epee log macros still exist, and map to the new log
levels, but since they're used as a "user facing" UI element
as much as a logging system, they often don't map well to log
severities (ie, a log level 0 log may be an error, or may be
something we want the user to see, such as an important info).
In those cases, I tried to use the new macros. In other cases,
I left the existing macros in. When modifying logs, it is
probably best to switch to the new macros with explicit levels.
The --log-level options and set_log commands now also accept
category settings, in addition to the epee style log levels.
2017-01-01 16:34:23 +00:00
MLOG ( level , " FAILED TESTS: " ) ;
2014-03-03 22:07:58 +00:00
BOOST_FOREACH ( auto test_name , failed_tests )
{
Change logging to easylogging++
This replaces the epee and data_loggers logging systems with
a single one, and also adds filename:line and explicit severity
levels. Categories may be defined, and logging severity set
by category (or set of categories). epee style 0-4 log level
maps to a sensible severity configuration. Log files now also
rotate when reaching 100 MB.
To select which logs to output, use the MONERO_LOGS environment
variable, with a comma separated list of categories (globs are
supported), with their requested severity level after a colon.
If a log matches more than one such setting, the last one in
the configuration string applies. A few examples:
This one is (mostly) silent, only outputting fatal errors:
MONERO_LOGS=*:FATAL
This one is very verbose:
MONERO_LOGS=*:TRACE
This one is totally silent (logwise):
MONERO_LOGS=""
This one outputs all errors and warnings, except for the
"verify" category, which prints just fatal errors (the verify
category is used for logs about incoming transactions and
blocks, and it is expected that some/many will fail to verify,
hence we don't want the spam):
MONERO_LOGS=*:WARNING,verify:FATAL
Log levels are, in decreasing order of priority:
FATAL, ERROR, WARNING, INFO, DEBUG, TRACE
Subcategories may be added using prefixes and globs. This
example will output net.p2p logs at the TRACE level, but all
other net* logs only at INFO:
MONERO_LOGS=*:ERROR,net*:INFO,net.p2p:TRACE
Logs which are intended for the user (which Monero was using
a lot through epee, but really isn't a nice way to go things)
should use the "global" category. There are a few helper macros
for using this category, eg: MGINFO("this shows up by default")
or MGINFO_RED("this is red"), to try to keep a similar look
and feel for now.
Existing epee log macros still exist, and map to the new log
levels, but since they're used as a "user facing" UI element
as much as a logging system, they often don't map well to log
severities (ie, a log level 0 log may be an error, or may be
something we want the user to see, such as an important info).
In those cases, I tried to use the new macros. In other cases,
I left the existing macros in. When modifying logs, it is
probably best to switch to the new macros with explicit levels.
The --log-level options and set_log commands now also accept
category settings, in addition to the epee style log levels.
2017-01-01 16:34:23 +00:00
MLOG ( level , " " < < test_name ) ;
2014-03-03 22:07:58 +00:00
}
}
}
else if ( command_line : : get_arg ( vm , arg_test_transactions ) )
{
CALL_TEST ( " TRANSACTIONS TESTS " , test_transactions ) ;
}
else
{
Change logging to easylogging++
This replaces the epee and data_loggers logging systems with
a single one, and also adds filename:line and explicit severity
levels. Categories may be defined, and logging severity set
by category (or set of categories). epee style 0-4 log level
maps to a sensible severity configuration. Log files now also
rotate when reaching 100 MB.
To select which logs to output, use the MONERO_LOGS environment
variable, with a comma separated list of categories (globs are
supported), with their requested severity level after a colon.
If a log matches more than one such setting, the last one in
the configuration string applies. A few examples:
This one is (mostly) silent, only outputting fatal errors:
MONERO_LOGS=*:FATAL
This one is very verbose:
MONERO_LOGS=*:TRACE
This one is totally silent (logwise):
MONERO_LOGS=""
This one outputs all errors and warnings, except for the
"verify" category, which prints just fatal errors (the verify
category is used for logs about incoming transactions and
blocks, and it is expected that some/many will fail to verify,
hence we don't want the spam):
MONERO_LOGS=*:WARNING,verify:FATAL
Log levels are, in decreasing order of priority:
FATAL, ERROR, WARNING, INFO, DEBUG, TRACE
Subcategories may be added using prefixes and globs. This
example will output net.p2p logs at the TRACE level, but all
other net* logs only at INFO:
MONERO_LOGS=*:ERROR,net*:INFO,net.p2p:TRACE
Logs which are intended for the user (which Monero was using
a lot through epee, but really isn't a nice way to go things)
should use the "global" category. There are a few helper macros
for using this category, eg: MGINFO("this shows up by default")
or MGINFO_RED("this is red"), to try to keep a similar look
and feel for now.
Existing epee log macros still exist, and map to the new log
levels, but since they're used as a "user facing" UI element
as much as a logging system, they often don't map well to log
severities (ie, a log level 0 log may be an error, or may be
something we want the user to see, such as an important info).
In those cases, I tried to use the new macros. In other cases,
I left the existing macros in. When modifying logs, it is
probably best to switch to the new macros with explicit levels.
The --log-level options and set_log commands now also accept
category settings, in addition to the epee style log levels.
2017-01-01 16:34:23 +00:00
MERROR ( " Wrong arguments " ) ;
2014-03-03 22:07:58 +00:00
return 2 ;
}
return failed_tests . empty ( ) ? 0 : 1 ;
CATCH_ENTRY_L0 ( " main " , 1 ) ;
}