File: testdbgcontrol.pas

package info (click to toggle)
lazarus 2.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 214,460 kB
  • sloc: pascal: 1,862,622; xml: 265,709; cpp: 56,595; sh: 3,008; java: 609; makefile: 535; perl: 297; sql: 222; ansic: 137
file content (171 lines) | stat: -rw-r--r-- 4,166 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
unit TestDbgControl;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, TestDbgConfig, TTestDbgExecuteables;

type
  TWriteLogConfig = (wlNever, wlAlways, wlOnError);

  TCanCpuBits = function(b: TCpuBitType): Boolean;
  TCanSymType = function(s: TSymbolType): Boolean;
  TCanCompiler = function(name: string): Boolean;
  TCanDebugger = function(name: string): Boolean;
  TCanTest = function(id: Pointer): Boolean;
  TGetTestPattern = function: string;

  TSetLogPath = procedure(path: string);
  TGetLogPath = function: string;
  TGetWriteLog = function: TWriteLogConfig;


  TRegisterCompiler = procedure(name: string);
  TRegisterDebugger = procedure(name: string);
  TRegisterTest = function(Name: String; Parent: Pointer = nil): Pointer;

var
  CanCpuBitsProc: TCanCpuBits;
  CanSymTypeProc: TCanSymType;
  CanCompilerProc: TCanCompiler;
  CanDebuggerProc: TCanDebugger;
  CanTestProc: TCanTest;
  GetTestPatternProc: TGetTestPattern;
  SetLogPathProc: TSetLogPath;
  GetLogPathProc: TGetLogPath;
  GetWriteLogProc: TGetWriteLog;
  RegisterCompilerProc: TRegisterCompiler;
  RegisterDebuggerProc: TRegisterDebugger;
  RegisterTestProc: TRegisterTest;

function TestControlCanCpuBits(b: TCpuBitType): Boolean;
function TestControlCanSymType(s: TSymbolType): Boolean;
function TestControlCanCompiler(name: string): Boolean;
function TestControlCanDebugger(name: string): Boolean;
function TestControlCanTest(id: Pointer): Boolean;
function TestControlGetTestPattern: string;

procedure TestControlRegisterCompiler(name: string);
procedure TestControlRegisterDebugger(name: string);
function TestControlRegisterTest(Name: String; Parent: Pointer = nil): Pointer;

procedure TestControlSetLogPath(path: string);
function TestControlGetLogPath: string;
function TestControlGetWriteLog: TWriteLogConfig;

procedure TestControlRegisterCompilers(c: TBaseList);
procedure TestControlRegisterDebuggers(d: TBaseList);

implementation

var
  LogPath: String;

function TestControlCanCpuBits(b: TCpuBitType): Boolean;
begin
  Result := True;
  if CanCpuBitsProc <> nil then
    Result := CanCpuBitsProc(b);
end;

function TestControlCanSymType(s: TSymbolType): Boolean;
begin
  Result := True;
  if CanSymTypeProc <> nil then
    Result := CanSymTypeProc(s);
end;

function TestControlCanCompiler(name: string): Boolean;
begin
  Result := True;
  if CanCompilerProc <> nil then
    Result := CanCompilerProc(name);
end;

function TestControlCanDebugger(name: string): Boolean;
begin
  Result := True;
  if CanDebuggerProc <> nil then
    Result := CanDebuggerProc(name);
end;

function TestControlCanTest(id: Pointer): Boolean;
begin
  Result := True;
  if id = nil then
    exit;
  if CanTestProc <> nil then
    Result := CanTestProc(id);
end;

function TestControlGetTestPattern: string;
begin
  Result := '';
  if GetTestPatternProc <> nil then
    Result := GetTestPatternProc();
end;

procedure TestControlRegisterCompiler(name: string);
begin
  if RegisterCompilerProc <> nil then
    RegisterCompilerProc(name);
end;

procedure TestControlRegisterDebugger(name: string);
begin
  if RegisterDebuggerProc <> nil then
    RegisterDebuggerProc(name);
end;

function TestControlRegisterTest(Name: String; Parent: Pointer): Pointer;
begin
  Result := nil;
  if RegisterTestProc <> nil then
    Result := RegisterTestProc(Name, Parent);
end;

procedure TestControlSetLogPath(path: string);
begin
  if SetLogPathProc <> nil then
    SetLogPathProc(path)
  else
    LogPath := path;
end;

function TestControlGetLogPath: string;
begin
  Result := LogPath;
  if GetLogPathProc <> nil then
    Result := GetLogPathProc();
end;

function TestControlGetWriteLog: TWriteLogConfig;
begin
  Result := wlNever;
  if GetWriteLogProc <> nil then
    Result := GetWriteLogProc()
  else
  if TestControlGetLogPath <> '' then
    Result := wlAlways;
end;

procedure TestControlRegisterCompilers(c: TBaseList);
var
  i: Integer;
begin
  for i := 0 to c.Count - 1 do
    TestControlRegisterCompiler(c.Name[i]);
end;

procedure TestControlRegisterDebuggers(d: TBaseList);
var
  i: Integer;
begin
  for i := 0 to d.Count - 1 do
    TestControlRegisterDebugger(d.Name[i]);
end;

end.