Example #1
0
void etUnit_open(const char* testResultPath, const char* testFileName) {
	etLogger_logInfoF("************* TEST START (%s) **************", testFileName);

	{
		char filename[ETUNIT_FAILURE_TEXT_LEN];
		int i;

		if (testResultPath!=NULL)
			sprintf(filename, "%s/%s.etu", testResultPath, testFileName);
		else
			sprintf(filename, "%s.etu", testFileName);

		/* init global data */
		for (i=0; i<ETUNIT_ORDER_MAX; ++i)
			etUnit_orderInfo[i].id = 0;
		for (i=0; i<ETUNIT_MAX_TEST_CASES; ++i)
			etUnit_testcaseSuccess[i] = TRUE;

		if (etUnit_reportfile == NULL) {
			etUnit_reportfile = etLogger_fopen(filename, "w+");
			if (etUnit_reportfile != NULL) {
				etLogger_fprintf(etUnit_reportfile, "etUnit report\n");
			} else {
				etLogger_logErrorF("Unable to open file %s", filename);
			}
		}
	}

	/* prepare time measurement */
	etUnit_startTime = clock();
	etUnit_currentTime = clock();
	etLogger_logInfoF("Start Time: %ld", etUnit_startTime);

}
Example #2
0
void etUnit_close(void) {
	if (etUnit_reportfile != NULL) {
		etLogger_fclose(etUnit_reportfile);
		etUnit_reportfile = NULL;
	}
	etLogger_logInfoF("End Time: %ld", clock());
	etLogger_logInfoF("************* TEST END **************");
}
Example #3
0
void etUnit_close(void) {
	if (etUnit_reportfile != NULL) {
		etLogger_fclose(etUnit_reportfile);
		etUnit_reportfile = NULL;
	}
	etLogger_logInfoF("End Time: %ld", clock());
	if (etUnit_errorCounter==0)
		etLogger_logInfoF("Error Counter: %ld", etUnit_errorCounter);
	else
		etLogger_logErrorF("Error Counter: %ld", etUnit_errorCounter);
	etLogger_logInfoF("************* TEST END **************");
}
Example #4
0
void expectOrder(etInt16 id, const char* message, etInt16 identifier, const char* file, int line){
	OrderInfo* info = getOrderInfo(id);
	if (info!=NULL) {
		if (info->currentIndex < info->size) {
			if (info->list[info->currentIndex] != identifier){
				char testresult[ETUNIT_FAILURE_TEXT_LEN];
				char exp[16], act[16];
				sprintf(testresult, "EXPECT_ORDER %s: index=%d, expected=%d, actual=%d", message, info->currentIndex, identifier, info->list[info->currentIndex]);
				sprintf(exp, "%d", identifier);
				sprintf(act, "%d", info->list[info->currentIndex]);
				etUnit_handleExpect(id, FALSE, testresult, exp, act, file, line);
			}
			else {
				etUnit_handleExpect(id, TRUE, "", NULL, NULL, file, line);
				info->currentIndex++;
			}
		}
		else {
			char testresult[ETUNIT_FAILURE_TEXT_LEN];
			sprintf(testresult, "EXPECT_ORDER: index(%d) is too big in %s", info->currentIndex, message);
			etUnit_handleExpect(id, FALSE, testresult, NULL, NULL, file, line);
			etLogger_logInfoF("EXPECT_ORDER: index too big in %s", message);
		}
	}
}