inc/qa.h File Reference

#include "htmlPage.h"

Include dependency graph for qa.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  qaStatus
struct  qaStatistics

Functions

char * qaStringBetween (char *text, char *startPattern, char *endPattern)
char * qaScanForErrorMessage (char *text)
int qaCountBetween (char *s, char *startPattern, char *endPattern, char *midPattern)
slNameqaRandomSample (char *db, char *table, char *field, int count)
qaStatusqaPageGet (char *url, struct htmlPage **retPage)
qaStatusqaPageFromForm (struct htmlPage *origPage, struct htmlForm *form, char *buttonName, char *buttonVal, struct htmlPage **retPage)
void qaStatusSoftError (struct qaStatus *qs, char *format,...)
void qaStatusReportOne (FILE *f, struct qaStatus *qs, char *format,...)
void qaStatisticsAdd (struct qaStatistics *stats, struct qaStatus *qs)
void qaStatisticsReport (struct qaStatistics *stats, char *label, FILE *f)


Function Documentation

int qaCountBetween ( char *  s,
char *  startPattern,
char *  endPattern,
char *  midPattern 
)

Definition at line 45 of file qa.c.

References startsWith(), and stringIn.

00048 {
00049 int count = 0;
00050 char *e;
00051 s = stringIn(startPattern, s);
00052 if (s != NULL)
00053     {
00054     s += strlen(startPattern);
00055     e = stringIn(endPattern, s);
00056     while (s < e)
00057         {
00058         if (startsWith(midPattern, s))
00059             ++count;
00060         s += 1;
00061         }
00062     }
00063 return count;
00064 }

Here is the call graph for this function:

struct qaStatus* qaPageFromForm ( struct htmlPage origPage,
struct htmlForm form,
char *  buttonName,
char *  buttonVal,
struct htmlPage **  retPage 
) [read]

Definition at line 151 of file qa.c.

References clock1000(), errCatchEnd(), errCatchFree(), errCatchNew(), errCatchStart, htmlPageFree(), htmlPageFromForm(), htmlPageValidateOrAbort(), and qaStatusOnPage().

00154 {
00155 struct errCatch *errCatch = errCatchNew();
00156 struct qaStatus *qs;
00157 struct htmlPage *page = NULL;
00158 long startTime = clock1000();
00159 if (errCatchStart(errCatch))
00160     {
00161     page = htmlPageFromForm(origPage, form, buttonName, buttonVal);
00162     htmlPageValidateOrAbort(page);
00163     }
00164 else
00165     {
00166     htmlPageFree(&page);
00167     }
00168 errCatchEnd(errCatch);
00169 qs = qaStatusOnPage(errCatch, page, startTime, retPage);
00170 errCatchFree(&errCatch);
00171 return qs;
00172 }

Here is the call graph for this function:

struct qaStatus* qaPageGet ( char *  url,
struct htmlPage **  retPage 
) [read]

Definition at line 129 of file qa.c.

References clock1000(), errCatchEnd(), errCatchFree(), errCatchNew(), errCatchStart, htmlPageFree(), htmlPageGet(), htmlPageValidateOrAbort(), and qaStatusOnPage().

00131 {
00132 struct errCatch *errCatch = errCatchNew();
00133 struct qaStatus *qs;
00134 struct htmlPage *page = NULL;
00135 long startTime = clock1000();
00136 if (errCatchStart(errCatch))
00137     {
00138     page = htmlPageGet(url);
00139     htmlPageValidateOrAbort(page);
00140     }
00141 else
00142     {
00143     htmlPageFree(&page);
00144     }
00145 errCatchEnd(errCatch);
00146 qs = qaStatusOnPage(errCatch, page, startTime, retPage);
00147 errCatchFree(&errCatch);
00148 return qs;
00149 }

Here is the call graph for this function:

struct slName* qaRandomSample ( char *  db,
char *  table,
char *  field,
int  count 
) [read]

char* qaScanForErrorMessage ( char *  text  ) 

Definition at line 38 of file qa.c.

