Ejemplo n.º 1
0
 LIBUPTESTAPI
 void console_test_listener::enter_test_suite(test_suite const& suite) {
     if (suite.parent() != nullptr) {
         printf("%s\n", suite.name());
         printf("%s\n", group_separator);
     }
 }
Ejemplo n.º 2
0
Archivo: main.cpp Proyecto: ndoss/nt2
    NT2_TEST_UNIT_DECL
    int unit_main(int argc, char* argv[], test_suite const& current_suite)
    {
      bool no_catch = false;
      bool float_debug = false;

      assert_mode = ASSERT_EXCEPT;

      for(int i=1; i<argc; ++i)
      {
        if(!strcmp(argv[i], "--no-catch"))
          no_catch = true;
        else if(!strcmp(argv[i], "--float-debug"))
          float_debug = true;
        else if(!strcmp(argv[i], "--assert-stackdump"))
          assert_mode = assert_mode_t(ASSERT_LOG | ASSERT_STACKDUMP | ASSERT_ABORT);
        else if(!strcmp(argv[i], "--assert-abort"))
          assert_mode = assert_mode_t(ASSERT_LOG | ASSERT_ABORT);
        else if(!strcmp(argv[i], "--assert-trap"))
          assert_mode = assert_mode_t(ASSERT_LOG | ASSERT_TRAP);
        else if(!strcmp(argv[i], "--assert-log"))
          assert_mode = assert_mode_t(ASSERT_LOG);
        else if(!strcmp(argv[i], "--assert-ignore"))
          assert_mode = assert_mode_t(ASSERT_IGNORE);
      }

      fill_args_map(argc,argv);

      if(float_debug)
        float_control_debug();

      #ifndef BOOST_NO_EXCEPTIONS
      if(no_catch)
      {
        current_suite.process();
        return nt2::unit::error_count() ? -1: 0;
      }

      try
      {
        current_suite.process();
        return nt2::unit::error_count() ? -1: 0;
      }
      catch(std::exception const& e)
      {
        std::cout << "uncaught exception: " << e.what() << std::endl;
        return 1;
      }
      catch(...)
      {
        std::cout << "uncaught exception" << std::endl;
        return 1;
      }
      #else
      current_suite.process();
      return nt2::unit::error_count() ? -1: 0;
      #endif
    }
