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; }
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); }
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 **************"); }