mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-05 21:28:21 +02:00
* synchronized with trunk
git-svn-id: branches/wasm@48460 -
This commit is contained in:
commit
8b52969b62
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -3877,6 +3877,8 @@ packages/fcl-net/src/sslsockets.pp svneol=native#text/plain
|
||||
packages/fcl-net/src/ssockets.pp svneol=native#text/plain
|
||||
packages/fcl-net/src/unix/resolve.inc svneol=native#text/plain
|
||||
packages/fcl-net/src/win/resolve.inc svneol=native#text/plain
|
||||
packages/fcl-net/tests/netdbtest.pp svneol=native#text/plain
|
||||
packages/fcl-net/tests/tresolvertests.pp svneol=native#text/plain
|
||||
packages/fcl-passrc/Makefile svneol=native#text/plain
|
||||
packages/fcl-passrc/Makefile.fpc svneol=native#text/plain
|
||||
packages/fcl-passrc/Makefile.fpc.fpcmake svneol=native#text/plain
|
||||
@ -16307,6 +16309,7 @@ tests/test/units/sysutils/tfexpand2.pp svneol=native#text/plain
|
||||
tests/test/units/sysutils/tffirst.pp svneol=native#text/plain
|
||||
tests/test/units/sysutils/tfile1.pp svneol=native#text/plain
|
||||
tests/test/units/sysutils/tfile2.pp svneol=native#text/plain
|
||||
tests/test/units/sysutils/tfileage.pp svneol=native#text/pascal
|
||||
tests/test/units/sysutils/tfilename.pp svneol=native#text/plain
|
||||
tests/test/units/sysutils/tfloattostr.pp svneol=native#text/plain
|
||||
tests/test/units/sysutils/tformat.pp svneol=native#text/plain
|
||||
|
@ -23,9 +23,10 @@ uses SysUtils,Classes;
|
||||
|
||||
Type
|
||||
TEventLog = Class;
|
||||
TLogType = (ltSystem,ltFile);
|
||||
TLogType = (ltSystem,ltFile,ltStdOut,ltStdErr);
|
||||
TLogCodeEvent = Procedure (Sender : TObject; Var Code : DWord) of Object;
|
||||
TLogCategoryEvent = Procedure (Sender : TObject; Var Code : Word) of Object;
|
||||
TLogMessageEvent = Procedure (Sender : TObject; EventType : TEventType; Const Msg : String) of Object;
|
||||
|
||||
TEventLog = Class(TComponent)
|
||||
Private
|
||||
@ -44,6 +45,7 @@ Type
|
||||
FOnGetCustomCategory : TLogCategoryEvent;
|
||||
FOnGetCustomEventID : TLogCodeEvent;
|
||||
FOnGetCustomEvent : TLogCodeEvent;
|
||||
FOnLogMessage: TLogMessageEvent;
|
||||
FPaused : Boolean;
|
||||
procedure SetActive(const Value: Boolean);
|
||||
procedure SetIdentification(const Value: String);
|
||||
@ -52,16 +54,20 @@ Type
|
||||
procedure DeActivateLog;
|
||||
procedure ActivateFileLog;
|
||||
procedure SetFileName(const Value: String);
|
||||
procedure ActivateIOLog;
|
||||
procedure ActivateSystemLog;
|
||||
function DefaultFileName: String;
|
||||
function FormatLogMessage(EventType : TEventType; const Msg: String): String;
|
||||
procedure WriteFileLog(EventType : TEventType; const Msg: String);
|
||||
procedure WriteSystemLog(EventType: TEventType; const Msg: String);
|
||||
procedure WriteIOLog(EventType: TEventType; const Msg: String; var OutFile: TextFile);
|
||||
procedure DeActivateFileLog;
|
||||
procedure DeActivateSystemLog;
|
||||
procedure CheckIdentification;
|
||||
Procedure DoGetCustomEventID(Var Code : DWord);
|
||||
Procedure DoGetCustomEventCategory(Var Code : Word);
|
||||
Procedure DoGetCustomEvent(Var Code : DWord);
|
||||
Procedure DoLogMessage(EventType : TEventType; const Msg: String);
|
||||
Protected
|
||||
Procedure CheckInactive;
|
||||
Procedure EnsureActive;
|
||||
@ -101,6 +107,7 @@ Type
|
||||
Property OnGetCustomCategory : TLogCategoryEvent Read FOnGetCustomCategory Write FOnGetCustomCategory;
|
||||
Property OnGetCustomEventID : TLogCodeEvent Read FOnGetCustomEventID Write FOnGetCustomEventID;
|
||||
Property OnGetCustomEvent : TLogCodeEvent Read FOnGetCustomEvent Write FOnGetCustomEvent;
|
||||
Property OnLogMessage : TLogMessageEvent read FOnLogMessage write FOnLogMessage;
|
||||
Property Paused : Boolean Read FPaused Write FPaused;
|
||||
End;
|
||||
|
||||
@ -114,6 +121,8 @@ Resourcestring
|
||||
SLogDebug = 'Debug';
|
||||
SLogCustom = 'Custom (%d)';
|
||||
SErrLogFailedMsg = 'Failed to log entry (Error: %s)';
|
||||
SErrLogOpenStdOut = 'Standard Output not available for logging';
|
||||
SErrLogOpenStdErr = 'Standard Error not available for logging';
|
||||
|
||||
implementation
|
||||
|
||||
@ -201,20 +210,31 @@ begin
|
||||
Case FlogType of
|
||||
ltFile : WriteFileLog(EventType,Msg);
|
||||
ltSystem : WriteSystemLog(EventType,Msg);
|
||||
ltStdOut : WriteIOLog(EventType,Msg,StdOut);
|
||||
ltStdErr : WriteIOLog(EventType,Msg,StdErr);
|
||||
end;
|
||||
DoLogMessage(EventType, Msg);
|
||||
end;
|
||||
|
||||
procedure TEventLog.WriteFileLog(EventType : TEventType; const Msg : String);
|
||||
|
||||
function TEventLog.FormatLogMessage(EventType : TEventType; const Msg: String): String;
|
||||
Var
|
||||
S,TS,T : String;
|
||||
TS,T : String;
|
||||
|
||||
begin
|
||||
If FTimeStampFormat='' then
|
||||
FTimeStampFormat:='yyyy-mm-dd hh:nn:ss.zzz';
|
||||
TS:=FormatDateTime(FTimeStampFormat,Now);
|
||||
T:=EventTypeToString(EventType);
|
||||
S:=Format('%s [%s %s] %s%s',[Identification,TS,T,Msg,LineEnding]);
|
||||
Result:=Format('%s [%s %s] %s',[Identification,TS,T,Msg]);
|
||||
end;
|
||||
|
||||
procedure TEventLog.WriteFileLog(EventType : TEventType; const Msg : String);
|
||||
|
||||
Var
|
||||
S : String;
|
||||
|
||||
begin
|
||||
S:=FormatLogMessage(EventType, Msg)+LineEnding;
|
||||
try
|
||||
FStream.WriteBuffer(S[1],Length(S));
|
||||
S:='';
|
||||
@ -226,6 +246,11 @@ begin
|
||||
Raise ELogError.CreateFmt(SErrLogFailedMsg,[S]);
|
||||
end;
|
||||
|
||||
procedure TEventLog.WriteIOLog(EventType: TEventType; const Msg: String; var OutFile: TextFile);
|
||||
begin
|
||||
Writeln(OutFile,FormatLogMessage(EventType,Msg));
|
||||
end;
|
||||
|
||||
procedure TEventLog.Log(const Fmt: String; Args: array of const);
|
||||
begin
|
||||
Log(Format(Fmt,Args));
|
||||
@ -249,6 +274,8 @@ begin
|
||||
Case FLogType of
|
||||
ltFile : ActivateFileLog;
|
||||
ltSystem : ActivateSystemLog;
|
||||
ltStdOut,
|
||||
ltStdErr : ActivateIOLog;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -258,6 +285,8 @@ begin
|
||||
Case FLogType of
|
||||
ltFile : DeActivateFileLog;
|
||||
ltSystem : DeActivateSystemLog;
|
||||
{ nothing to do here }
|
||||
ltStdOut,ltStdErr : ;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -279,6 +308,24 @@ begin
|
||||
FStream.Seek(0,soFromEnd);
|
||||
end;
|
||||
|
||||
Procedure TEventLog.ActivateIOLog;
|
||||
|
||||
var
|
||||
errmsg: String;
|
||||
m: LongInt;
|
||||
|
||||
begin
|
||||
if FLogtype = ltStdOut then begin
|
||||
m := TextRec(StdOut).Mode;
|
||||
errmsg := SErrLogOpenStdOut;
|
||||
end else begin
|
||||
m := TextRec(StdErr).Mode;
|
||||
errmsg := SErrLogOpenStdErr;
|
||||
end;
|
||||
if (m <> fmOutput) and (m <> fmAppend) then
|
||||
raise ELogError.Create(errmsg);
|
||||
end;
|
||||
|
||||
Procedure TEventLog.DeActivateFileLog;
|
||||
|
||||
begin
|
||||
@ -354,6 +401,13 @@ begin
|
||||
FOnGetCustomEvent(Self,Code);
|
||||
end;
|
||||
|
||||
Procedure TEventLog.DoLogMessage(EventType : TEventType; const Msg: String);
|
||||
|
||||
begin
|
||||
If Assigned(FOnLogMessage) then
|
||||
FOnLogMessage(Self,EventType,Msg);
|
||||
end;
|
||||
|
||||
|
||||
destructor TEventLog.Destroy;
|
||||
begin
|
||||
|
File diff suppressed because it is too large
Load Diff
4615
packages/fcl-net/tests/netdbtest.pp
Normal file
4615
packages/fcl-net/tests/netdbtest.pp
Normal file
File diff suppressed because it is too large
Load Diff
28
packages/fcl-net/tests/tresolvertests.pp
Normal file
28
packages/fcl-net/tests/tresolvertests.pp
Normal file
@ -0,0 +1,28 @@
|
||||
program tresolvertests;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
Classes, consoletestrunner, netdbtest;
|
||||
|
||||
type
|
||||
|
||||
{ TMyTestRunner }
|
||||
|
||||
TMyTestRunner = class(TTestRunner)
|
||||
protected
|
||||
// override the protected methods of TTestRunner to customize its behavior
|
||||
end;
|
||||
|
||||
var
|
||||
Application: TMyTestRunner;
|
||||
|
||||
begin
|
||||
DefaultFormat:=fPlain;
|
||||
DefaultRunAllTests:=True;
|
||||
Application := TMyTestRunner.Create(nil);
|
||||
Application.Initialize;
|
||||
Application.Title:='resolvertests';
|
||||
Application.Run;
|
||||
Application.Free;
|
||||
end.
|
@ -70,7 +70,7 @@ unit cpu;
|
||||
function InterlockedCompareExchange128(var Target: Int128Rec; NewValue: Int128Rec; Comperand: Int128Rec): Int128Rec;
|
||||
begin
|
||||
{$if FPC_FULLVERSION >= 30101}
|
||||
{$ifndef FPC_PIC}
|
||||
{$ifndef FPC_PIC}
|
||||
if _RTMSupport then
|
||||
begin
|
||||
asm
|
||||
@ -92,11 +92,10 @@ unit cpu;
|
||||
{ 8a: 0f 01 d5 xend }
|
||||
.byte 0x0f, 0x01, 0xd5
|
||||
{$endif}
|
||||
xend
|
||||
end;
|
||||
end
|
||||
else
|
||||
{$endif FPC_PIC}
|
||||
{$endif FPC_PIC}
|
||||
{$endif FPC_FULLVERSION >= 30101}
|
||||
RunError(217);
|
||||
end;
|
||||
|
@ -55,6 +55,10 @@ uses
|
||||
{$DEFINE HAVECLOCKGETTIME}
|
||||
{$ENDIF}
|
||||
|
||||
{$if defined(LINUX)}
|
||||
{$DEFINE HAS_STATX}
|
||||
{$endif}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -547,12 +551,26 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
Function FileAge (Const FileName : RawByteString): Int64;
|
||||
Var
|
||||
Info : Stat;
|
||||
SystemFileName: RawByteString;
|
||||
{$ifdef HAS_STATX}
|
||||
Infox : Statx;
|
||||
{$endif HAS_STATX}
|
||||
begin
|
||||
SystemFileName:=ToSingleByteFileSystemEncodedFileName(FileName);
|
||||
|
||||
{$ifdef HAS_STATX}
|
||||
{ first try statx }
|
||||
if (Fpstatx(0,pchar(SystemFileName),0,STATX_MTIME or STATX_MODE,Infox)>=0) and not(fpS_ISDIR(Infox.stx_mode)) then
|
||||
begin
|
||||
Result:=Infox.stx_mtime.tv_sec;
|
||||
exit;
|
||||
end;
|
||||
{$endif HAS_STATX}
|
||||
|
||||
If (fpstat(pchar(SystemFileName),Info)<0) or fpS_ISDIR(info.st_mode) then
|
||||
exit(-1)
|
||||
else
|
||||
|
@ -2429,7 +2429,7 @@ LOGEXT=.testlog .tbslog .tbflog .webtbslog .webtbflog
|
||||
TESTUNITDIRS=system dos crt objects strings sysutils math sharemem strutils matrix lineinfo ucomplex fpwidestring cpu fmtbcd windows classes character dateutil fpcunit softfpu variants sortbase sortalgs linux unixutil types nullable
|
||||
TESTDIRECTDIRS=
|
||||
TESTSUBDIRS=cg cg/variants cg/cdecl cpu16 cpu16/i8086 library opt $(addprefix units/,$(TESTUNITDIRS))
|
||||
TESTPACKAGESDIRS=win-base webtbs hash fcl-registry fcl-process zlib fcl-db fcl-xml cocoaint bzip2
|
||||
TESTPACKAGESDIRS=win-base webtbs hash fcl-registry fcl-process zlib fcl-db fcl-xml cocoaint bzip2 fcl-net
|
||||
TESTPACKAGESUBDIRS=$(addprefix packages/,$(TESTPACKAGESDIRS))
|
||||
TESTPACKAGESDIRECTDIRS=rtl-objpas rtl-generics hash regexpr fcl-registry
|
||||
TESTPACKAGESDIRECTSUBDIRS=$(addprefix ../packages/,$(addsuffix /tests,$(TESTPACKAGESDIRECTDIRS)))
|
||||
|
@ -162,7 +162,7 @@ LOGEXT=.testlog .tbslog .tbflog .webtbslog .webtbflog
|
||||
TESTUNITDIRS=system dos crt objects strings sysutils math sharemem strutils matrix lineinfo ucomplex fpwidestring cpu fmtbcd windows classes character dateutil fpcunit softfpu variants sortbase sortalgs linux unixutil types nullable
|
||||
TESTDIRECTDIRS=
|
||||
TESTSUBDIRS=cg cg/variants cg/cdecl cpu16 cpu16/i8086 library opt $(addprefix units/,$(TESTUNITDIRS))
|
||||
TESTPACKAGESDIRS=win-base webtbs hash fcl-registry fcl-process zlib fcl-db fcl-xml cocoaint bzip2
|
||||
TESTPACKAGESDIRS=win-base webtbs hash fcl-registry fcl-process zlib fcl-db fcl-xml cocoaint bzip2 fcl-net
|
||||
TESTPACKAGESUBDIRS=$(addprefix packages/,$(TESTPACKAGESDIRS))
|
||||
TESTPACKAGESDIRECTDIRS=rtl-objpas rtl-generics hash regexpr fcl-registry
|
||||
TESTPACKAGESDIRECTSUBDIRS=$(addprefix ../packages/,$(addsuffix /tests,$(TESTPACKAGESDIRECTDIRS)))
|
||||
|
10
tests/test/units/sysutils/tfileage.pp
Normal file
10
tests/test/units/sysutils/tfileage.pp
Normal file
@ -0,0 +1,10 @@
|
||||
uses
|
||||
sysutils;
|
||||
begin
|
||||
if 3600*24*(now()-FileDateToDateTime(FileAge(paramstr(0))))>7200 then
|
||||
begin
|
||||
writeln('FileAge returns: ',FileDateToDateTime(FileAge(paramstr(0))));
|
||||
writeln('Compilation time and run time differ too much, SysUtils.FileAge buggy?');
|
||||
halt(1);
|
||||
end;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user