1 |
tony |
315 |
(*
|
2 |
|
|
* Firebird Interface (fbintf) Test suite. This program is used to
|
3 |
|
|
* test the Firebird Pascal Interface and provide a semi-automated
|
4 |
|
|
* pass/fail check for each test.
|
5 |
|
|
*
|
6 |
|
|
* The contents of this file are subject to the Initial Developer's
|
7 |
|
|
* Public License Version 1.0 (the "License"); you may not use this
|
8 |
|
|
* file except in compliance with the License. You may obtain a copy
|
9 |
|
|
* of the License here:
|
10 |
|
|
*
|
11 |
|
|
* http://www.firebirdsql.org/index.php?op=doc&id=idpl
|
12 |
|
|
*
|
13 |
|
|
* Software distributed under the License is distributed on an "AS
|
14 |
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
15 |
|
|
* implied. See the License for the specific language governing rights
|
16 |
|
|
* and limitations under the License.
|
17 |
|
|
*
|
18 |
|
|
* The Initial Developer of the Original Code is Tony Whyman.
|
19 |
|
|
*
|
20 |
|
|
* The Original Code is (C) 2016 Tony Whyman, MWA Software
|
21 |
|
|
* (http://www.mwasoftware.co.uk).
|
22 |
|
|
*
|
23 |
|
|
* All Rights Reserved.
|
24 |
|
|
*
|
25 |
|
|
* Contributor(s): ______________________________________.
|
26 |
|
|
*
|
27 |
|
|
*)
|
28 |
|
|
|
29 |
tony |
45 |
unit Test9;
|
30 |
tony |
56 |
{$IFDEF MSWINDOWS}
|
31 |
|
|
{$DEFINE WINDOWS}
|
32 |
|
|
{$ENDIF}
|
33 |
tony |
45 |
|
34 |
tony |
56 |
{$IFDEF FPC}
|
35 |
|
|
{$mode delphi}
|
36 |
tony |
45 |
{$codepage utf8}
|
37 |
tony |
56 |
{$ENDIF}
|
38 |
tony |
45 |
|
39 |
|
|
{Test 9: Database Information tests}
|
40 |
|
|
|
41 |
|
|
{
|
42 |
|
|
This test opens the employee example databases with the supplied user name/password
|
43 |
|
|
and then reads and prints all defined database information.
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
interface
|
47 |
|
|
|
48 |
|
|
uses
|
49 |
tony |
315 |
Classes, SysUtils, TestApplication, FBTestApp, IB;
|
50 |
tony |
45 |
|
51 |
|
|
type
|
52 |
|
|
|
53 |
|
|
{ TTest9 }
|
54 |
|
|
|
55 |
tony |
315 |
TTest9 = class(TFBTestBase)
|
56 |
tony |
45 |
private
|
57 |
|
|
procedure GetDBInformation(Attachment: IAttachment);
|
58 |
|
|
public
|
59 |
tony |
56 |
function TestTitle: AnsiString; override;
|
60 |
|
|
procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override;
|
61 |
tony |
45 |
end;
|
62 |
|
|
|
63 |
|
|
implementation
|
64 |
|
|
|
65 |
|
|
{ TTest9 }
|
66 |
|
|
|
67 |
|
|
procedure TTest9.GetDBInformation(Attachment: IAttachment);
|
68 |
|
|
var DBInfo: IDBInformation;
|
69 |
tony |
143 |
DBRequest: IDIRB;
|
70 |
tony |
45 |
begin
|
71 |
tony |
143 |
{First check ODS version to avoid information requests supported DB 2.5 and later}
|
72 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_ods_version,isc_info_ods_minor_version]);
|
73 |
|
|
if (DBInfo.Count > 1) and (DBInfo[0].AsInteger > 11) or
|
74 |
|
|
((DBInfo[0].AsInteger = 11) and (DBInfo[1].AsInteger > 1)) then
|
75 |
|
|
begin
|
76 |
|
|
WriteDBInfo(Attachment.GetDBInformation(isc_info_db_id));
|
77 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_allocation,isc_info_base_level,
|
78 |
tony |
45 |
isc_info_implementation,isc_info_no_reserve,isc_info_ods_minor_version,
|
79 |
tony |
143 |
isc_info_ods_version,isc_info_page_size,isc_info_version,isc_info_db_read_only,
|
80 |
|
|
isc_info_creation_date,fb_info_pages_used,fb_info_pages_free]);
|
81 |
|
|
WriteDBInfo(DBInfo);
|
82 |
|
|
|
83 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_current_memory, isc_info_forced_writes,
|
84 |
|
|
isc_info_max_memory, isc_info_num_buffers, isc_info_sweep_interval,
|
85 |
|
|
isc_info_user_names,isc_info_active_tran_count]);
|
86 |
|
|
WriteDBInfo(DBInfo);
|
87 |
|
|
|
88 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_fetches,isc_info_marks,
|
89 |
|
|
isc_info_reads, isc_info_writes]);
|
90 |
|
|
WriteDBInfo(DBInfo);
|
91 |
|
|
|
92 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_backout_count, isc_info_delete_count,
|
93 |
|
|
isc_info_expunge_count,isc_info_insert_count, isc_info_purge_count,
|
94 |
|
|
isc_info_read_idx_count, isc_info_read_seq_count, isc_info_update_count]);
|
95 |
|
|
WriteDBInfo(DBInfo);
|
96 |
|
|
|
97 |
|
|
DBRequest := Attachment.AllocateDIRB;
|
98 |
|
|
|
99 |
|
|
DBRequest.Add(isc_info_page_size);
|
100 |
|
|
|
101 |
|
|
{Only enable during unit test. This result will always be different for
|
102 |
|
|
each run and you will only get false positives in the log}
|
103 |
|
|
// DBRequest.Add(fb_info_page_contents).AsInteger := 100;
|
104 |
|
|
WriteDBInfo(Attachment.GetDBInformation(DBRequest));
|
105 |
|
|
end
|
106 |
|
|
else
|
107 |
|
|
begin
|
108 |
|
|
WriteDBInfo(Attachment.GetDBInformation(isc_info_db_id));
|
109 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_allocation,isc_info_base_level,
|
110 |
|
|
isc_info_implementation,isc_info_no_reserve,isc_info_ods_minor_version,
|
111 |
tony |
61 |
isc_info_ods_version,isc_info_page_size,isc_info_version,isc_info_db_read_only]);
|
112 |
tony |
45 |
WriteDBInfo(DBInfo);
|
113 |
|
|
|
114 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_current_memory, isc_info_forced_writes,
|
115 |
|
|
isc_info_max_memory, isc_info_num_buffers, isc_info_sweep_interval,
|
116 |
|
|
isc_info_user_names]);
|
117 |
|
|
WriteDBInfo(DBInfo);
|
118 |
|
|
|
119 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_fetches,isc_info_marks,
|
120 |
|
|
isc_info_reads, isc_info_writes]);
|
121 |
|
|
WriteDBInfo(DBInfo);
|
122 |
|
|
|
123 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_backout_count, isc_info_delete_count,
|
124 |
|
|
isc_info_expunge_count,isc_info_insert_count, isc_info_purge_count,
|
125 |
|
|
isc_info_read_idx_count, isc_info_read_seq_count, isc_info_update_count]);
|
126 |
|
|
WriteDBInfo(DBInfo);
|
127 |
tony |
143 |
|
128 |
|
|
DBRequest := Attachment.AllocateDIRB;
|
129 |
|
|
DBRequest.Add(isc_info_page_size);
|
130 |
|
|
WriteDBInfo(Attachment.GetDBInformation(DBRequest));
|
131 |
|
|
end;
|
132 |
tony |
45 |
end;
|
133 |
|
|
|
134 |
tony |
56 |
function TTest9.TestTitle: AnsiString;
|
135 |
tony |
45 |
begin
|
136 |
|
|
Result := 'Test 9: Database Information tests';
|
137 |
|
|
end;
|
138 |
|
|
|
139 |
tony |
56 |
procedure TTest9.RunTest(CharSet: AnsiString; SQLDialect: integer);
|
140 |
tony |
45 |
var DPB: IDPB;
|
141 |
|
|
Attachment: IAttachment;
|
142 |
|
|
begin
|
143 |
|
|
DPB := FirebirdAPI.AllocateDPB;
|
144 |
|
|
DPB.Add(isc_dpb_user_name).setAsString(Owner.GetUserName);
|
145 |
|
|
DPB.Add(isc_dpb_password).setAsString(Owner.GetPassword);
|
146 |
|
|
DPB.Add(isc_dpb_lc_ctype).setAsString(CharSet);
|
147 |
|
|
DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect);
|
148 |
|
|
Attachment := FirebirdAPI.OpenDatabase(Owner.GetEmployeeDatabaseName,DPB);
|
149 |
|
|
|
150 |
|
|
GetDBInformation(Attachment);
|
151 |
|
|
end;
|
152 |
|
|
|
153 |
|
|
initialization
|
154 |
|
|
RegisterTest(TTest9);
|
155 |
|
|
|
156 |
|
|
end.
|
157 |
|
|
|