2091
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
1447
|
3 |
"{ Package: 'stx:goodies/regression' }"
|
324
|
4 |
|
|
5 |
"{ NameSpace: RegressionTests }"
|
|
6 |
|
|
7 |
TestCase subclass:#ExternalInterfaceTests
|
|
8 |
instanceVariableNames:''
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
|
11 |
category:'tests-Regression'
|
|
12 |
!
|
|
13 |
|
|
14 |
!ExternalInterfaceTests class methodsFor:'documentation'!
|
|
15 |
|
|
16 |
documentation
|
|
17 |
"
|
|
18 |
documentation to be added.
|
|
19 |
|
|
20 |
[author:]
|
1447
|
21 |
cg (cg@FUSI)
|
324
|
22 |
|
|
23 |
[instance variables:]
|
|
24 |
|
|
25 |
[class variables:]
|
|
26 |
|
|
27 |
[see also:]
|
|
28 |
|
|
29 |
"
|
|
30 |
!
|
|
31 |
|
|
32 |
history
|
|
33 |
"Created: / 23-04-2006 / 08:13:27 / cg"
|
|
34 |
! !
|
|
35 |
|
2091
|
36 |
!ExternalInterfaceTests methodsFor:'structs'!
|
|
37 |
|
|
38 |
PROCESS_INFORMATION
|
|
39 |
"Describes a created process and its main thread."
|
|
40 |
|
|
41 |
<C: struct PROCESS_INFORMATION {
|
|
42 |
HANDLE hProcess;
|
|
43 |
HANDLE hThread;
|
|
44 |
DWORD dwProcessId;
|
|
45 |
DWORD dwThreadId;
|
|
46 |
}>
|
|
47 |
! !
|
|
48 |
|
|
49 |
!ExternalInterfaceTests methodsFor:'structs'!
|
|
50 |
|
|
51 |
SECURITY_ATTRIBUTES
|
|
52 |
"Describes security of associated process."
|
|
53 |
|
|
54 |
<C: struct SECURITY_ATTRIBUTES {
|
|
55 |
DWORD nLength;
|
|
56 |
LPVOID lpSecurityDescriptor;
|
|
57 |
BOOL bInheritHandle;
|
|
58 |
}>
|
|
59 |
! !
|
|
60 |
|
|
61 |
!ExternalInterfaceTests methodsFor:'structs'!
|
|
62 |
|
|
63 |
STARTUPINFOA
|
|
64 |
"Describes how we want the process to be started."
|
|
65 |
|
|
66 |
<C: struct STARTUPINFOA {
|
|
67 |
DWORD cb;
|
|
68 |
LPSTR lpReserved;
|
|
69 |
LPSTR lpDesktop;
|
|
70 |
LPSTR lpTitle;
|
|
71 |
DWORD dwX;
|
|
72 |
DWORD dwY;
|
|
73 |
DWORD dwXSize;
|
|
74 |
DWORD dwYSize;
|
|
75 |
DWORD dwXCountChars;
|
|
76 |
DWORD dwYCountChars;
|
|
77 |
DWORD dwFillAttribute;
|
|
78 |
DWORD dwFlags;
|
|
79 |
WORD wShowWindow;
|
|
80 |
WORD cbReserved2;
|
|
81 |
LPBYTE lpReserved2;
|
|
82 |
HANDLE hStdInput;
|
|
83 |
HANDLE hStdOutput;
|
|
84 |
HANDLE hStdError;
|
|
85 |
}>
|
|
86 |
! !
|
|
87 |
|
|
88 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
89 |
|
|
90 |
BOOL
|
|
91 |
<C: typedef long BOOL>
|
|
92 |
|
|
93 |
"
|
|
94 |
self new BOOL
|
|
95 |
"
|
|
96 |
! !
|
|
97 |
|
|
98 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
99 |
|
|
100 |
BYTE
|
|
101 |
<C: typedef unsigned char BYTE>
|
|
102 |
|
|
103 |
"
|
|
104 |
self new BYTE
|
|
105 |
"
|
|
106 |
! !
|
|
107 |
|
|
108 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
109 |
|
|
110 |
DWORD
|
|
111 |
<C: typedef unsigned long DWORD>
|
|
112 |
|
|
113 |
"
|
|
114 |
self new DWORD
|
|
115 |
"
|
|
116 |
! !
|
|
117 |
|
|
118 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
119 |
|
|
120 |
HANDLE
|
|
121 |
<C: typedef void * HANDLE>
|
|
122 |
|
|
123 |
"
|
|
124 |
self new HANDLE
|
|
125 |
"
|
|
126 |
! !
|
|
127 |
|
|
128 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
129 |
|
|
130 |
LPBYTE
|
|
131 |
<C: typedef BYTE *LPBYTE>
|
|
132 |
|
|
133 |
"
|
|
134 |
self new LPBYTE
|
|
135 |
"
|
|
136 |
! !
|
|
137 |
|
|
138 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
139 |
|
|
140 |
LPCTSR
|
|
141 |
<C: typedef void * LPCTSR>
|
|
142 |
|
|
143 |
"
|
|
144 |
self new LPCTSR
|
|
145 |
"
|
|
146 |
! !
|
|
147 |
|
|
148 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
149 |
|
|
150 |
LPCTSTR
|
|
151 |
<C: typedef void * LPCTSTR>
|
|
152 |
|
|
153 |
"
|
|
154 |
self new LPCTSTR
|
|
155 |
"
|
|
156 |
! !
|
|
157 |
|
|
158 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
159 |
|
|
160 |
LPSIZE
|
|
161 |
<C: typedef SIZE * LPSIZE>
|
|
162 |
|
|
163 |
"
|
|
164 |
self new LPSIZE
|
|
165 |
"
|
|
166 |
! !
|
|
167 |
|
|
168 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
169 |
|
|
170 |
LPSTR
|
|
171 |
<C: typedef char * LPSTR>
|
|
172 |
|
|
173 |
"
|
|
174 |
self new LPSTR
|
|
175 |
"
|
|
176 |
! !
|
|
177 |
|
|
178 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
179 |
|
|
180 |
LPTSTR
|
|
181 |
<C: typedef void * LPTSTR>
|
|
182 |
|
|
183 |
"
|
|
184 |
self new LPTSTR
|
|
185 |
"
|
|
186 |
! !
|
|
187 |
|
|
188 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
189 |
|
|
190 |
LPVOID
|
|
191 |
<C: typedef void * LPVOID>
|
|
192 |
|
|
193 |
"
|
|
194 |
self new LPVOID
|
|
195 |
"
|
|
196 |
! !
|
|
197 |
|
|
198 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
199 |
|
|
200 |
SIZE
|
|
201 |
<C: typedef struct {
|
|
202 |
long cx;
|
|
203 |
long cy;
|
|
204 |
} SIZE>
|
|
205 |
|
|
206 |
"
|
|
207 |
self new SIZE
|
|
208 |
"
|
|
209 |
! !
|
|
210 |
|
|
211 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
212 |
|
|
213 |
WORD
|
|
214 |
<C: typedef unsigned short WORD>
|
|
215 |
|
|
216 |
"
|
|
217 |
self new WORD
|
|
218 |
"
|
|
219 |
! !
|
|
220 |
|
|
221 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
222 |
|
|
223 |
fooType
|
|
224 |
<C: struct foo {
|
|
225 |
long l1;
|
|
226 |
float f1;
|
|
227 |
}>
|
|
228 |
|
|
229 |
"
|
|
230 |
self new fooType
|
|
231 |
"
|
|
232 |
! !
|
|
233 |
|
325
|
234 |
!ExternalInterfaceTests methodsFor:'procedures'!
|
|
235 |
|
|
236 |
CreateProcess: imageName commandLine: commandLine pSecurity: pSecurity tSecurity: tSecurity inheritHandles: inheritHandles creationFlags: creationFlags environment: environment currentDirectoryName: currentDirectoryName startupInfo: startupInfo processInfo: processInfo
|
|
237 |
"Create a new process running in a separate address space. n.b., we use CreateProcessA
|
|
238 |
(the ANSI version) rather than CreateProcessW (the UNICODE/wide version) as we want the
|
|
239 |
daemon, vworad, to receive its command line arguments as ANSI strings not wide strings."
|
|
240 |
|
|
241 |
<C: BOOL CreateProcessA(
|
2089
|
242 |
LPCSTR imageName,
|
|
243 |
LPSTR commandLine,
|
1447
|
244 |
struct SECURITY_ATTRIBUTES *pSecurity,
|
|
245 |
struct SECURITY_ATTRIBUTES *tSecurity,
|
|
246 |
BOOL inheritHandles,
|
|
247 |
DWORD creationFlags,
|
|
248 |
LPVOID environment,
|
2089
|
249 |
LPCSTR currentDirectoryName,
|
|
250 |
struct STARTUPINFOA *startupInfo,
|
1447
|
251 |
struct PROCESS_INFORMATION *processInfo)>
|
325
|
252 |
|
|
253 |
"
|
|
254 |
self new
|
|
255 |
CreateProcess: 'foo' commandLine: 'foo bla' pSecurity: nil tSecurity: nil inheritHandles: false
|
|
256 |
creationFlags: 0 environment: nil currentDirectoryName: 'baz' startupInfo: nil processInfo: nil
|
|
257 |
"
|
|
258 |
!
|
|
259 |
|
|
260 |
TerminateProcess: hProcess exitCode: dwExitCode
|
1447
|
261 |
"Kill the specified process."
|
325
|
262 |
|
1447
|
263 |
self primTerminateProcess: hProcess exitCode: 1234
|
325
|
264 |
!
|
|
265 |
|
|
266 |
closeHandle: aHandle
|
1447
|
267 |
"Close an OS Handle decrementing it's use count."
|
325
|
268 |
|
1447
|
269 |
<C: int CloseHandle(HANDLE aHandle)>
|
325
|
270 |
!
|
|
271 |
|
|
272 |
primTerminateProcess: hProcess exitCode: dwExitCode
|
1447
|
273 |
"Kill the specified process."
|
325
|
274 |
|
1447
|
275 |
<C: BOOL TerminateProcess(HANDLE hProcess, DWORD dwExitCode)>
|
325
|
276 |
!
|
|
277 |
|
|
278 |
setCurrentDirectory: pathName
|
2091
|
279 |
"Set the current working directory."
|
325
|
280 |
|
2091
|
281 |
<C: BOOL _wincall
|
|
282 |
SetCurrentDirectoryA(LPCSTR pathName)>
|
|
283 |
"/ ^self externalAccessFailedWith: _errorCode
|
|
284 |
|
|
285 |
"Modified: / 04-03-2019 / 11:15:34 / Claus Gittinger"
|
325
|
286 |
! !
|
|
287 |
|
|
288 |
|
324
|
289 |
!ExternalInterfaceTests methodsFor:'tests'!
|
|
290 |
|
|
291 |
test_call_01
|
|
292 |
|fn|
|
|
293 |
|
671
|
294 |
OperatingSystem isMSWINDOWSlike ifFalse:[
|
1447
|
295 |
"This test makes sense only on windows"
|
|
296 |
^ self.
|
671
|
297 |
].
|
|
298 |
|
324
|
299 |
fn := ExternalLibraryFunction
|
1447
|
300 |
name:'Beep'
|
|
301 |
module:'kernel32.dll'
|
2090
|
302 |
callType:'api'
|
1447
|
303 |
returnType:(CType bool)
|
|
304 |
argumentTypes:(Array with:(CType unsignedLong) with:(CType unsignedLong)).
|
324
|
305 |
|
|
306 |
fn invokeWith:440 with:1.
|
|
307 |
|
|
308 |
"
|
|
309 |
self run:#test_call_01
|
|
310 |
self new test_call_01
|
|
311 |
"
|
2091
|
312 |
!
|
|
313 |
|
|
314 |
test_call_02
|
|
315 |
|fn|
|
|
316 |
|
|
317 |
fn := ExternalLibraryFunction
|
|
318 |
name:'printf'
|
|
319 |
module:'libc'
|
|
320 |
returnType:(CType void)
|
|
321 |
argumentTypes:(Array with:(CType charPointer)
|
|
322 |
with:(CType int)).
|
|
323 |
|
|
324 |
fn invokeWith:c'hello world %d\n' with:1.
|
|
325 |
|
|
326 |
"
|
|
327 |
self run:#test_call_02
|
|
328 |
self new test_call_02
|
|
329 |
"
|
|
330 |
|
|
331 |
"Created: / 04-03-2019 / 11:12:23 / Claus Gittinger"
|
2092
|
332 |
!
|
|
333 |
|
|
334 |
test_call_03
|
|
335 |
|fn nsApp|
|
|
336 |
|
|
337 |
OperatingSystem isOSXlike ifFalse:[
|
|
338 |
"This test makes sense only on OSX"
|
|
339 |
^ self
|
|
340 |
].
|
|
341 |
|
|
342 |
nsApp := ObjCClass named:'NSApplication'.
|
|
343 |
|
|
344 |
fn := ExternalLibraryFunction
|
|
345 |
name:'sharedApplication'
|
|
346 |
module:nil
|
|
347 |
callType:'objc'
|
|
348 |
returnType:(CType void)
|
|
349 |
argumentTypes:#().
|
|
350 |
|
|
351 |
fn invokeObjCOn:nsApp.
|
|
352 |
|
|
353 |
"
|
|
354 |
self run:#test_call_03
|
|
355 |
self new test_call_03
|
|
356 |
"
|
|
357 |
|
|
358 |
"Created: / 04-03-2019 / 11:41:02 / Claus Gittinger"
|
324
|
359 |
! !
|
|
360 |
|
325
|
361 |
!ExternalInterfaceTests methodsFor:'types'!
|
|
362 |
|
341
|
363 |
var1
|
|
364 |
<C: #define var1 1234>
|
|
365 |
|
|
366 |
"
|
|
367 |
self new var1
|
|
368 |
"
|
|
369 |
!
|
|
370 |
|
|
371 |
var2
|
|
372 |
<C: #define var1 "hello">
|
|
373 |
|
|
374 |
"
|
1447
|
375 |
self new var2
|
341
|
376 |
"
|
|
377 |
!
|
|
378 |
|
|
379 |
var3
|
|
380 |
<C: #define var1 1.2345>
|
|
381 |
|
|
382 |
"
|
1447
|
383 |
self new var3
|
341
|
384 |
"
|
325
|
385 |
! !
|
|
386 |
|
324
|
387 |
!ExternalInterfaceTests class methodsFor:'documentation'!
|
|
388 |
|
|
389 |
version
|
|
390 |
^ '$Header$'
|
2092
|
391 |
!
|
|
392 |
|
|
393 |
version_CVS
|
|
394 |
^ '$Header$'
|
324
|
395 |
! !
|
2091
|
396 |
|