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