예제 #1
0
TestResult xUnitTest::Run()
{
    for (auto &recorder : testEventRecorders)
    {
        recorder->Tie([&](TestEvent &&evt) { AddEvent(std::move(evt)); });
    }

    testStart = Time::Clock::now();

    try
    {
        test();
    }
    catch (const xUnitAssert &assert)
    {
        AddEvent(TestEvent(EventLevel::Assert, assert));
    }
    catch (const std::exception &e)
    {
        AddEvent(TestEvent(e));
    }
    catch (...)
    {
        AddEvent(TestEvent(EventLevel::Fatal, "Unknown exception caught: test has crashed."));
    }

    testStop = Time::Clock::now();

    return failureEventLogged ? TestResult::Failure : TestResult::Success;
}
예제 #2
0
/* 原因ディスクリプタトHwCARDイベントクリア */
void _clear_event_x(void) {

	TestEvent(ev10);
	TestEvent(ev11);
	TestEvent(ev12);
	TestEvent(ev13);
}
예제 #3
0
/* 原因ディスクリプタトSwCARDイベントクリア */
void _clear_event(void)
{
	TestEvent(ev0);
	TestEvent(ev1);
	TestEvent(ev2);
	TestEvent(ev3);
}
예제 #4
0
/* 原因ディスクリプタトSwCARDイベントチェック(NO_WAIT) */
int _card_event_NW(void)
{
	if(TestEvent(ev0)==1) return CARD_IOE;		/* IOE */
	if(TestEvent(ev1)==1) return CARD_ERROR;	/* ERROR */
	if(TestEvent(ev2)==1) return CARD_TIMEOUT;	/* TIMEOUT */
	if(TestEvent(ev3)==1) return CARD_NEWCARD;	/* NEW CARD */
	return(0);					/* イベント未発生 */
}
예제 #5
0
/* 原因ディスクリプタトHwCARDイベントチェック */
int _card_event_x(void) {

	while(1) {
		if(TestEvent(ev10)==1) return CARD_IOE;		/* IOE */
		if(TestEvent(ev11)==1) return CARD_ERROR;	/* ERROR */
		if(TestEvent(ev12)==1) return CARD_TIMEOUT;	/* TIMEOUT */
		if(TestEvent(ev13)==1) return CARD_NEWCARD;	/* NEW CARD */
	}
}
예제 #6
0
/* イベントのテスト(ブロック型) */
_card_event()
{
    while(1) {
        if(TestEvent(ev0)==1)         /* IOE */
            return 0;
        if(TestEvent(ev1)==1)         /* ERROR */
            return 1;
        if(TestEvent(ev2)==1)         /* TIMEOUT */
            return 2;
        if(TestEvent(ev3)==1)         /* NEW CARD */
            return 3;
    }
}
예제 #7
0
 DisruptorFixture::DisruptorFixture()
 {
     m_lastPublishedEvent = nullptr;
     m_ringBuffer = nullptr;
     m_delayedEventHandlers.clear();
     m_testWorkHandlers.clear();
     m_executor = std::make_shared< StubExecutor >();
     m_disruptor = std::make_shared< disruptor< TestEvent > >([] { return TestEvent(); }, 4, m_executor);
 }
