Fix tests better

The solution being used for initializing the boost test modules is
now deprecated, so update it to use the global test fixture instead
This commit is contained in:
Nathan Hourt 2021-03-05 12:05:11 -06:00 committed by Michel Santos
parent 8a6bae6006
commit 906ffa6351
7 changed files with 75 additions and 82 deletions

View file

@ -2860,21 +2860,14 @@ BOOST_AUTO_TEST_CASE( wimbledon_2017_gentelmen_singles_final_test )
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
struct GlobalInitializationFixture {
GlobalInitializationFixture() {
//#define BOOST_TEST_MODULE "C++ Unit Tests for Graphene Blockchain Database"
#include <cstdlib>
#include <iostream>
#include <boost/test/included/unit_test.hpp>
boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
std::srand(time(NULL)); std::srand(time(NULL));
std::cout << "Random number generator seeded to " << time(NULL) << std::endl; std::cout << "Random number generator seeded to " << time(NULL) << std::endl;
// betting operations don't take effect until HARDFORK 1000 // betting operations don't take effect until HARDFORK 1000
GRAPHENE_TESTING_GENESIS_TIMESTAMP = GRAPHENE_TESTING_GENESIS_TIMESTAMP = HARDFORK_1000_TIME.sec_since_epoch() + 2;
(HARDFORK_1000_TIME.sec_since_epoch() + 15) / GRAPHENE_DEFAULT_BLOCK_INTERVAL * GRAPHENE_DEFAULT_BLOCK_INTERVAL;
return nullptr;
} }
};
BOOST_TEST_GLOBAL_FIXTURE(GlobalInitializationFixture);

View file

@ -21,12 +21,18 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include <cstdlib>
#include <iostream>
#include <boost/test/included/unit_test.hpp>
boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { #define BOOST_TEST_MODULE Intense Tests
#include <boost/test/unit_test.hpp>
#include <cstdlib>
struct GlobalInitializationFixture {
GlobalInitializationFixture() {
std::srand(time(NULL)); std::srand(time(NULL));
std::cout << "Random number generator seeded to " << time(NULL) << std::endl; std::cout << "Random number generator seeded to " << time(NULL) << std::endl;
return nullptr;
} }
};
BOOST_TEST_GLOBAL_FIXTURE(GlobalInitializationFixture);

View file

@ -5,13 +5,11 @@
BOOST_AUTO_TEST_CASE(peerplays_sidechain) { BOOST_AUTO_TEST_CASE(peerplays_sidechain) {
} }
#include <boost/test/included/unit_test.hpp> struct GlobalInitializationFixture {
#include <cstdlib> GlobalInitializationFixture() {
#include <iostream>
boost::unit_test::test_suite *init_unit_test_suite(int argc, char *argv[]) {
std::srand(time(NULL)); std::srand(time(NULL));
std::cout << "Random number generator seeded to " << time(NULL) << std::endl; std::cout << "Random number generator seeded to " << time(NULL) << std::endl;
return nullptr;
} }
};
BOOST_TEST_GLOBAL_FIXTURE(GlobalInitializationFixture);

View file

@ -74,13 +74,11 @@ BOOST_AUTO_TEST_CASE( transfer_benchmark )
//BOOST_AUTO_TEST_SUITE_END() //BOOST_AUTO_TEST_SUITE_END()
//#define BOOST_TEST_MODULE "C++ Unit Tests for Graphene Blockchain Database" struct GlobalInitializationFixture {
#include <cstdlib> GlobalInitializationFixture() {
#include <iostream>
#include <boost/test/included/unit_test.hpp>
boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
std::srand(time(NULL)); std::srand(time(NULL));
std::cout << "Random number generator seeded to " << time(NULL) << std::endl; std::cout << "Random number generator seeded to " << time(NULL) << std::endl;
return nullptr;
} }
};
BOOST_TEST_GLOBAL_FIXTURE(GlobalInitializationFixture);

View file

@ -134,12 +134,10 @@ BOOST_FIXTURE_TEST_CASE( basic, database_fixture )
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
//#define BOOST_TEST_MODULE "C++ Unit Tests for Graphene Blockchain Database" struct GlobalInitializationFixture {
#include <cstdlib> GlobalInitializationFixture() {
#include <iostream> auto argc = boost::unit_test::framework::master_test_suite().argc;
#include <boost/test/included/unit_test.hpp> auto argv = boost::unit_test::framework::master_test_suite().argv;
boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
for (int i=1; i<argc; i++) for (int i=1; i<argc; i++)
{ {
const std::string arg = argv[i]; const std::string arg = argv[i];
@ -153,5 +151,7 @@ boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
std::cout << "Random number generator seeded to " << time(NULL) << std::endl; std::cout << "Random number generator seeded to " << time(NULL) << std::endl;
if (signal(SIGPIPE, sig_handler) == SIG_ERR) if (signal(SIGPIPE, sig_handler) == SIG_ERR)
std::cout << "Can't catch SIGPIPE signal!" << std::endl; std::cout << "Can't catch SIGPIPE signal!" << std::endl;
return nullptr;
} }
};
BOOST_TEST_GLOBAL_FIXTURE(GlobalInitializationFixture);

View file

@ -21,20 +21,20 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#define BOOST_TEST_MODULE Tests
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include <boost/test/included/unit_test.hpp> #include <boost/test/included/unit_test.hpp>
extern uint32_t GRAPHENE_TESTING_GENESIS_TIMESTAMP; extern uint32_t GRAPHENE_TESTING_GENESIS_TIMESTAMP;
boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { struct GlobalInitializationFixture {
GlobalInitializationFixture() {
std::srand(time(NULL)); std::srand(time(NULL));
std::cout << "Random number generator seeded to " << time(NULL) << std::endl; std::cout << "Random number generator seeded to " << time(NULL) << std::endl;
const char* genesis_timestamp_str = getenv("GRAPHENE_TESTING_GENESIS_TIMESTAMP");
if( genesis_timestamp_str != nullptr )
{
GRAPHENE_TESTING_GENESIS_TIMESTAMP = std::stoul( genesis_timestamp_str );
}
std::cout << "GRAPHENE_TESTING_GENESIS_TIMESTAMP is " << GRAPHENE_TESTING_GENESIS_TIMESTAMP << std::endl;
return nullptr;
} }
};
BOOST_TEST_GLOBAL_FIXTURE(GlobalInitializationFixture);

View file

@ -2259,13 +2259,11 @@ BOOST_FIXTURE_TEST_CASE( massive, database_fixture )
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
//#define BOOST_TEST_MODULE "C++ Unit Tests for Graphene Blockchain Database" struct GlobalInitializationFixture {
#include <cstdlib> GlobalInitializationFixture() {
#include <iostream>
#include <boost/test/included/unit_test.hpp>
boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
std::srand(time(NULL)); std::srand(time(NULL));
std::cout << "Random number generator seeded to " << time(NULL) << std::endl; std::cout << "Random number generator seeded to " << time(NULL) << std::endl;
return nullptr;
} }
};
BOOST_TEST_GLOBAL_FIXTURE(GlobalInitializationFixture);