00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
#include <stdio.h>
00011
#include <time.h>
00012
#include "../GeneralInclude/TestCompilerSwitches.h"
00013
#include "../GeneralInclude/TestConstants.h"
00014
#include "../Utilities/TestUtilities.h"
00015
00016
void printRegressionTestHeader(FILE* outFile) {
00017
#ifdef MS_HOST
00018
time_t ltime;
00019 time( <ime );
00020 fprintf(outFile,
"<html><head>\n");
00021 fprintf(outFile,
"<title>OBS Framework - Regression Test Report</title>\n");
00022 fprintf(outFile,
"</head><body bgcolor=\"#FFFF99\" link=\"#3333FF\">\n");
00023 fprintf(outFile,
"<center><h1>Regression Test Report</h1></center>\n");
00024 fprintf(outFile,
"<center><h4><i>Test Run Performed on %s</i></h4></center>\n",
00025 ctime( <ime ));
00026 fprintf(outFile,
"This report was automatically generated by the regression test program of\n");
00027 fprintf(outFile,
"the OBS Framework. The regression test program executes all the test cases\n");
00028 fprintf(outFile,
"defined for the OBS Framework. The test cases are executed in sequence.\n");
00029 fprintf(outFile,
"Each test cases tests some or all the functionalities of one \n");
00030 fprintf(outFile,
"framework component. The tests are performed at component-level only.\n");
00031 fprintf(outFile,
"A test case can have two possible outcomes: 'test succeeded' or 'test failed'.\n");
00032 fprintf(outFile,
"The test case outcome can be accompanied by an explanatory message.\n");
00033 fprintf(outFile,
"The table below reports the outcome of the test case performed in a \n");
00034 fprintf(outFile,
"regression test run. The links in the table point to the files documenting the individual test cases. \n");
00035 fprintf(outFile,
"The links are active only if this file\n");
00036 fprintf(outFile,
"is placed in the directory containing the HTML architectural documentation of \n");
00037 fprintf(outFile,
"the OBS Framework.\n");
00038 fprintf(outFile,
"There should be one documentation file for each test case. The links assume its \n");
00039 fprintf(outFile,
"name to be: 'TEST_FILE_NAME_1'+'test name'+'TEST_FILE_NAME_2'+'.html' where \n");
00040 fprintf(outFile,
"'TEST_FILE_NAME_1' and 'TEST_FILE_NAME_2' are string constants defined in\n");
00041 fprintf(outFile,
"the 'TestConstants.h' include file.\n");
00042 fprintf(outFile,
"<p>\n");
00043 fprintf(outFile,
"<p>\n");
00044 fprintf(outFile,
"<table BORDER=1 ALIGN=\"center\" CELLPADDING=5%>\n");
00045 fprintf(outFile,
"<tr><th>Test Name</th>\n");
00046 fprintf(outFile,
"<th>Test Outcome</th></tr>\n");
00047
#else
00048
printf(
"Regression Test Report");
00049
#endif
00050
}
00051
00052
void printRegressionTestTail(FILE* outFile) {
00053
#ifdef MS_HOST
00054
fprintf(outFile,
"</table></body></html>\n");
00055
#endif
00056
}
00057
00058
void printTestSuccess(FILE* outFile,
char* testName,
char* testMsg) {
00059
#ifdef MS_HOST
00060
fprintf(outFile,
"<tr><td><a href=\"%s%s%s.html\">%s</a></td>\n",
00061 TEST_FILE_NAME_1,doubleUnderscore(outFile,testName),TEST_FILE_NAME_2,testName);
00062 fprintf(outFile,
"<td>%s</td></tr>\n",testMsg);
00063
#else
00064
printf(
"Test %s executed successfully. %s\n",testName,testMsg);
00065
#endif
00066
}
00067
00068
void printTestFailed(FILE* outFile,
char* testName,
char* testMsg) {
00069
#ifdef MS_HOST
00070
fprintf(outFile,
"<tr><td><a href=\"%s%s%s.html\">%s</a></td>\n",
00071 TEST_FILE_NAME_1,doubleUnderscore(outFile,testName),TEST_FILE_NAME_2,testName);
00072 fprintf(outFile,
"<td><b>%s</b></td></tr>\n",testMsg);
00073
#else
00074
printf(
"Test %s failed. %s\n",testName,testMsg);
00075
#endif
00076
}
00077
00078
void printErrorMsg(FILE* outFile,
char* testName,
char* testMsg) {
00079
#ifdef MS_HOST
00080
fprintf(outFile,
"<tr><td>%s</td>\n",testName);
00081 fprintf(outFile,
"<td><b>%s</b></td></tr>\n",testMsg);
00082
#else
00083
printf(
"Test %s failed. %s\n",testName,testMsg);
00084
#endif
00085
}
00086
00087
char* doubleUnderscore(FILE* outFile,
char* testName) {
00088
int i = 0;
00089
int j = 0;
00090
while ( (testName[j]!=
'\0') && (i<(
MAX_TEST_FILE_NAME_LENGTH-1)) ) {
00091 charBuffer[i] = testName[j];
00092
if (testName[j]==
'_') {
00093 i++;
00094 charBuffer[i] =
'_';
00095 }
00096 i++;
00097 j++;
00098 }
00099
if (testName[j]!=
'\0') {
00100 printErrorMsg(outFile,testName,
"Test case name is too long");
00101 }
00102 charBuffer[i]=
'\0';
00103
return charBuffer;
00104 }
00105