Ejemplo n.º 3
0
static test_outcome run_test_with_siglongjmp(const test_suite suite, const test* test_case)
{
	int sigsetret;
	if (0 == test_case->test_case) {
		fprintf(stderr, "%s is a null test\n", current_test);
		return INVALID;
	}
	sigsetret = sigsetjmp(recovery_buffer, 1);
	VERBOSE_LOG("Test %s:%s checkpoint status %d\n", sigsetret);
	switch (sigsetret) { /* clean path */
		case 0:
			current_stage = SETUP;
			VERBOSE_LOG("Running %s:%s suite setup\n");
			suite.setup();
			VERBOSE_LOG("Running %s:%s setup\n");
			test_case->setup();
			current_stage = TEST;
			VERBOSE_LOG("Running %s:%s\n");
			test_case->test_case();
			current_stage = TEARDOWN;
			VERBOSE_LOG("Running %s:%s tear down\n");
			test_case->teardown();
			VERBOSE_LOG("Running %s:%s tear down\n");
			suite.teardown();
			return PASS;
			break;
		case SETUP:
			LOG_TEST_ERROR("Error in [%s:%s] during setup\n");
			sigsetret = sigsetjmp(recovery_buffer, 1);
			if (0 == sigsetret) {
				current_stage = TEARDOWN;
				VERBOSE_LOG("Running %s:%s setup failure tear down\n");
				test_case->teardown();
			}
			break;
		case TEST:
			LOG_TEST_ERROR("Test failure in [%s:%s] ***%s\n", TEST_OUTCOMES[FAIL]);
			sigsetret = sigsetjmp(recovery_buffer, 1);
			if (0 == sigsetret) {
				current_stage = TEARDOWN;
				VERBOSE_LOG("Running %s:%s test failure tear down\n");
				test_case->teardown();
			}
			return FAIL;
			break;
		case TEARDOWN:
			LOG_TEST_ERROR("Error in [%s:%s] during teardown\n");
			break;
		default:
			LOG_TEST_ERROR("Error in [%s:%s] with unknown failure type %u\n", sigsetret);
			break;
	}

	return UNRESOLVED;
}
	bool actualizeMembers(test_suite& suite, const std::deque<test_unit_id>& members) {
		const std::size_t suiteSize = suite.size();
		const std::size_t memSize = members.size();
		if (suiteSize != memSize) {
			//diff size
			DEPENDENCY_LOG_ERROR( "Members size[" << memSize << "] differs from sute size[" << suiteSize << "]" );
			return false;
		} else {
			//obtain all pointers
			std::vector<test_unit*> units(memSize);
			bool gotAllUnits = true;
			//std::deque<test_unit_id>::const_iterator iter = members.begin();
			//std::deque<test_unit_id>::const_iterator eiter = members.end();
			for(std::size_t i =0; i<memSize; i++) {
				DependencyId unitId = members[i];
				test_unit* unit = getUnit(unitId);
				if (unit!=NULL) {
					units[i] = unit;
				} else {
					DEPENDENCY_LOG_ERROR( "Could not get member[" << unitId << "]" );
					gotAllUnits = false;
				}
			}

			if (gotAllUnits==false) {
				DEPENDENCY_LOG_ERROR( "Could not get all members" );
				return false;
			} else {
				//remove old tests
				for(std::size_t i=0; i<suiteSize; i++) {
					suite.remove( members[i] );
				}
				const std::size_t newSuiteSize = suite.size();
				if (newSuiteSize>0) {
					DEPENDENCY_LOG_ERROR( "Could not clear the suite" );
					return false;
				} else {
					//add tests in correct order

					for(std::size_t i=0; i<memSize; i++) {
						test_unit* unit = units[i];
						suite.add(unit, unit->p_expected_failures, unit->p_timeout);
					}
				}
			}
			return true;
		}
	}
Ejemplo n.º 5
0
   EXPORT_C   bool            test_suite_start( test_suite const& ts )
    {
        if( !ts.check_dependencies() ) {
            BOOST_TEST_FOREACH( test_observer*, to, m_observers )
                to->test_unit_skipped( ts );

            return false;
        }
Ejemplo n.º 6
0
static test_outcome run_test(const test_suite suite, const test* test_case)
{
    VERBOSE_LOG("Test %s:%s running in child process %u\n", getpid());
    current_stage = SETUP;
	VERBOSE_LOG("Setting up suite for test %s:%s\n");
	suite.setup();
    VERBOSE_LOG("Setting up test %s:%s\n");
    test_case->setup();
    VERBOSE_LOG("Running %s:%s\n");
    current_stage = TEST;
    test_case->test_case();
    current_stage = TEARDOWN;
    VERBOSE_LOG("Running %s:%s tear down\n");
    test_case->teardown();
	VERBOSE_LOG("Tearing down suite for %s:%s\n");
    return PASS;
}
Ejemplo n.º 7
0
 registrar(test_suite & st, test_case tc) noexcept
 {
     st.register_test(tc);
 }
static void register_method_function_instance(test_suite& suite)
{
    suite.add(BOOST_TEST_CASE(stream_with_badbit_throws_runtime_error));
}
static void register_method_static_instance(test_suite& suite)
{
    suite.add(BOOST_TEST_CASE(
        boost::bind(&hello_fixture::stream_with_badbit_throws_runtime_error,
            &hf)));
}
static void register_function(test_suite& suite)
{
    suite.add(BOOST_TEST_CASE(inserts_text));
}
Ejemplo n.º 11
0
 registrar(test_suite & st, test_case tc)
 {
     st.register_test(tc);
 }
Ejemplo n.º 12
0
 LIBUPTESTAPI
 void console_test_listener::exit_test_suite(test_suite const& suite) {
     if (suite.parent() != nullptr) {
         putchar('\n');
     }
 }