浏览代码

* more updates for test history

git-svn-id: trunk@14627 -
pierre 15 年之前
父节点
当前提交
134331f129
共有 1 个文件被更改,包括 251 次插入27 次删除
  1. 251 27
      tests/utils/testsuite/utests.pp

+ 251 - 27
tests/utils/testsuite/utests.pp

@@ -4,7 +4,24 @@ unit utests;
 
 
 interface
 interface
 
 
-uses cgiapp,sysutils,mysql50conn,sqldb,whtml,dbwhtml,db,
+{$ifdef FPC}
+  {$ifdef VER2_4}
+    {$define USE_FPCGI}
+  {$endif VER2_4}
+  {$ifdef VER2_5}
+    {$define USE_FPCGI}
+  {$endif VER2_5}
+{$endif FPC}
+
+{$undef USE_FPCGI}
+
+uses 
+{$ifdef USE_FPCGI}
+     fpcgi,
+{$else not USE_FPCGI}
+     cgiapp,
+{$endif not USE_FPCGI}     
+     sysutils,mysql50conn,sqldb,whtml,dbwhtml,db,
      tresults,
      tresults,
      Classes,ftFont,fpimage,fpimgcanv,fpWritePng,fpcanvas;
      Classes,ftFont,fpimage,fpimgcanv,fpWritePng,fpcanvas;
 
 
@@ -38,6 +55,7 @@ Type
     FViewVCURL : String;
     FViewVCURL : String;
     FDate : TDateTime;
     FDate : TDateTime;
     FDebug,
     FDebug,
+    FListAll,
     FNoSkipped,
     FNoSkipped,
     FOnlyFailed : Boolean;
     FOnlyFailed : Boolean;
     FRunSkipCount,
     FRunSkipCount,
@@ -56,6 +74,7 @@ Type
     Procedure FormatFailedOverview(Sender : TObject; Var CellData : String);
     Procedure FormatFailedOverview(Sender : TObject; Var CellData : String);
     Procedure FormatTestRunOverview(Sender : TObject; Var CellData : String);
     Procedure FormatTestRunOverview(Sender : TObject; Var CellData : String);
     Procedure FormatFileDetails(Sender: TObject; var CellData: String);
     Procedure FormatFileDetails(Sender: TObject; var CellData: String);
+    Procedure FormatFileIDDetails(Sender: TObject; var CellData: String);
     Procedure FormatTestResult(Sender: TObject; var CellData: String);
     Procedure FormatTestResult(Sender: TObject; var CellData: String);
     Procedure DoDrawPie(Img : TFPCustomImage; Skipped,Failed,Total : Integer);
     Procedure DoDrawPie(Img : TFPCustomImage; Skipped,Failed,Total : Integer);
   Public
   Public
@@ -72,6 +91,7 @@ Type
     Function InitCGIVars : Integer;
     Function InitCGIVars : Integer;
     Procedure DoRun; override;
     Procedure DoRun; override;
     Procedure EmitOverviewForm;
     Procedure EmitOverviewForm;
+    Procedure EmitHistoryForm;
     Procedure ShowRunResults;
     Procedure ShowRunResults;
     Procedure ShowRunComparison;
     Procedure ShowRunComparison;
     Procedure ShowOneTest;
     Procedure ShowOneTest;
@@ -295,6 +315,8 @@ begin
   FRunFailedCount:=StrToIntDef(RequestVariables['PIEFAILED'],0);
   FRunFailedCount:=StrToIntDef(RequestVariables['PIEFAILED'],0);
   S:=RequestVariables['DEBUGCGI'];
   S:=RequestVariables['DEBUGCGI'];
   FDebug:=(S='1');
   FDebug:=(S='1');
+  S:=RequestVariables['listall'];
+  FListAll:=(S='1');
   Result:=FAction;
   Result:=FAction;
 end;
 end;
 
 
@@ -506,6 +528,137 @@ begin
   ShowRunOverview;
   ShowRunOverview;
 end;
 end;
 
 
