Across-the-board rename so the unit prefix matches the repo
name (mb = msgbase). Brings naming into line with
fpc-ftn-transport's tt.* prefix and avoids the historical
"ma" abbreviation that meant nothing to new readers.
Files renamed via git mv:
src/ma.{api,events,kludge,lock,paths,types}.pas
-> src/mb.{...}.pas
src/formats/ma.fmt.{jam,squish,hudson,msg,pcboard,ezycom,
goldbase,wildcat,wcutil}{,.uni}.pas
-> src/formats/mb.fmt.*.pas
All `unit ma.X` declarations and `uses ma.X` clauses rewritten
to `mb.X` across src/, examples/, tests/.
Suite: 47/47 (read 7, hwm 11, lock 4, pack 4, write 5,
wildcat 5, consumer_round1 5, batch's gone w/ PKT relocation,
plus testutil).
Consumer impact: anyone with `uses ma.api;` etc. needs to
update to `uses mb.api;`. No semantic changes; a search/replace
on the consumer's source tree is the only migration step.
NR's notes (~/.MSGAPI_MSGS.md round 3) align this against
their already-pinned 8130b40; the next NR pin bump rolls in
both this rename and any further work in one step.
99 lines
2.3 KiB
ObjectPascal
99 lines
2.3 KiB
ObjectPascal
{
|
|
test_wildcat.pas - WildCat! 4 adapter smoke test.
|
|
|
|
The WC SDK opens databases for write (btis lock, modcounter
|
|
bumps) even when the caller only reads, so we never touch the
|
|
source tree directly. This test copies the vendored testdata
|
|
to a scratch location first, runs the adapter there, then
|
|
leaves the scratch alone for manual inspection.
|
|
|
|
Source lives in-repo at tests/data/wildcat/ and is NEVER
|
|
modified.
|
|
}
|
|
|
|
program test_wildcat;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
uses
|
|
SysUtils,
|
|
testutil,
|
|
mb.types, mb.events, mb.api,
|
|
mb.fmt.wildcat, mb.fmt.wildcat.uni;
|
|
|
|
const
|
|
SRC = 'tests/data/wildcat';
|
|
SCRATCH = '/tmp/ma_wildcat';
|
|
|
|
function RunShell(const Cmd: string): integer;
|
|
begin
|
|
Result := ExecuteProcess('/bin/sh', ['-c', Cmd]);
|
|
end;
|
|
|
|
function CopyTree(const Source, Dest: string): boolean;
|
|
var
|
|
cmd: string;
|
|
begin
|
|
cmd := SysUtils.Format('cp -r "%s"/. "%s"/ 2>/dev/null', [Source, Dest]);
|
|
Result := RunShell(cmd) = 0;
|
|
end;
|
|
|
|
procedure PrepareScratch;
|
|
begin
|
|
if DirectoryExists(SCRATCH) then
|
|
RunShell(SysUtils.Format('rm -rf "%s"', [SCRATCH]));
|
|
ForceDirectories(SCRATCH);
|
|
if not CopyTree(SRC, SCRATCH) then
|
|
raise Exception.Create('cp -r failed');
|
|
end;
|
|
|
|
procedure TestConference(Conf: word);
|
|
var
|
|
base: TMessageBase;
|
|
adapter: TWildcatMessageBase;
|
|
msg: TUniMessage;
|
|
i, count, ok: longint;
|
|
begin
|
|
TestBegin(SysUtils.Format('WildCat! conference %d', [Conf]));
|
|
base := MessageBaseOpen(mbfWildcat, SCRATCH, momReadWrite);
|
|
adapter := base as TWildcatMessageBase;
|
|
adapter.Conference := Conf;
|
|
try
|
|
AssertTrue('Open', base.Open);
|
|
count := base.MessageCount;
|
|
ok := 0;
|
|
for i := 0 to count - 1 do
|
|
if base.ReadMessage(i, msg) then begin
|
|
Inc(ok);
|
|
if i = 0 then
|
|
AssertTrue('First msg has sender',
|
|
Length(msg.Attributes.Get('from')) > 0);
|
|
end;
|
|
AssertEquals('Read all reported messages', count, ok);
|
|
finally
|
|
base.Close;
|
|
base.Free;
|
|
end;
|
|
TestOK;
|
|
end;
|
|
|
|
var
|
|
conf: word;
|
|
begin
|
|
WriteLn('fpc-msgbase: WildCat! 4 read tests');
|
|
WriteLn;
|
|
|
|
if not DirectoryExists(SRC) then begin
|
|
WriteLn('SKIP (sample at ', SRC, ' missing)');
|
|
Halt(0);
|
|
end;
|
|
|
|
PrepareScratch;
|
|
|
|
{ testdata has conferences 0..6. Walk each one. }
|
|
for conf := 0 to 6 do
|
|
TestConference(conf);
|
|
|
|
Halt(TestsSummary);
|
|
end.
|