示例#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);

}
示例#2
0
void etUnit_closeTestCase(etInt16 id) {
	clock_t time = clock() - etUnit_currentTime;
	etUnit_currentTime = clock();

	if (etUnit_reportfile != NULL) {
		etLogger_fprintf(etUnit_reportfile, "tc end %d: %d\n", id, time);
	}
}
示例#3
0
etInt16 etUnit_openTestCase(const char* testCaseName) {
	etInt16 caseId = etUnit_nextCaseId++;

	if (etUnit_reportfile != NULL) {
		etLogger_fprintf(etUnit_reportfile, "tc start %d: %s\n", caseId, testCaseName);
	}

	return caseId;
}
示例#4
0
static void etUnit_handleExpect(etInt16 id, etBool result, const char *resulttext, const char* exp, const char* act, const char* file, int line) {
	if (result == TRUE) {
		/* nothing to do because no failure */
	}
	else {
		if (etUnit_testcaseSuccess[id] == TRUE){
			/* first failure will be remembered */
			etUnit_testcaseSuccess[id] = FALSE;

			if (act!=NULL && exp!=NULL)
				etLogger_fprintf(etUnit_reportfile, "tc fail %d: #%s#%s#%s:%d#%s\n", id, exp, act, file, line, resulttext);
			else
				etLogger_fprintf(etUnit_reportfile, "tc fail %d: ###%s:%d#%s\n", id, file, line, resulttext);
		}
		else{
			/* more than one error will be ignored */
		}
	}
}
示例#5
0
etInt16 etUnit_openTestCase(const char* testCaseName) {
	etInt16 caseId = etUnit_nextCaseId++;

	if (caseId >= ETUNIT_MAX_TEST_CASES) {
		etLogger_logErrorF("Too many test cases. Maximum number of test cases is %d\n", ETUNIT_MAX_TEST_CASES);
		etLogger_logErrorF("ETUNIT_MAX_TEST_CASES (etUnit_openTestCase, %s: %d)", __FILE__, __LINE__);
		exit(-1);
	}
	if (etUnit_reportfile != NULL) {
		etLogger_fprintf(etUnit_reportfile, "tc start %d: %s\n", caseId, testCaseName);
	}

	return caseId;
}
示例#6
0
void etUnit_openTestSuite(const char* testSuiteName) {
	if (etUnit_reportfile != NULL) {
		etLogger_fprintf(etUnit_reportfile, "ts start: %s\n", testSuiteName);
	}
}