+Procedure TTestSuite.EmitHistoryForm;
+
+begin
+  ConnectToDB;
+  ContentType:='text/html';
+  EmitContentType;
+  EmitTitle(Title);
+  With FHTMLWriter do
+    begin
+    HeaderStart(1);
+    Write('View Test suite results');
+    HeaderEnd(1);
+    Write('Please specify search criteria:');
+    ParagraphStart;
+    FormStart(TestsuiteCGIURL,'');
+    if FDebug then
+      EmitHiddenVar('DEBUGCGI', '1');
+    EmitHiddenVar('action','4');
+    TableStart(2,true);
+    RowStart;
+      CellStart;
+        Write('File:');
+      CellNext;
+        EmitInput('testfilename',FTestfilename);
+      CellEnd;
+    RowNext;
+    (*   CellStart;
+        Write('FileID:');
+      CellNext;
+        EmitInput('testfileid',FTestfileid);
+      CellEnd;
+    RowNext; *)
+ 
+      CellStart;
+        Write('Operating system:');
+      CellNext;
+        ComboBoxFromQuery('os','SELECT TO_ID,TO_NAME FROM TESTOS ORDER BY TO_NAME',FOS);
+      CellEnd;
+    RowNext;
+      CellStart;
+        Write('Processor:');
+      CellNext;
+        ComboBoxFromQuery('cpu','SELECT TC_ID,TC_NAME FROM TESTCPU ORDER BY TC_NAME',FCPU);
+      CellEnd;
+    RowNext;
+      CellStart;
+        Write('Version');
+      CellNext;
+        ComboBoxFromQuery('version','SELECT TV_ID,TV_VERSION FROM TESTVERSION ORDER BY TV_VERSION DESC',FVERSION);
+      CellEnd;
+    RowNext;
+      CellStart;
+        Write('Date');
+      CellNext;
+        If (FDate=0) then
+          EmitInput('date','')
+        else
+          EmitInput('date',DateToStr(FDate));
+      CellEnd;
+        RowNext;
+        CellStart;
+        Write('Submitter');
+        CellNext;
+        If (FSubmitter='') then
+          EmitInput('submitter','')
+        else
+          EmitInput('submitter',FSubmitter);
+        CellEnd;
+       RowNext;
+        CellStart;
+        Write('Machine');
+        CellNext;
+        If (FMachine='') then
+          EmitInput('machine','')
+        else
+          EmitInput('machine',FMachine);
+        CellEnd;
+        RowNext;
+        CellStart;
+        Write('Comment');
+        CellNext;
+        If (FComment='') then
+          EmitInput('comment','')
+        else
+          EmitInput('comment',FComment);
+        CellEnd;
+        RowNext;
+        CellStart;
+        Write('Limit');
+        CellNext;
+        EmitInput('limit',IntToStr(FLimit));
+        CellEnd;
+
+        RowNext;
+        CellStart;
+        Write('Cond');
+        CellNext;
+        If (FCond='') then
+          EmitInput('cond','')
+        else
+          EmitInput('cond',FCond);
+        CellEnd;
+    RowNext;
+      CellStart;
+        Write('Only failed tests');
+      CellNext;
+        EmitCheckBox('failedonly','1',FonlyFailed);
+      CellEnd;
+    RowNext;
+      CellStart;
+        Write('Hide skipped tests');
+      CellNext;
+        EmitCheckBox('noskipped','1',FNoSkipped);
+      CellEnd;
+    RowNext;
+      CellStart;
+        Write('List all tests');
+      CellNext;
+        EmitCheckBox('listall','1',FListAll);
+      CellEnd;
+
+    RowEnd;
+    TableEnd;
+    ParaGraphStart;
+    EmitSubmitButton('','Search');
+    EmitResetButton('','Reset form');
+    FormEnd;
+    end;
+end;
+
+
 procedure TTestSuite.EmitEnd;
 procedure TTestSuite.EmitEnd;
 begin  
 begin  
   if not FNeedEnd then
   if not FNeedEnd then
@@ -897,6 +1050,11 @@ begin
       With Q do
       With Q do
         try
         try
           Open;
           Open;
+          while not EOF do
+            Next;
+          RecNo:=0;
+
+          DumpLn(Format('<p>Record count: %d </p>',[Q.RecordCount]));
           Try
           Try
             With CreateTableProducer(Q) do
             With CreateTableProducer(Q) do
               Try
               Try
@@ -909,6 +1067,9 @@ begin
                 FL:=FL+',Result';
                 FL:=FL+',Result';
                 CreateColumns(FL);
                 CreateColumns(FL);
                 OnGetRowAttributes:=@GetRunRowAttr;
                 OnGetRowAttributes:=@GetRunRowAttr;
+                TableColumns.ColumnByNAme('Id').OnGetCellContents:=
+                  @FormatFileIDDetails;
+
                 TableColumns.ColumnByNAme('Filename').OnGetCellContents:=
                 TableColumns.ColumnByNAme('Filename').OnGetCellContents:=
                   @FormatFileDetails;
                   @FormatFileDetails;
                 TableColumns.ColumnByNAme('Result').OnGetCellContents:=
                 TableColumns.ColumnByNAme('Result').OnGetCellContents:=
