+ Changed database structure after suggestion of florian

This commit is contained in:
michael 2003-10-03 22:51:02 +00:00
parent 7ee24daeef
commit 67082bc610
2 changed files with 81 additions and 22 deletions

View File

@ -328,7 +328,8 @@ Var
TestCPUID : Integer;
TestOSID : Integer;
TestVersionID : Integer;
TestRunID : Integer;
Procedure GetIDs;
begin
@ -343,6 +344,15 @@ begin
Verbose(V_Error,'NO ID for version "'+TestVersion+'" found.');
If (Round(TestDate)=0) then
Testdate:=Date;
TestRunID:=GetRunID(TestOSID,TestCPUID,TestVersionID,TestDate);
If (TestRunID=-1) then
begin
TestRunID:=AddRun(TestOSID,TestCPUID,TestVersionID,TestDate);
If TestRUnID=-1 then
Verbose(V_Error,'Could not insert new testrun record!');
end
else
CleanTestRun(TestRunID);
end;
Function GetLog(FN : String) : String;
@ -387,10 +397,7 @@ begin
TestLog:=GetLog(Line)
else
TestLog:='';
AddTestResult(ID,TestOSID,TestCPUID,TestVersionID,Ord(TS),
TestOK[TS],TestSkipped[TS],
TestLog,
TestDate);
AddTestResult(ID,TestRunID,Ord(TS),TestOK[TS],TestSkipped[TS],TestLog);
end;
end
end
@ -416,7 +423,10 @@ end.
{
$Log$
Revision 1.4 2002-12-24 21:47:49 peter
Revision 1.5 2003-10-03 22:51:02 michael
+ Changed database structure after suggestion of florian
Revision 1.4 2002/12/24 21:47:49 peter
* NeedTarget, SkipTarget, SkipCPU added
* Retrieve compiler info in a single call for 1.1 compiler

View File

@ -16,13 +16,15 @@ Function GetTestID(Name : string) : Integer;
Function GetOSID(Name : String) : Integer;
Function GetCPUID(Name : String) : Integer;
Function GetVersionID(Name : String) : Integer;
Function GetRunID(OSID, CPUID, VERSIONID : Integer; Date : TDateTime) : Integer;
Function AddRun(OSID, CPUID, VERSIONID : Integer; Date : TDateTime) : Integer;
Function AddTest(Name : String; AddSource : Boolean) : Integer;
Function UpdateTest(ID : Integer; Info : TConfig; Source : String) : Boolean;
Function AddTestResult(TestID,OSID,CPUID,VersionID,TestRes : Integer;
Function AddTestResult(TestID,RunID,TestRes : Integer;
OK, Skipped : Boolean;
Log : String;
TestDate : TDateTime) : Integer;
Log : String) : Integer;
Function RequireTestID(Name : String): Integer;
Function CleanTestRun(ID : Integer) : Boolean;
{ ---------------------------------------------------------------------
Low-level DB access.
@ -39,6 +41,7 @@ Procedure FreeQueryResult (Res : TQueryResult);
Function GetResultField (Res : TQueryResult; Id : Integer) : String;
Function IDQuery(Qry : String) : Integer;
Function EscapeSQL( S : String) : String;
Function SQLDate(D : TDateTime) : String;
Implementation
@ -144,12 +147,16 @@ begin
end;
Function SQLDate(D : TDateTime) : String;
begin
Result:=FormatDateTime('YYYY/MM/DD',D);
end;
{ ---------------------------------------------------------------------
High-level access
---------------------------------------------------------------------}
Function GetTestID(Name : string) : Integer;
@ -194,6 +201,40 @@ begin
Result:=IDQuery(Format(SFromName,[Name]));
end;
Function GetRunID(OSID, CPUID, VERSIONID : Integer; Date : TDateTime) : Integer;
Const
SFromIDS = 'SELECT TU_ID FROM TESTRUN WHERE '+
' (TU_OS_FK=%d) '+
' AND (TU_CPU_FK=%d) '+
' AND (TU_VERSION_FK=%d) '+
' AND (TU_DATE="%s")';
begin
Result:=IDQuery(Format(SFromIDS,[OSID,CPUID,VERSIONID,SQLDate(Date)]));
end;
Function AddRun(OSID, CPUID, VERSIONID : Integer; Date : TDateTime) : Integer;
Const
SInsertRun = 'INSERT INTO TESTRUN '+
'(TU_OS_FK,TU_CPU_FK,TU_VERSION_FK,TU_DATE)'+
' VALUES '+
'(%d,%d,%d,"%s")';
Var
Res : TQueryResult;
begin
If RunQuery(Format(SInsertRun,[OSID,CPUID,VERSIONID,SQLDate(Date)]),Res) then
Result:=mysql_insert_id(@connection)
else
Result:=-1;
end;
Function AddTest(Name : String; AddSource : Boolean) : Integer;
Const
@ -263,18 +304,15 @@ begin
Result:=RunQuery(Qry,res)
end;
Function AddTestResult(TestID,OSID,CPUID,VersionID,TestRes : Integer;
Function AddTestResult(TestID,RunID,TestRes : Integer;
OK, Skipped : Boolean;
Log : String;
TestDate : TDateTime) : Integer;
Log : String) : Integer;
Const
SInsertRes = 'Insert into TESTRESULTS ('+
' TR_TEST_FK, TR_DATE, TR_CPU_FK, TR_OS_FK,TR_VERSION_FK,'+
' TR_OK, TR_SKIP, TR_RESULT, TR_LOG)'+
'VALUES ('+
' %d,"%s",%d,%d,%d,'+
' "%s","%s",%d,"%s")';
SInsertRes='Insert into TESTRESULTS '+
'(TR_TEST_FK,TR_TESTRUN_FK,TR_OK,TR_SKIP,TR_RESULT,TR_LOG) '+
' VALUES '+
'(%d,%d,"%s","%s",%d,"%s") ';
Var
Qry : String;
@ -282,9 +320,8 @@ Var
begin
Result:=-1;
Qry:=Format(SInsertRes,[TestID,FormatDateTime('yyyymmdd',TestDate),CPUID,OSID,VersionID,
B[OK],B[Skipped],TestRes,EscapeSQL(Log)
]);
Qry:=Format(SInsertRes,
[TestID,RunID,B[OK],B[Skipped],TestRes,EscapeSQL(Log)]);
If RunQuery(Qry,Res) then
Result:=mysql_insert_id(@connection);
end;
@ -299,4 +336,16 @@ begin
Verbose(V_WARNING,'Could not find or create entry for test '+Name);
end;
Function CleanTestRun(ID : Integer) : Boolean;
Const
SDeleteRun = 'DELETE FROM TESTRESULTS WHERE TR_TESTRUN_FK=%d';
Var
Res : TQueryResult;
begin
Result:=RunQuery(Format(SDeleteRun,[ID]),Res);
end;
end.