From 833ba1266437e4a83ceb052ad87e1077d91a6eb5 Mon Sep 17 00:00:00 2001 From: Shane Caraveo Date: Mon, 15 Jan 2001 00:56:23 +0000 Subject: [PATCH] fix file reading, add results --- sapi/isapi/stresstest/stresstest.cpp | 70 +++++++++++++++++----------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/sapi/isapi/stresstest/stresstest.cpp b/sapi/isapi/stresstest/stresstest.cpp index 625a3f2817..d43bc5ef57 100644 --- a/sapi/isapi/stresstest/stresstest.cpp +++ b/sapi/isapi/stresstest/stresstest.cpp @@ -36,11 +36,18 @@ HANDLE StartNow; // quick and dirty environment typedef CMapStringToString TEnvironment; TEnvironment IsapiEnvironment; + +typedef struct _TResults { + LONG ok; + LONG bad; +} TResults; + CStringArray IsapiFileList; // list of filenames CStringArray TestNames; // --TEST-- CStringArray IsapiGetData; // --GET-- CStringArray IsapiPostData; // --POST-- CStringArray IsapiMatchData; // --EXPECT-- +CArray Results; typedef struct _TIsapiContext { HANDLE in; @@ -207,6 +214,10 @@ BOOL ParseTestFile(const char *path, const char *fn) enum state {none, test, skipif, post, get, file, expect} parsestate = none; FILE *fp = fopen(filename, "r"); + char *tn = _tempnam(temppath,"pht."); + char *en = _tempnam(temppath,"exp."); + FILE *ft = fopen(tn, "w+"); + FILE *fe = fopen(en, "w+"); if (fp) { while (fgets(line,sizeof(line)-1,fp)) { if (line[0]=='-') { @@ -245,36 +256,25 @@ BOOL ParseTestFile(const char *path, const char *fn) cGet += line; break; case file: - cFile += line; + fputs(line, ft); break; case expect: - cExpect += line; + fputs(line, fe); break; } } fclose(fp); - - if (!cTest.IsEmpty() && !cFile.IsEmpty() && !cExpect.IsEmpty()) { - BOOL created = FALSE; - char *fn = _tempnam(temppath,"pht."); - char *en = _tempnam(temppath,"exp."); - FILE *fp = fopen(fn, "w+"); - FILE *fe = fopen(en, "w+"); - if (fp && en) { - fwrite(cFile, cFile.GetLength(), 1, fp); - fwrite(cExpect, cExpect.GetLength(), 1, fe); - IsapiFileList.Add(fn); - TestNames.Add(cTest); - IsapiGetData.Add(cGet); - IsapiPostData.Add(cPost); - IsapiMatchData.Add(en); - created = TRUE; - } - if (fp) fclose(fp); - if (fe) fclose(fe); - - return created; + fclose(ft); + fclose(fe); + + if (!cTest.IsEmpty()) { + IsapiFileList.Add(tn); + TestNames.Add(cTest); + IsapiGetData.Add(cGet); + IsapiPostData.Add(cPost); + IsapiMatchData.Add(en); + return TRUE; } } return FALSE; @@ -322,9 +322,19 @@ void DoTestFiles(const char *filelist, const char *environment) return; } + Results.SetSize(IsapiFileList.GetSize()); + ReadGlobalEnvironment(environment); DoThreads(); + + printf("\r\nRESULTS:\r\n"); + // show results: + DWORD r = Results.GetSize(); + for (DWORD i=0; i< r; i++) { + TResults result = Results.GetAt(i); + printf("%s\r\nOK: %d FAILED: %d\r\n", TestNames.GetAt(i), result.ok, result.bad); + } } int main(int argc, char* argv[]) { @@ -409,11 +419,15 @@ DWORD CALLBACK IsapiThread(void *p) for (DWORD i=0; i