Skip to content

Commit 49336e0

Browse files
committed
SNAPSNAP environment-test-suite
1 parent e8aa3bb commit 49336e0

File tree

8 files changed

+172
-9
lines changed

8 files changed

+172
-9
lines changed

documentation/source/hacker-guide/environment/environment-protocols.rst

+19-3
Original file line numberDiff line numberDiff line change
@@ -1044,15 +1044,19 @@ Address Objects
10441044

10451045
:signature: address-read-memory-contents (server addr #key size format from-index to-index) => (printable-strings nxt)
10461046

1047-
:parameter server: An instance of :class:`<server>`.
1048-
:parameter addr: An instance of :class:`<address-object>`.
1049-
:parameter #key size: An instance of :const:`<data-display-size>`.
1047+
:parameter server: An instance of :class:`<server>`. The backend dispatching object.
1048+
:parameter addr: An instance of :class:`<address-object>`. The address at which to base the import.
1049+
:parameter #key size: An instance of :const:`<data-display-size>`. The granularity at which to read data; defaults to ``#"word"`` (the runtime platform word-size).
10501050
:parameter #key format: An instance of :const:`<data-display-format>`.
10511051
:parameter #key from-index: An instance of :class:`<integer>`.
10521052
:parameter #key to-index: An instance of :class:`<integer>`.
10531053
:value printable-strings: An instance of :class:`<sequence>`.
10541054
:value nxt: An instance of :class:`<address-object>`.
10551055

1056+
Import a block of memory contents starting at the supplied address,
1057+
and return the contents as formatted strings. Also returns the
1058+
address that immediately follows the block that has been read.
1059+
10561060
.. method:: address-read-memory-contents
10571061
:specializer: <project-object>, <address-object>
10581062

@@ -1143,6 +1147,9 @@ Component Objects
11431147

11441148
.. class:: <component-object>
11451149

1150+
Represents a runtime "component", i.e. a DLL/EXE file or a shared
1151+
object file.
1152+
11461153
:superclasses: :class:`<application-object>`
11471154

11481155

@@ -1231,6 +1238,8 @@ Composite Objects
12311238
.. generic-function:: composite-object-contents
12321239
:open:
12331240

1241+
Returns the slot names and values of a composite instance.
1242+
12341243
:signature: composite-object-contents (server object #key inherited?) => (names values)
12351244

12361245
:parameter server: An instance of :class:`<server>`.
@@ -1239,6 +1248,9 @@ Composite Objects
12391248
:value names: An instance of :class:`<sequence>`.
12401249
:value values: An instance of :class:`<sequence>`.
12411250

1251+
All of the values are wrapped up in :class:`<environment-object>`
1252+
instances, whereas the slot names are just returned as strings.
1253+
12421254
.. method:: composite-object-contents
12431255
:specializer: <project-object>, <composite-object>
12441256

@@ -4086,6 +4098,10 @@ Playground
40864098
:parameter #key just-name?: An instance of :class:`<boolean>`.
40874099
:value playground?: An instance of :class:`<boolean>`.
40884100

4101+
The ``just-name?`` keyword should be passed as ``#t`` when you want
4102+
to test for playground-project-nature, but the project may not have
4103+
been opened properly yet.
4104+
40894105
.. function:: playground-application-filename
40904106

40914107
:signature: playground-application-filename (project) => (filename)

sources/environment/dfmc/application/control-protocols.dylan

+2
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ define method register-thread-in-state-model
551551
:= application.application-thread-counter + 1;
552552
thread-state-model(application, thread)
553553
:= thread-state;
554+
debugger-message("Registered thread %d in state model",
555+
thread-state.thread-state-thread-index);
554556
end method register-thread-in-state-model;
555557

556558

sources/environment/tests/dfmc/debugging.dylan

+110
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,50 @@ Warranty: Distributed WITHOUT WARRANTY OF ANY KIND
88

99
define constant $debugging-test-application = "cmu-test-suite";
1010

11+
define variable *test-application-application* :: false-or(<application>) = #f;
12+
13+
define function dbg-machine () => (machine :: <machine>);
14+
let orb = corba/orb-init(make(corba/<arg-list>), "Open Dylan ORB");
15+
let network-address = environment-variable("OPEN_DYLAN_DEBUGGING_MACHINE");
16+
if (network-address)
17+
let password
18+
= environment-variable("OPEN_DYLAN_DEBUGGING_PASSWORD")
19+
| error ("Environment variable OPEN_DYLAN_DEBUGGING_PASSWORD is not set");
20+
make(<machine>,
21+
network-address: network-address,
22+
password: password)
23+
else
24+
environment-host-machine()
25+
end if
26+
end function;
27+
28+
define constant $project-message-queue = make(<deque>);
29+
define constant $project-message-notification
30+
= make(<notification>, lock: make(<lock>));
31+
32+
define function debugging-project-message-callback (message :: <project-message>)
33+
with-lock (associated-lock($project-message-notification))
34+
push-last($project-message-queue, message);
35+
release($project-message-notification);
36+
end with-lock;
37+
end function;
38+
39+
define function await-project-message () => (message :: <project-message>);
40+
with-lock (associated-lock($project-message-notification))
41+
while (empty?($project-message-queue))
42+
wait-for($project-message-notification);
43+
end while;
44+
pop($project-message-queue)
45+
end with-lock
46+
end function;
47+
48+
define function initialize-application-client
49+
(client :: <object>, application :: <application>) => ()
50+
register-application-callbacks
51+
(application,
52+
initialized-callback: note-application-initialized);
53+
end function;
54+
1155
define function open-debugging-test-project () => ()
1256
let application
1357
= open-project(test-project-location($debugging-test-application));
@@ -21,9 +65,75 @@ define function open-debugging-test-project () => ()
2165
parse-project-source(application);
2266
end unless;
2367
*test-application* := application;
68+
69+
tune-in($project-channel, debugging-project-message-callback,
70+
message-type: <project-message>);
71+
72+
// FIXME
73+
let machine = dbg-machine();
74+
*test-application-application*
75+
:= run-application(*test-application*,
76+
initialize-client: initialize-application-client,
77+
startup-option: #"debug",
78+
machine: machine);
79+
iterate loop (initialized? = #f, stopped? = #t, transient-bp-count = 0)
80+
format-out("I=%= S=%= BP=%d\n",
81+
initialized?, stopped?,
82+
transient-bp-count);
83+
unless (initialized? & stopped? & zero?(transient-bp-count))
84+
let message = await-project-message();
85+
format-out("%s\n", message);
86+
select (message by instance?)
87+
<application-initialized-message> =>
88+
format-out(" it is initialized\n");
89+
loop(#t, stopped?, transient-bp-count);
90+
<application-state-changed-message> =>
91+
let state = *test-application-application*.application-state;
92+
format-out(" state is now %s\n", state);
93+
if (state == #"running")
94+
loop(initialized?, #f, transient-bp-count);
95+
else
96+
loop(initialized?, #t, transient-bp-count);
97+
end if;
98+
<single-breakpoint-state-change-message> =>
99+
let breakpoint = message.message-breakpoint;
100+
let state = message.message-breakpoint-state;
101+
format-out(" Breakpoint %s (%=) state is now %s\n",
102+
breakpoint,
103+
environment-object-id(*test-application*, breakpoint),
104+
state);
105+
if (breakpoint.breakpoint-transient?)
106+
select (state)
107+
#"created" =>
108+
loop(initialized?, stopped?, transient-bp-count + 1);
109+
#"destroyed" =>
110+
loop(initialized?, stopped?, transient-bp-count - 1);
111+
end select;
112+
else
113+
loop(initialized?, stopped?, transient-bp-count);
114+
end if;
115+
<application-threads-changed-message> =>
116+
/*
117+
*/
118+
loop(initialized?, stopped?, transient-bp-count);
119+
otherwise =>
120+
loop(initialized?, stopped?, transient-bp-count);
121+
end select;
122+
end unless;
123+
end iterate;
124+
format-out("It's started; I'm glad\n");
125+
for (thread in *test-application-application*.application-threads)
126+
format-out(" Thread %s (%s) state %s suspended %=\n",
127+
thread,
128+
environment-object-primitive-name(*test-application*, thread),
129+
thread-state(*test-application*, thread),
130+
thread.thread-suspended?);
131+
end for;
24132
end function;
25133

26134
define function close-debugging-test-project () => ()
135+
stop-application(*test-application-application*);
136+
tune-out($project-channel, debugging-project-message-callback);
27137
close-project(*test-application*);
28138
end function;
29139

sources/environment/tests/dfmc/library.dylan

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ define library dfmc-environment-test-suite
1515
use source-records;
1616

1717
use testworks;
18+
use channels;
19+
use dylan-orb;
1820

1921
use environment-protocols;
20-
use environment-commands;
21-
use environment-application-commands;
22+
use dfmc-environment;
23+
use dfmc-environment-projects;
24+
use dfmc-environment-application;
2225
use environment-test-suite;
2326

2427
// Back-ends
2528
use dfmc-back-end-implementations;
29+
use remote-access-path;
2630

2731
export dfmc-environment-test-suite;
2832
end library dfmc-environment-test-suite;

sources/environment/tests/dfmc/module.dylan

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,22 @@ define module dfmc-environment-test-suite
1313
use standard-io;
1414
use progress-stream;
1515
use locators;
16+
use file-system;
17+
use threads;
1618

1719
use source-records;
1820
use operating-system,
1921
exclude: { run-application };
2022

2123
use testworks;
2224

25+
use channels;
26+
use dylan-orb;
27+
2328
use environment-protocols,
2429
exclude: { application-filename,
2530
application-arguments };
26-
use environment-commands;
31+
use dfmc-application;
2732
use environment-test-suite;
2833

2934
export dfmc-environment-suite;

sources/environment/tests/dfmc/projects.dylan

+27-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ define function open-test-projects () => ()
9191
open-project-compiler-database
9292
(application, error-handler: project-condition-handler);
9393

94-
test-project-build(application);
94+
test-project-build(application, link?: #t);
9595

9696
unless (open-project-compiler-database
9797
(library, error-handler: project-condition-handler))
@@ -127,6 +127,9 @@ define test open-projects-test ()
127127
check-equal("Application project interface type",
128128
project-interface-type(*test-application*),
129129
#"gui");
130+
check-equal("Application project name",
131+
project-name(*test-application*),
132+
$test-application);
130133
check-equal("Application project name",
131134
environment-object-primitive-name
132135
(*test-application*, *test-application*),
@@ -141,6 +144,9 @@ define test open-projects-test ()
141144
check-equal("Library interface target type",
142145
project-interface-type(*test-library*),
143146
#"console");
147+
check-equal("Library project name",
148+
project-name(*test-library*),
149+
$test-library);
144150
check-equal("Library project name",
145151
environment-object-primitive-name
146152
(*test-library*, *test-library*),
@@ -149,9 +155,29 @@ define test open-projects-test ()
149155
project-compiled?(*test-library*));
150156
end test open-projects-test;
151157

158+
define test project-files-test ()
159+
check-equal("Library project filename",
160+
test-project-location($test-library),
161+
project-filename(*test-library*));
162+
check-equal("Application project filename",
163+
test-project-location($test-application),
164+
project-filename(*test-application*));
165+
166+
check-true("Library project directory exists",
167+
file-exists?(project-directory(*test-library*)));
168+
for (s in project-sources(*test-library*))
169+
check-true("Source file exists",
170+
file-exists?(source-record-location(s)));
171+
end for;
172+
check-true("Library full build file exists",
173+
file-exists?(project-full-build-filename(*test-library*)));
174+
check-true("Application full build file exists",
175+
file-exists?(project-full-build-filename(*test-application*)));
176+
end test;
152177

153178
/// projects suite
154179

155180
define suite projects-suite ()
156181
test open-projects-test;
182+
test project-files-test;
157183
end suite projects-suite;

sources/environment/tests/library.dylan

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ define library environment-test-suite
1111
use release-info;
1212
//---*** andrewa: this needs a DUIM backend to work
1313
// use environment-framework;
14-
use duim-core;
14+
//use duim-core;
1515

1616
use testworks;
1717

sources/environment/tests/module.dylan

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ define module environment-test-suite
1111
use environment-protocols;
1212
//---*** andrewa: this needs a DUIM backend to work
1313
// use environment-framework;
14-
use duim;
14+
// use duim;
1515

1616
use testworks;
1717

0 commit comments

Comments
 (0)