adds error catching code to close databases properly

This commit is contained in:
Eyck Jentzsch 2024-05-08 17:19:37 +02:00
parent f82c3ce229
commit f8bd40cd60

View File

@ -7,6 +7,8 @@
#include "factory.h"
#include <catch2/catch_session.hpp>
#include <csetjmp>
#include <csignal>
#include <cstdlib>
#include <scc/report.h>
#include <scc/trace.h>
@ -16,19 +18,26 @@
using namespace scc;
using namespace sc_core;
jmp_buf abrt;
void ABRThandler(int sig) { longjmp(abrt, 1); }
int sc_main(int argc, char* argv[]) {
signal(SIGABRT, ABRThandler);
auto my_name = util::split(argv[0], '/').back();
scc::init_logging(LogConfig().logLevel(getenv("SCC_TEST_VERBOSE") ? log::DEBUG : log::FATAL).logAsync(false).msgTypeFieldWidth(35));
scc::init_logging(LogConfig().logLevel(getenv("SCC_TEST_VERBOSE") ? log::TRACE : log::FATAL).logAsync(false).msgTypeFieldWidth(35));
// create tracer if environment variable SCC_TEST_TRACE is defined
std::unique_ptr<scc::tracer> tracer;
if(getenv("SCC_TEST_TRACE"))
tracer = std::make_unique<scc::tracer>(my_name, scc::tracer::file_type::TEXT, true);
tracer = std::make_unique<scc::tracer>(my_name, scc::tracer::NONE, scc::tracer::ENABLE);
int result = -1;
if(setjmp(abrt) == 0) {
// instantiate design(s)
factory::get_instance().create();
// run tests
int result = Catch::Session().run(argc, argv);
result = Catch::Session().run(argc, argv);
// destroy design(s)
sc_stop();
factory::get_instance().destroy();
}
return result;
}