@@ -918,7 +1079,6 @@ begin
               Finally
               Finally
                 Free;
                 Free;
               end;
               end;
-            DumpLn(Format('<p>Record count: %d </p>',[Q.RecordCount]));
           Finally
           Finally
             Close;
             Close;
           end;
           end;
@@ -1201,7 +1361,8 @@ end;
 Procedure TTestSuite.ShowHistory;
 Procedure TTestSuite.ShowHistory;
 
 
 Var
 Var
-  S,FL : String;
+  S,FL,cpu,version,os : String;
+  date : TDateTime;
   Qry : String;
   Qry : String;
   Base, Category : string;
   Base, Category : string;
   Q : TSQLQuery;
   Q : TSQLQuery;
@@ -1211,6 +1372,7 @@ Var
   total_count, skip_count, not_skip_count : longint;
   total_count, skip_count, not_skip_count : longint;
   TS : TTestStatus;
   TS : TTestStatus;
   result_count : array[TTestStatus] of longint;
   result_count : array[TTestStatus] of longint;
+  first_date, last_date : array[TTestStatus] of TDateTime;
   FieldName,FieldValue,
   FieldName,FieldValue,
   Log,Source : String;
   Log,Source : String;
   Res : Boolean;
   Res : Boolean;
@@ -1242,11 +1404,12 @@ begin
       begin
       begin
         // This is useless as it is now
         // This is useless as it is now
         // It should be integrated into a form probably PM 
         // It should be integrated into a form probably PM 
-        Write('Only failed tests');
-        EmitCheckBox('failedonly','1',FonlyFailed);
-        Write('Hide skipped tests');
-        EmitCheckBox('noskipped','1',FNoSkipped);
+        //Write('Only failed tests');
+        //EmitCheckBox('failedonly','1',FonlyFailed);
+        //Write('Hide skipped tests');
+        //EmitCheckBox('noskipped','1',FNoSkipped);
         Res:=true;
         Res:=true;
+        EmitHistoryForm;
       end;
       end;
     If Res then
     If Res then
       begin
       begin
@@ -1254,10 +1417,7 @@ begin
       Write('Test file "'+FTestFileName+'" information:');
       Write('Test file "'+FTestFileName+'" information:');
       HeaderEnd(2);
       HeaderEnd(2);
       ParaGraphStart;
       ParaGraphStart;
-      if FTestFileID<>'' then
-        S:='SELECT * FROM TESTS WHERE T_ID='+FTestFileID
-      else
-        S:='SELECT * FROM TESTS WHERE T_NAME='+FTestFileName;
+      S:='SELECT * FROM TESTS WHERE T_ID='+FTestFileID;
       Q:=CreateDataSet(S);
       Q:=CreateDataSet(S);
       With Q do
       With Q do
         Try
         Try
@@ -1267,7 +1427,6 @@ begin
               begin
               begin
                 FieldValue:=Fields[i].AsString;
                 FieldValue:=Fields[i].AsString;
                 FieldName:=Fields[i].DisplayName;
                 FieldName:=Fields[i].DisplayName;
-                
                 if (FieldValue<>'') and (FieldValue<>'-') and 
                 if (FieldValue<>'') and (FieldValue<>'-') and 
                    (FieldName<>'T_NAME') and (FieldName<>'T_SOURCE') then
                    (FieldName<>'T_NAME') and (FieldName<>'T_SOURCE') then
                   begin
                   begin
@@ -1297,20 +1456,35 @@ begin
       ParaGraphStart;
       ParaGraphStart;
       S:='SELECT TR_ID,TR_TESTRUN_FK,TR_TEST_FK,TR_OK, TR_SKIP,TR_RESULT '
       S:='SELECT TR_ID,TR_TESTRUN_FK,TR_TEST_FK,TR_OK, TR_SKIP,TR_RESULT '
       //S:='SELECT * '
       //S:='SELECT * '
+        +',TC_NAME AS CPU, TV_VERSION AS VERSION, TO_NAME AS OS'
         +',TU_ID,TU_DATE,TU_SUBMITTER,TU_MACHINE,TU_COMMENT '
         +',TU_ID,TU_DATE,TU_SUBMITTER,TU_MACHINE,TU_COMMENT '
