From d5f0cc1f7d91e05d89259e6f4a18fe31cc4b7f43 Mon Sep 17 00:00:00 2001 From: pierre Date: Fri, 22 Jan 2010 15:33:34 +0000 Subject: [PATCH] + Add explicit Port for mysql connection git-svn-id: trunk@14771 - --- tests/utils/dbdigest.pp | 14 +++++++++----- tests/utils/dbtests.pp | 27 +++++++++++++++++---------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/tests/utils/dbdigest.pp b/tests/utils/dbdigest.pp index 2cd4930961..58d0089090 100644 --- a/tests/utils/dbdigest.pp +++ b/tests/utils/dbdigest.pp @@ -65,6 +65,7 @@ TConfigOpt = ( soHost, coUserName, coPassword, + coPort, coLogFile, coOS, coCPU, @@ -86,6 +87,7 @@ ConfigStrings : Array [TConfigOpt] of string = ( 'host', 'username', 'password', + 'port', 'logfile', 'os', 'cpu', @@ -101,7 +103,7 @@ ConfigStrings : Array [TConfigOpt] of string = ( ); ConfigOpts : Array[TConfigOpt] of char - = ('d','h','u','p','l','o','c','a','v','t','s','m','C','S','r','V'); + = ('d','h','u','p','P','l','o','c','a','v','t','s','m','C','S','r','V'); Var TestOS, @@ -112,6 +114,7 @@ Var HostName, UserName, Password, + Port, LogFileName, Submitter, Machine, @@ -127,12 +130,13 @@ begin soHost : HostName:=Value; coUserName : UserName:=Value; coPassword : Password:=Value; + coPort : Port:=Value; coLogFile : LogFileName:=Value; coOS : TestOS:=Value; coCPU : TestCPU:=Value; coCategory : TestCategory:=Value; coVersion : TestVersion:=Value; - coDate : + coDate : begin { Formated like YYYYMMDDhhmm } if Length(value)=12 then @@ -145,7 +149,7 @@ begin TestDate:=EncodeDate(year,month,day)+EncodeTime(hour,min,0,0); end else - Verbose(V_Error,'Error in date format, use YYYYMMDDhhmm'); + Verbose(V_Error,'Error in date format, use YYYYMMDDhhmm'); end; coSubmitter : Submitter:=Value; coMachine : Machine:=Value; @@ -362,7 +366,7 @@ begin TestLog:=GetExecuteLog(Line); if pos(failed_to_compile,TestLog)=1 then TestLog:=GetLog(Line); - end + end else TestLog:=''; AddTestResult(ID,TestRunID,Ord(TS),TestOK[TS],TestSkipped[TS],TestLog); @@ -397,7 +401,7 @@ begin ProcessCommandLine; If LogFileName<>'' then begin - ConnectToDatabase(DatabaseName,HostName,UserName,Password); + ConnectToDatabase(DatabaseName,HostName,UserName,Password,Port); GetIDs; ProcessFile(LogFileName); UpdateTestRun; diff --git a/tests/utils/dbtests.pp b/tests/utils/dbtests.pp index 0efbd38eaf..911eb7e73a 100644 --- a/tests/utils/dbtests.pp +++ b/tests/utils/dbtests.pp @@ -10,7 +10,7 @@ Uses mysql4, {$else} mysql, -{$endif} +{$endif} testu; { --------------------------------------------------------------------- @@ -40,7 +40,7 @@ Function CleanTestRun(ID : Integer) : Boolean; Type TQueryResult = PMYSQL_RES; -Function ConnectToDatabase(DatabaseName,Host,User,Password : String) : Boolean; +Function ConnectToDatabase(DatabaseName,Host,User,Password,Port : String) : Boolean; Procedure DisconnectDatabase; Function RunQuery (Qry : String; Var res : TQueryResult) : Boolean ; Procedure FreeQueryResult (Res : TQueryResult); @@ -67,19 +67,26 @@ Var Connection : TMYSQL; -Function ConnectToDatabase(DatabaseName,Host,User,Password : String) : Boolean; +Function ConnectToDatabase(DatabaseName,Host,User,Password,Port : String) : Boolean; Var S : String; - + PortNb : longint; + Error : word; begin - Verbose(V_DEBUG,'Connection params : '+DatabaseName+' '+Host+' '+User+' '+Password); -{$ifdef ver1_0} + Verbose(V_DEBUG,'Connection params : '+DatabaseName+' '+Host+' '+User+' '+Password+' '+Port); + if Port<>'' then + begin + Val(Port,PortNb,Error); + if Error<>0 then + PortNb:=0; + end; +{$ifdef ver1_0} Result:=mysql_connect(@Connection,PChar(Host),PChar(User),PChar(Password))<>Nil; -{$else} +{$else} mysql_init(@Connection); - Result:=mysql_real_connect(@Connection,PChar(Host),PChar(User),PChar(Password),Nil,0,Nil,0)<>Nil; -{$endif} + Result:=mysql_real_connect(@Connection,PChar(Host),PChar(User),PChar(Password),Nil,PortNb,Nil,0)<>Nil; +{$endif} If Not Result then begin S:=Strpas(mysql_error(@connection)); @@ -294,7 +301,7 @@ begin else if FileExists(FileName+'.pp') then FileName := FileName + '.pp' else exit; - + Verbose(V_Debug,'Reading '+FileName); assign(t,FileName); {$I-}