References htmlWarnEndPattern(), htmlWarnStartPattern(), and qaStringBetween().

Referenced by qaStatusOnPage().

00041 {
00042 return qaStringBetween(text, htmlWarnStartPattern(), htmlWarnEndPattern());
00043 }

Here is the call graph for this function:

Here is the caller graph for this function:

void qaStatisticsAdd ( struct qaStatistics stats,
struct qaStatus qs 
)

Definition at line 193 of file qa.c.

References qaStatus::errMessage, qaStatistics::hardCount, qaStatus::hardError, qaStatus::milliTime, qaStatistics::milliTotal, qaStatistics::softCount, and qaStatistics::testCount.

00195 {
00196 stats->testCount += 1;
00197 stats->milliTotal += qs->milliTime;
00198 if (qs->errMessage)
00199     {
00200     if (qs->hardError)
00201         stats->hardCount += 1;
00202     else
00203         stats->softCount += 1;
00204     }
00205 }

void qaStatisticsReport ( struct qaStatistics stats,
char *  label,
FILE *  f 
)

Definition at line 207 of file qa.c.

References qaStatistics::hardCount, qaStatistics::milliTotal, qaStatistics::softCount, and qaStatistics::testCount.

00209 {
00210 fprintf(f, "%20s:  %3d tests, %2d soft errors, %2d hard errors, %5.2f seconds\n",
00211         label, stats->testCount, stats->softCount, stats->hardCount, 
00212         0.001 * stats->milliTotal);
00213 }

void qaStatusReportOne ( FILE *  f,
struct qaStatus qs,
char *  format,
  ... 
)

Definition at line 66 of file qa.c.

References qaStatus::errMessage, qaStatus::hardError, and qaStatus::milliTime.

00068 {
00069 char *errMessage = qs->errMessage;
00070 char *severity = "ok";
00071 va_list args;
00072 va_start(args, format);
00073 if (errMessage == NULL)
00074     errMessage = "";
00075 else
00076     {
00077     if (qs->hardError)
00078         severity = "hard";
00079     else
00080         severity = "soft";
00081     }
00082   
00083 vfprintf(f, format, args);
00084 fprintf(f, " %4.3fs (%s) %s\n", 0.001*qs->milliTime, severity, errMessage);
00085 va_end(args);
00086 }

void qaStatusSoftError ( struct qaStatus qs,
char *  format,
  ... 
)

Definition at line 174 of file qa.c.

References cloneString(), dyStringAppend(), dyStringAppendC(), dyStringFree, dyStringNew, dyStringVaPrintf(), qaStatus::errMessage, freez(), dyString::string, and vaWarn().

00176 {
00177 struct dyString *dy = dyStringNew(0);
00178 va_list args;
00179 va_start(args, format);
00180 vaWarn(format, args);
00181 if (qs->errMessage)
00182     {
00183     dyStringAppend(dy, qs->errMessage);
00184     dyStringAppendC(dy, '\n');
00185     }
00186 dyStringVaPrintf(dy, format, args);
00187 va_end(args);
00188 freez(&qs->errMessage);
00189 qs->errMessage = cloneString(dy->string);
00190 dyStringFree(&dy);
00191 }

Here is the call graph for this function:

char* qaStringBetween ( char *  text,
char *  startPattern,
char *  endPattern 
)

Definition at line 13 of file qa.c.

References cloneStringZ(), and stringIn.

Referenced by qaScanForErrorMessage().

00017 {
00018 char *startMid = stringIn(startPattern, text);
00019 if (startMid != NULL)
00020     {
00021     char *endMid;
00022     int midSize;
00023     startMid += strlen(startPattern);
00024     endMid = stringIn(startMid, endPattern);
00025     if (endMid == NULL)
00026         {
00027         midSize = strlen(startMid);
00028         if (midSize > 100)
00029             midSize = 100;
00030         }
00031     else
00032         midSize = endMid - startMid;
00033     return cloneStringZ(startMid, midSize);
00034     }
00035 return NULL;
00036 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Tue Dec 25 19:13:25 2007 for blat by  doxygen 1.5.2