From 42b1b44ad4957ae3bc6aa1d7d33af5422627aca5 Mon Sep 17 00:00:00 2001 From: Shane Caraveo Date: Mon, 15 Jan 2001 01:52:47 +0000 Subject: [PATCH] test now produce valid OK or FAIL. --- sapi/isapi/stresstest/notes.txt | 5 +- sapi/isapi/stresstest/stresstest.cpp | 88 ++++++++++++++++++---------- 2 files changed, 59 insertions(+), 34 deletions(-) diff --git a/sapi/isapi/stresstest/notes.txt b/sapi/isapi/stresstest/notes.txt index e2ee5c2161..454e88ebc1 100644 --- a/sapi/isapi/stresstest/notes.txt +++ b/sapi/isapi/stresstest/notes.txt @@ -37,13 +37,10 @@ run: stresstest T c:\php4-source TODO: -Make an apropriate test of the output against the EXPECT data for the test files, right now it simply doesn't work since I'm burnt (tired that is). - Make more options configurable: number of threads, itterations, etc. Improve stdout output to make it more usefull -Log totals for each test. - Implement support for SKIPIF +Improve speed of CompareFile function (too slow on big files). diff --git a/sapi/isapi/stresstest/stresstest.cpp b/sapi/isapi/stresstest/stresstest.cpp index 3933fb0a91..6c74efeed8 100644 --- a/sapi/isapi/stresstest/stresstest.cpp +++ b/sapi/isapi/stresstest/stresstest.cpp @@ -83,12 +83,11 @@ DWORD CALLBACK IsapiThread(void *); int stress_main(const char *filename, const char *arg, const char *postfile, - const char *matchdata, - const char *testname); + const char *matchdata); -BOOL test = FALSE; +BOOL bUseTestFiles = FALSE; char temppath[MAX_PATH]; void stripcrlf(char *line) @@ -99,6 +98,37 @@ void stripcrlf(char *line) if (line[l]==10 || line[l]==13) line[l]=0; } + +BOOL CompareFiles(const char*f1, const char*f2) +{ + FILE *fp1 = fopen(f1,"r"); + if (!fp1) return FALSE; + FILE *fp2 = fopen(f2,"r"); + if (!fp2) { + fclose(fp1); + return FALSE; + } + + CString file1, file2, line; + char buf[1024]; + while (fgets(buf, sizeof(buf), fp1)) { + line = buf; + line.TrimLeft(); + line.TrimRight(); + file1+=line; + } + fclose(fp1); + while (fgets(buf, sizeof(buf), fp2)) { + line = buf; + line.TrimLeft(); + line.TrimRight(); + file2+=line; + } + fclose(fp2); + + return file1==file2; +} + BOOL ReadGlobalEnvironment(const char *environment) { if (environment) { @@ -154,6 +184,8 @@ BOOL ReadFileList(const char *filelist) i++; } + Results.SetSize(TestNames.GetSize()); + fclose(fp); return IsapiFileList.GetSize() > 0; } @@ -371,7 +403,7 @@ int main(int argc, char* argv[]) { printf("USAGE: stresstest [L|T] filelist [environment]\r\n"); return 0; } else { - if (argv[1][0]=='T') test = TRUE; + if (argv[1][0]=='T') bUseTestFiles = TRUE; if (argc > 1) filelist = argv[2]; if (argc > 2) environment = argv[3]; } @@ -416,7 +448,7 @@ int main(int argc, char* argv[]) { return -1; } - if (test) { + if (bUseTestFiles) { char TestPath[MAX_PATH]; if (filelist != NULL) _snprintf(TestPath, sizeof(TestPath)-1, "%s\\tests", filelist); @@ -443,16 +475,24 @@ DWORD CALLBACK IsapiThread(void *p) for (DWORD j=0; j