DBG: Tests argv

git-svn-id: trunk@37963 -
This commit is contained in:
martin 2012-07-18 14:06:22 +00:00
parent 3e7175b81e
commit 356f9cf685
6 changed files with 121 additions and 2 deletions

2
.gitattributes vendored
View File

@ -3114,6 +3114,7 @@ debugger/registersdlg.pp svneol=native#text/pascal
debugger/sshgdbmidebugger.pas svneol=native#text/pascal
debugger/test/Gdbmi/RunGdbmi.lpi svneol=native#text/xml
debugger/test/Gdbmi/RunGdbmi.lpr svneol=native#text/pascal
debugger/test/Gdbmi/TestApps/ArgVPrg.pas svneol=native#text/pascal
debugger/test/Gdbmi/TestApps/EnvPrg.pas svneol=native#text/pascal
debugger/test/Gdbmi/TestApps/ExceptPrg.pas svneol=native#text/pascal
debugger/test/Gdbmi/TestApps/WatchesPrg.pas svneol=native#text/pascal
@ -3132,6 +3133,7 @@ debugger/test/Gdbmi/fpclist.txt.sample svneol=native#text/plain
debugger/test/Gdbmi/gdblist.txt.sample svneol=native#text/plain
debugger/test/Gdbmi/rungdbmiform.lfm svneol=native#text/plain
debugger/test/Gdbmi/rungdbmiform.pas svneol=native#text/pascal
debugger/test/Gdbmi/testargv.pas svneol=native#text/pascal
debugger/test/Gdbmi/testbase.pas svneol=native#text/pascal
debugger/test/Gdbmi/testbreakpoint.pas svneol=native#text/pascal
debugger/test/Gdbmi/testdisass.pas svneol=native#text/pascal

View File

@ -0,0 +1,28 @@
program ArgVPrg;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, sysutils
{ you can add units after this };
var
i: Integer;
p: PChar;
s: String;
begin
s := '';
for i := 0 to argc - 1 do begin
p := (argv+i)^;
while p^ <> #0 do begin
s := s + IntToHex(ord(p^), 2);
inc(p);
end;
s := s + ' ';
end;
WriteLn(s);
end.

View File

@ -46,7 +46,7 @@
<PackageName Value="FCL"/>
</Item5>
</RequiredPackages>
<Units Count="11">
<Units Count="12">
<Unit0>
<Filename Value="TestGdbmi.lpr"/>
<IsPartOfProject Value="True"/>
@ -103,6 +103,11 @@
<IsPartOfProject Value="True"/>
<UnitName Value="TestEnvironment"/>
</Unit10>
<Unit11>
<Filename Value="testargv.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="TestArgV"/>
</Unit11>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -6,7 +6,7 @@ uses
Interfaces, Forms, GuiTestRunner, CompileHelpers,
TestGdbType, TestDisAss,
TestGDBMIControl,
TestBase, TestException, Testwatches, TestBreakPoint, TestEnvironment;
TestBase, TestException, Testwatches, TestBreakPoint, TestEnvironment, TestArgV;
{$R *.res}

View File

@ -0,0 +1,82 @@
unit TestArgV;
{$mode objfpc}{$H+}
interface
uses
SysUtils, fpcunit, testutils, testregistry, TestGDBMIControl,
TestBase, Debugger, GDBMIDebugger, LCLProc, FileUtil, TestWatches;
const
BREAK_LINE_ARGV = 26;
type
{ TTestEnvironment }
{ TTestArgV }
TTestArgV = class(TGDBTestCase)
published
procedure TestArgv;
end;
implementation
{ TTestArgV }
procedure TTestArgV.TestArgv;
var
dbg: TGDBMIDebugger;
TestExeName, s, s2, s3: string;
t: TDBGType;
i: Integer;
begin
if SkipTest then exit;
if not TestControlForm.CheckListBox1.Checked[TestControlForm.CheckListBox1.Items.IndexOf('TTestArgV')] then exit;
ClearTestErrors;
TestCompile(AppDir + 'ArgVPrg.pas', TestExeName);
s := 'env value 1';
try
dbg := StartGDB(AppDir, TestExeName);
dbg.Arguments := 'a b c ä ö ';
with dbg.BreakPoints.Add('ArgVPrg.pas', BREAK_LINE_ARGV) do begin
InitialEnabled := True;
Enabled := True;
end;
dbg.Run;
TestTrue(s+' not in error state', dbg.State <> dsError, 0);
t := nil;
TestTrue('Can eval', dbg.Evaluate('s', s, t));
TestTrue('a b c in '+s, pos('61 62 63', s) > 0);
s2 := UTF8ToSys('ä');
s3 := ' ';
for i := 1 to length(s2) do
s3 := s3 + IntToHex(ord(s2[i]), 2);
s3 := s3 + ' ';
TestTrue(' ä in '+s, pos(s3, s) > 0);
finally
dbg.Done;
CleanGdb;
dbg.Free;
end;
AssertTestErrors;
end;
initialization
RegisterDbgTest(TTestArgV);
end.

View File

@ -90,6 +90,8 @@ begin
CheckListBox1.Checked[j] := False;
j := CheckListBox1.Items.Add('TTestEnvironment');
CheckListBox1.Checked[j] := True;
j := CheckListBox1.Items.Add('TTestArgV');
CheckListBox1.Checked[j] := True;
d := GetDebuggers;
for i := 0 to d.Count - 1 do begin