mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 20:38:16 +02:00
DBG: Tests argv
git-svn-id: trunk@37963 -
This commit is contained in:
parent
3e7175b81e
commit
356f9cf685
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -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
|
||||
|
28
debugger/test/Gdbmi/TestApps/ArgVPrg.pas
Normal file
28
debugger/test/Gdbmi/TestApps/ArgVPrg.pas
Normal 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.
|
||||
|
@ -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>
|
||||
|
@ -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}
|
||||
|
||||
|
82
debugger/test/Gdbmi/testargv.pas
Normal file
82
debugger/test/Gdbmi/testargv.pas
Normal 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.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user