int FAR PASCAL WinMain(HINSTANCE hInstance,	HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
	InitTotalStatistics();
	InitEmptyString();
	FastFunctionsInit();

	TestStackPointers();
	TestClass();
	TestClassStorage();
	TestUnknowns();
	TestArrayUnknown();
	TestSetUnknown();
	TestArrayType();
	TestSetType();
	TestMapStringUnknown();
	TestEvent();
	TestActionEvent();
	TestExternalChannels();
	TestExternalChannelPadder();
	TestChannels();
	TestChannelsAccessor();
	TestSingleChannelAccessor();
	TestChunkFileNames();
	TestParameters();
	TestDistToRoot();
	TestDistToStack();
	TestObjectsSimple();
	TestRoot();
	TestObject();
	TestPointer();
	TestArrayCommonObject();
	TestNamedObject();
	TestObjectAllocator();
	TestObjectWriterChunked();
	TestObjectGraphSerialiser();
	TestObjectReaderSimple();
	TestObjectReaderChunked();
	TestObjectStackPointers();
	TestNamedIndexes();
	TestObjectGraphDeserialiser();
	TestObjectConverter();
	TestObjects();
	TestDehollowfication();
	TestUsage();
	TestArray();
	TestSet();
	TestKill();
	TestEmbedded();
	TestEmbeddedObjectRemapTos();

	FastFunctionsKill();
	KillEmptyString();
	return TestTotalStatistics();
}
예제 #9
0
/*____________________________________________________________________*/
void Events( void)
{
	short i;
	
	print ("\nChecking events types\n");
	print ("-----------------------------\n");
	ResetFilter(); 
	for(i=typeNote; i<=typePrivate; i++) {
		print ("  %s : ", typeListe[i]);
		RejectType(myFilterPtr,i);
		TestEvent( i);
		AcceptType(myFilterPtr,i);
		flush;
	}
	for(i=typeQuarterFrame; i<=typePortPrefix; i++) {
		print ("  %s : ", typeListe[i]);
		RejectType(myFilterPtr,i);
		TestEvent( i);
		AcceptType(myFilterPtr,i);
		flush;
	}
}
예제 #10
0
/**
 *  Tests about Log streams and special printf functions.
 */