-        +' FROM TESTRUN LEFT JOIN TESTRESULTS ON  (TR_TESTRUN_FK=TU_ID)'
-        +' WHERE  (TR_TEST_FK='+FTestFileID+')'
-        +' AND (TR_TESTRUN_FK=TU_ID)';
+        +' FROM TESTRUN '
+        +' LEFT JOIN TESTRESULTS ON  (TR_TESTRUN_FK=TU_ID)'
+        +' LEFT JOIN TESTOS ON  (TU_OS_FK=TO_ID)'
+        +' LEFT JOIN TESTCPU ON  (TU_CPU_FK=TC_ID)'
+        +' LEFT JOIN TESTVERSION ON  (TU_VERSION_FK=TV_ID)'
+        +' WHERE  (TR_TEST_FK='+FTestFileID+')';
       If FOnlyFailed then
       If FOnlyFailed then
         S:=S+' AND (TR_OK="-")';
         S:=S+' AND (TR_OK="-")';
+      If (FCPU<>'') and (GetCPUName(FCPU)<>'All') then
+        S:=S+' AND (TU_CPU_FK='+FCPU+')';
+      If (FVersion<>'') and (GetVersionName(FVersion)<>'All')  then
+        S:=S+' AND (TU_VERSION_FK='+FVERSION+')';
+      if (FOS<>'') and (GetOSName(FOS)<>'All') then
+        S:=S+' AND (TU_OS_FK='+FOS+')';
+
       If FSubmitter<>'' then
       If FSubmitter<>'' then
         S:=S+' AND (TU_SUBMITTER='''+FSubmitter+''')';
         S:=S+' AND (TU_SUBMITTER='''+FSubmitter+''')';
       If FMachine<>'' then
       If FMachine<>'' then
         S:=S+' AND (TU_MACHINE='''+FMachine+''')';
         S:=S+' AND (TU_MACHINE='''+FMachine+''')';
       If FComment<>'' then
       If FComment<>'' then
         S:=S+' AND (TU_COMMENT='''+FComment+''')';
         S:=S+' AND (TU_COMMENT='''+FComment+''')';
+      if FDATE<>0 then
+        S:=S+' AND (TU_DATE >= '''+FormatDateTime('YYYY-MM-DD',FDate)+''')';
 
 
-      S:=S+' ORDER BY TU_ID DESC LIMIT '+IntToStr(FLimit);
+      S:=S+' ORDER BY TU_ID DESC';
+      if FDATE=0 then
+        S:=S+' LIMIT '+IntToStr(FLimit);
       Qry:=S;
       Qry:=S;
       If FDebug then
       If FDebug then
       begin
       begin
@@ -1324,6 +1498,13 @@ begin
       With Q do
       With Q do
         try
         try
           Open;
           Open;
+          
+          while not EOF do
+            Next;
+          RecNo:=0;
+          If FDebug or FListAll then
+           begin
+
             With CreateTableProducer(Q) do
             With CreateTableProducer(Q) do
               Try
               Try
                 Border:=True;
                 Border:=True;
@@ -1334,6 +1515,13 @@ begin
                   FL:=FL+',TU_MACHINE';
                   FL:=FL+',TU_MACHINE';
                 if Fcomment='' then
                 if Fcomment='' then
                   FL:=FL+',TU_COMMENT';
                   FL:=FL+',TU_COMMENT';
+                if (FOS='') or (GetOSName(FOS)='All') then
+                  FL:=FL+',OS';
+                if (FCPU='') or (GetCPUName(FCPU)='All') then
+                  FL:=FL+',CPU';
+                if (FVersion='') or (GetVersionName(FVersion)='All') then
+                  FL:=FL+',VERSION';
+                
                 CreateColumns(FL);
                 CreateColumns(FL);
                 //TableColumns.Delete(TableColumns.ColumnByName('TR_TEST_FK').Index);
                 //TableColumns.Delete(TableColumns.ColumnByName('TR_TEST_FK').Index);
                 TableColumns.ColumnByNAme('TR_TESTRUN_FK').OnGetCellContents:=
                 TableColumns.ColumnByNAme('TR_TESTRUN_FK').OnGetCellContents:=
@@ -1346,13 +1534,15 @@ begin
               Finally
               Finally
                 Free;
                 Free;
               end;
               end;
-           DumpLn(Format('<p>Record count: %d </p>',[Q.RecordCount]));
+           end;
+           
+          DumpLn(Format('<p>Record count: %d </p>',[Q.RecordCount]));
 
 
           Try
           Try
            if FDebug then
            if FDebug then
              begin
              begin
                Writeln(stdout,'FieldKind=',Fields[0].FieldKind);
                Writeln(stdout,'FieldKind=',Fields[0].FieldKind);
-               Writeln(stdout,'iDataType=',Fields[0].DataType);
+               Writeln(stdout,'DataType=',Fields[0].DataType);
                system.flush(stdout);
                system.flush(stdout);
              end;
              end;
 
 
@@ -1366,13 +1556,6 @@ begin
             begin
             begin
               Q.RecNo:=i;
               Q.RecNo:=i;
               inc(total_count);
               inc(total_count);
-              S:=Fields[0].AsString;
-              if FDebug then
-                begin
-                  Writeln(stdout,'i=',i);
-                  Writeln(stdout,'S=',S);
-                  system.flush(stdout);
-                end;
               S:=Fields[3].AsString;
               S:=Fields[3].AsString;
               if S='+' then
               if S='+' then
                 inc(OK_count)
                 inc(OK_count)
@@ -1384,21 +1567,44 @@ begin
               else
               else
                 inc(not_skip_count);
                 inc(not_skip_count);
               S:=Fields[5].AsString;
               S:=Fields[5].AsString;
+              cpu:=Fields[6].ASString;
+              version:=Fields[7].AsString;
+              os:=Fields[8].AsString;
+              date:=Fields[10].ASDateTime;
               system.val(S,resi,error);
               system.val(S,resi,error);
               if (error=0) and (Resi>=longint(FirstStatus)) and
               if (error=0) and (Resi>=longint(FirstStatus)) and
                  (Resi<=longint(LastStatus)) then
                  (Resi<=longint(LastStatus)) then
                 begin   
                 begin   
                   TS:=TTestStatus(Resi);
                   TS:=TTestStatus(Resi);
+                  if Result_count[TS]=0 then
+                    begin
+                      first_date[TS]:=date;
+                      last_date[TS]:=date;
+                    end
+                  else 
+                    begin
+                      if (date>last_date[TS]) then
+                        last_date[TS]:=date;
+                      if date<first_date[TS] then
+                        first_date[TS]:=date;
+                    end;
+                    
                   inc(Result_count[TS]);
                   inc(Result_count[TS]);
                 end
                 end
               else if Fdebug then
               else if Fdebug then
                 writeln(stdout,'Error for Result, S=',S);
                 writeln(stdout,'Error for Result, S=',S);
             end;
             end;
           DumpLn(Format('<p>Total = %d </p>',[total_count]));
           DumpLn(Format('<p>Total = %d </p>',[total_count]));
-          DumpLn(Format('<p>OK=%d Percentage= %3.2f </p>',[OK_count,OK_count*100/total_count]));
+          if Total_count > 0 then
+            DumpLn(Format('<p>OK=%d Percentage= %3.2f </p>',[OK_count,OK_count*100/total_count]));
+          if Skip_count > 0 then
+            DumpLn(Format('<p>Skipped=%d Percentage= %3.2f </p>',[Skip_count,Skip_count*100/total_count]));
           For TS:=FirstStatus to LastStatus do
           For TS:=FirstStatus to LastStatus do
             if Result_count[TS]>0 then
             if Result_count[TS]>0 then
-              DumpLn(Format('%s=%d </p>', [StatusText[TS],Result_count[TS]]));
+              DumpLn(Format('<p>%s=%d From %s to %s</p>',
+                [StatusText[TS],Result_count[TS],
+                 DateTimeToStr(first_date[TS]),
+                 DateTimeToStr(last_date[TS])]));
 
 
           Finally
           Finally
             Close;
             Close;
@@ -1730,6 +1936,24 @@ begin
   CellData:=Format('<A HREF="%s">%s</A>',[S,CellData]);
   CellData:=Format('<A HREF="%s">%s</A>',[S,CellData]);
 end;
 end;
 
 
+procedure TTestSuite.FormatFileIDDetails(Sender: TObject; var CellData: String);
+
+Var
+  S: String;
+  P : TTableProducer;
+
+begin
+  P:=(Sender as TTableProducer);
+  if FVersion<>'' then
+    S:=Format(TestSuiteCGIURL + '?action=4&version=%s&testfileid=%s',
+       [FVersion,P.DataSet.FieldByName('Id').AsString])
+  else 
+    S:=Format(TestSuiteCGIURL + '?action=4&testfileid=%s',
+       [P.DataSet.FieldByName('Id').AsString]);
+  CellData:=Format('<A HREF="%s">%s</A>',[S,CellData]);
+end;
+
+
 procedure TTestSuite.FormatFileDetails(Sender: TObject; var CellData: String);
 procedure TTestSuite.FormatFileDetails(Sender: TObject; var CellData: String);
 
 
 Var
 Var