void Test1(char *str, char *file)
{
	char tempstr[2048];
	struct display_buffer buffer = { sizeof(tempstr), tmpstr, tmpstr };
	int i;

	SetComponentLogFile(COMPONENT_INIT, "STDOUT");
	LogAlways(COMPONENT_INIT, "%s", "Starting Log Tests");
	LogTest("My PID = %d", getpid());

	LogTest("------------------------------------------------------");
	LogTest("Test conversion of log levels between string and integer");
	for (i = NIV_NULL; i < NB_LOG_LEVEL; i++) {
		int j;
		if (strcmp(tabLogLevel[i].str, ReturnLevelInt(i)) != 0) {
			LogTest(
			     "FAILURE: Log level %d did not convert to %s, it converted to %s",
			     i, tabLogLevel[i].str, ReturnLevelInt(i));
			exit(1);
		}
		j = ReturnLevelAscii(tabLogLevel[i].str);
		if (j != i) {
			LogTest(
			     "FAILURE: Log level %s did not convert to %d, it converted to %d",
			     tabLogLevel[i].str, i, j);
			exit(1);
		}
	}

	LogTest("------------------------------------------------------");

	LogTest("\nTesting possible environment variable");
	LogTest("COMPONENT_MEMCORRUPT debug level is %s",
		ReturnLevelInt(LogComponents[COMPONENT_MEMCORRUPT].
			       comp_log_level));
	LogFullDebug(COMPONENT_MEMCORRUPT,
		     "This should appear if environment is set properly");

	LogTest("------------------------------------------------------");
	LogTest("Send some messages to various files");
	SetComponentLogFile(COMPONENT_DISPATCH, "STDERR");
	LogEvent(COMPONENT_DISPATCH, "This should go to stderr");
	SetComponentLogFile(COMPONENT_DISPATCH, "STDOUT");
	LogEvent(COMPONENT_DISPATCH, "This should go to stdout");
	SetComponentLogFile(COMPONENT_DISPATCH, "SYSLOG");
	LogEvent(COMPONENT_DISPATCH, "This should go to syslog (verf = %s)",
		 str);
	LogTest("About to set %s", file);
	SetComponentLogFile(COMPONENT_DISPATCH, file);
	LogTest("Got it set");
	LogEvent(COMPONENT_DISPATCH, "This should go to %s", file);

	/* Set up for tests that will verify what was actually produced by log
	 * messages. This is used to test log levels and to test the
	 * log_vnsprintf function.
	 */
	/** @todo FSF: this can be done by setting the right header flags and
	 * peeking at the context buffer.
	 */
	SetComponentLogBuffer(COMPONENT_MAIN, &buffer);
	SetComponentLogBuffer(COMPONENT_INIT, &buffer);

	LogTest("------------------------------------------------------");
	LogTest("Test all levels of log filtering");
	SetComponentLogLevel(COMPONENT_MAIN, NIV_NULL);
	TestAlways(true, tempstr, COMPONENT_MAIN, "LogAlways (should print)");
	TestMajor(false, tempstr, COMPONENT_MAIN, "LogMajor (shouldn't print)");
	TestCrit(false, tempstr, COMPONENT_MAIN, "LogCrit (shouldn't print)");
	TestEvent(false, tempstr, COMPONENT_MAIN, "LogEvent (shouldn't print)");
	TestDebug(false, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
	TestFullDebug(false, tempstr, COMPONENT_MAIN,
		      "LogFullDebug (shouldn't print)");
	SetComponentLogLevel(COMPONENT_MAIN, NIV_MAJOR);
	TestAlways(true, tempstr, COMPONENT_MAIN, "LogAlways (should print)");
	TestMajor(true, tempstr, COMPONENT_MAIN, "LogMajor (should print)");
	TestCrit(false, tempstr, COMPONENT_MAIN, "LogCrit (shouldn't print)");
	TestEvent(false, tempstr, COMPONENT_MAIN, "LogEvent (shouldn't print)");
	TestDebug(false, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
	TestFullDebug(false, tempstr, COMPONENT_MAIN,
		      "LogFullDebug (shouldn't print)");
	SetComponentLogLevel(COMPONENT_MAIN, NIV_CRIT);
	TestAlways(true, tempstr, COMPONENT_MAIN, "LogAlways (should print)");
	TestMajor(true, tempstr, COMPONENT_MAIN, "LogMajor (should print)");
	TestCrit(true, tempstr, COMPONENT_MAIN, "LogCrit (should print)");
	TestEvent(false, tempstr, COMPONENT_MAIN, "LogEvent (shouldn't print)");
	TestDebug(false, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
	TestFullDebug(false, tempstr, COMPONENT_MAIN,
		      "LogFullDebug (shouldn't print)");
	SetComponentLogLevel(COMPONENT_MAIN, NIV_EVENT);
	TestAlways(true, tempstr, COMPONENT_MAIN, "LogAlways (should print)");
	TestMajor(true, tempstr, COMPONENT_MAIN, "LogMajor (should print)");
	TestCrit(true, tempstr, COMPONENT_MAIN, "LogCrit (should print)");
	TestEvent(true, tempstr, COMPONENT_MAIN, "LogEvent (should print)");
	TestDebug(false, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
	TestFullDebug(false, tempstr, COMPONENT_MAIN,
		      "LogFullDebug (shouldn't print)");
	SetComponentLogLevel(COMPONENT_MAIN, NIV_DEBUG);
	TestAlways(true, tempstr, COMPONENT_MAIN, "LogAlways (should print)");
	TestMajor(true, tempstr, COMPONENT_MAIN, "LogMajor (should print)");
	TestCrit(true, tempstr, COMPONENT_MAIN, "LogCrit (should print)");
	TestEvent(true, tempstr, COMPONENT_MAIN, "LogEvent (should print)");
	TestDebug(true, tempstr, COMPONENT_MAIN, "LogDebug (should print)");
	TestFullDebug(false, tempstr, COMPONENT_MAIN,
		      "LogFullDebug (shouldn't print)");
	SetComponentLogLevel(COMPONENT_MAIN, NIV_FULL_DEBUG);
	TestAlways(true, tempstr, COMPONENT_MAIN, "LogAlways (should print)");
	TestMajor(true, tempstr, COMPONENT_MAIN, "LogMajor (should print)");
	TestCrit(true, tempstr, COMPONENT_MAIN, "LogCrit (should print)");
	TestEvent(true, tempstr, COMPONENT_MAIN, "LogEvent (should print)");
	TestDebug(true, tempstr, COMPONENT_MAIN, "LogDebug (should print)");
	TestFullDebug(true, tempstr, COMPONENT_MAIN,
		      "LogFullDebug (should print)");
}
예제 #11
0
/**
 *  Tests about Log streams and special printf functions.
 */
int Test1(char *str, char *file)
{
  char tempstr[2048];
  int  i;

  SetComponentLogFile(COMPONENT_INIT, "STDOUT");
  LogAlways(COMPONENT_INIT, "%s", "Starting Log Tests");
  LogTest("My PID = %d", getpid());

  LogTest("------------------------------------------------------");

  LogTest("Test ERR_DUMMY");
  LogTest("A numerical error : error %%d = %%J%%R, in ERR_DUMMY_2 %%J%%R");
  log_snprintf(tempstr, sizeof(tempstr),
               "A numerical error : error %d = %J%R, in ERR_DUMMY_2 %J%R",
               ERR_SIGACTION, ERR_SYS, ERR_SIGACTION, ERR_DUMMY, ERR_DUMMY_2);
  LogTest("%s", tempstr);
  LogTest("A numerical error : error %d = %J%R, in ERR_DUMMY_1 %J%R",
          ERR_OPEN, ERR_SYS, ERR_OPEN, ERR_DUMMY, ERR_DUMMY_1);

  LogTest("------------------------------------------------------");
  LogTest("Test conversion of log levels between string and integer");
  for (i = NIV_NULL; i < NB_LOG_LEVEL; i++)
    {
      int j;
      if (strcmp(tabLogLevel[i].str, ReturnLevelInt(i)) != 0)
        {
          LogTest("FAILURE: Log level %d did not convert to %s, it converted to %s",
                  i, tabLogLevel[i].str, ReturnLevelInt(i));
          exit(1);
        }
      j = ReturnLevelAscii(tabLogLevel[i].str);
      if (j != i)
        {
          LogTest("FAILURE: Log level %s did not convert to %d, it converted to %d",
                  tabLogLevel[i].str, i, j);
          exit(1);
        }
    }

  LogTest("------------------------------------------------------");

  log_snprintf(tempstr, sizeof(tempstr), "Test log_snprintf");
  LogTest("%s", tempstr);
  LogTest("\nTesting LogError function");
  LogError(COMPONENT_CONFIG, ERR_SYS, ERR_MALLOC, EINVAL);
  LogTest("\nTesting possible environment variable");
  LogTest("COMPONENT_MEMCORRUPT debug level is %s",
          ReturnLevelInt(LogComponents[COMPONENT_MEMCORRUPT].comp_log_level));
  LogFullDebug(COMPONENT_MEMCORRUPT,
               "This should appear if environment is set properly");

  LogTest("------------------------------------------------------");
  LogTest("Send some messages to various files");
  SetComponentLogFile(COMPONENT_DISPATCH, "STDERR");
  LogEvent(COMPONENT_DISPATCH, "This should go to stderr");
  SetComponentLogFile(COMPONENT_DISPATCH, "STDOUT");
  LogEvent(COMPONENT_DISPATCH, "This should go to stdout");
  SetComponentLogFile(COMPONENT_DISPATCH, "SYSLOG");
  LogEvent(COMPONENT_DISPATCH, "This should go to syslog (verf = %s)", str);
  LogTest("About to set %s", file);
  SetComponentLogFile(COMPONENT_DISPATCH, file);
  LogTest("Got it set");
  LogEvent(COMPONENT_DISPATCH, "This should go to %s", file);

  /*
   * Set up for tests that will verify what was actually produced by log messages.
   * This is used to test log levels and to test the log_vnsprintf function.
   */
  SetComponentLogBuffer(COMPONENT_MAIN, tempstr);
  SetComponentLogBuffer(COMPONENT_INIT, tempstr);

#ifdef _SNMP_ADM_ACTIVE
  {
    snmp_adm_type_union param;
    int rc;
    strcpy(param.string, "FAILED");

    LogTest("------------------------------------------------------");
    LogTest("Test SNMP functions");
    SetLevelDebug(NIV_DEBUG);

    rc = getComponentLogLevel(&param, (void *)COMPONENT_ALL);
    LogTest("getComponentLogLevel(&param, (void *)COMPONENT_ALL) rc=%d result=%s",
            rc, param.string);
    if (rc != 0)
    {
      LogTest("FAILURE");
      exit(1);
    }
    strcpy(param.string, "NIV_EVENT");
    rc = setComponentLogLevel(&param, (void *)COMPONENT_MAIN);
    LogTest("setComponentLogLevel(&param, (void *)COMPONENT_MAIN) rc=%d", rc);
    if (rc != 0)
    {
      LogTest("FAILURE");
      exit(1);
    }
    TestAlways    (TRUE,  tempstr, COMPONENT_MAIN, "LogAlways (should print)");
    TestMajor     (TRUE,  tempstr, COMPONENT_MAIN, "LogMajor (should print)");
    TestCrit      (TRUE,  tempstr, COMPONENT_MAIN, "LogCrit (should print)");
    TestEvent     (TRUE,  tempstr, COMPONENT_MAIN, "LogEvent (should print)");
    TestDebug     (FALSE, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
    TestFullDebug (FALSE, tempstr, COMPONENT_MAIN, "LogFullDebug (shouldn't print)");
    TestAlways    (TRUE,  tempstr, COMPONENT_INIT, "LogAlways (should print)");
    TestMajor     (TRUE,  tempstr, COMPONENT_INIT, "LogMajor (should print)");
    TestCrit      (TRUE,  tempstr, COMPONENT_INIT, "LogCrit (should print)");
    TestEvent     (TRUE,  tempstr, COMPONENT_INIT, "LogEvent (should print)");
    TestDebug     (TRUE,  tempstr, COMPONENT_INIT, "LogDebug (should print)");
    TestFullDebug (FALSE, tempstr, COMPONENT_INIT, "LogFullDebug (shouldn't print)");
  }
#endif /* _SNMP_ADM_ACTIVE */

  LogTest("------------------------------------------------------");
  LogTest("Test all levels of log filtering");
  SetComponentLogLevel(COMPONENT_MAIN, NIV_NULL);
  TestAlways    (TRUE,  tempstr, COMPONENT_MAIN, "LogAlways (should print)");
  TestMajor     (FALSE, tempstr, COMPONENT_MAIN, "LogMajor (shouldn't print)");
  TestCrit      (FALSE, tempstr, COMPONENT_MAIN, "LogCrit (shouldn't print)");
  TestEvent     (FALSE, tempstr, COMPONENT_MAIN, "LogEvent (shouldn't print)");
  TestDebug     (FALSE, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
  TestFullDebug (FALSE, tempstr, COMPONENT_MAIN, "LogFullDebug (shouldn't print)");
  SetComponentLogLevel(COMPONENT_MAIN, NIV_MAJOR);
  TestAlways    (TRUE,  tempstr, COMPONENT_MAIN, "LogAlways (should print)");
  TestMajor     (TRUE,  tempstr, COMPONENT_MAIN, "LogMajor (should print)");
  TestCrit      (FALSE, tempstr, COMPONENT_MAIN, "LogCrit (shouldn't print)");
  TestEvent     (FALSE, tempstr, COMPONENT_MAIN, "LogEvent (shouldn't print)");
  TestDebug     (FALSE, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
  TestFullDebug (FALSE, tempstr, COMPONENT_MAIN, "LogFullDebug (shouldn't print)");
  SetComponentLogLevel(COMPONENT_MAIN, NIV_CRIT);
  TestAlways    (TRUE,  tempstr, COMPONENT_MAIN, "LogAlways (should print)");
  TestMajor     (TRUE,  tempstr, COMPONENT_MAIN, "LogMajor (should print)");
  TestCrit      (TRUE,  tempstr, COMPONENT_MAIN, "LogCrit (should print)");
  TestEvent     (FALSE, tempstr, COMPONENT_MAIN, "LogEvent (shouldn't print)");
  TestDebug     (FALSE, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
  TestFullDebug (FALSE, tempstr, COMPONENT_MAIN, "LogFullDebug (shouldn't print)");
  SetComponentLogLevel(COMPONENT_MAIN, NIV_EVENT);
  TestAlways    (TRUE,  tempstr, COMPONENT_MAIN, "LogAlways (should print)");
  TestMajor     (TRUE,  tempstr, COMPONENT_MAIN, "LogMajor (should print)");
  TestCrit      (TRUE,  tempstr, COMPONENT_MAIN, "LogCrit (should print)");
  TestEvent     (TRUE,  tempstr, COMPONENT_MAIN, "LogEvent (should print)");
  TestDebug     (FALSE, tempstr, COMPONENT_MAIN, "LogDebug (shouldn't print)");
  TestFullDebug (FALSE, tempstr, COMPONENT_MAIN, "LogFullDebug (shouldn't print)");
  SetComponentLogLevel(COMPONENT_MAIN, NIV_DEBUG);
  TestAlways    (TRUE,  tempstr, COMPONENT_MAIN, "LogAlways (should print)");
  TestMajor     (TRUE,  tempstr, COMPONENT_MAIN, "LogMajor (should print)");
  TestCrit      (TRUE,  tempstr, COMPONENT_MAIN, "LogCrit (should print)");
  TestEvent     (TRUE,  tempstr, COMPONENT_MAIN, "LogEvent (should print)");
  TestDebug     (TRUE,  tempstr, COMPONENT_MAIN, "LogDebug (should print)");
  TestFullDebug (FALSE, tempstr, COMPONENT_MAIN, "LogFullDebug (shouldn't print)");
  SetComponentLogLevel(COMPONENT_MAIN, NIV_FULL_DEBUG);
  TestAlways    (TRUE,  tempstr, COMPONENT_MAIN, "LogAlways (should print)");
  TestMajor     (TRUE,  tempstr, COMPONENT_MAIN, "LogMajor (should print)");
  TestCrit      (TRUE,  tempstr, COMPONENT_MAIN, "LogCrit (should print)");
  TestEvent     (TRUE,  tempstr, COMPONENT_MAIN, "LogEvent (should print)");
  TestDebug     (TRUE,  tempstr, COMPONENT_MAIN, "LogDebug (should print)");
  TestFullDebug (TRUE,  tempstr, COMPONENT_MAIN, "LogFullDebug (should print)");
}
예제 #12
0
파일: xUnitLog.cpp 프로젝트: asmodehn/xunit
Log::Log(const TestEventRecorder &recorder)
    : Debug([&](const std::string &msg, const LineInfo &lineInfo) { recorder(TestEvent(EventLevel::Debug, msg, lineInfo)); })
    , Info([&](const std::string &msg, const LineInfo &lineInfo) { recorder(TestEvent(EventLevel::Info, msg, lineInfo)); })
    , Warn([&](const std::string &msg, const LineInfo &lineInfo) { recorder(TestEvent(EventLevel::Warning, msg, lineInfo)); })
{
}
 void set_state(simpleState s){
     state = s;
     publishEvent(TestEvent());
 }
예제 #14
0
/* イベントのクリア */
_clear_event()
{
    TestEvent(ev0);  TestEvent(ev1);  TestEvent(ev2);  TestEvent(ev3);
}