ReactOS 0.4.16-dev-297-gc569aee
run.c File Reference
#include <stdio.h>
#include <initguid.h>
#include <windows.h>
#include <psapi.h>
#include <oaidl.h>
#include "wine/test.h"
Include dependency graph for run.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define CONST_VTABLE
 
#define PSAPI_VERSION   1
 
#define DEFINE_EXPECT(func)    static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
 
#define SET_EXPECT(func)    expect_ ## func = TRUE
 
#define CLEAR_CALLED(func)    expect_ ## func = called_ ## func = FALSE
 
#define CHECK_EXPECT2(func)
 
#define CHECK_EXPECT(func)
 
#define CHECK_CALLED(func)
 
#define DISPID_TESTOBJ_OK   10000
 
#define DISPID_TESTOBJ_TRACE   10001
 
#define DISPID_TESTOBJ_REPORTSUCCESS   10002
 
#define DISPID_TESTOBJ_WSCRIPTFULLNAME   10003
 
#define DISPID_TESTOBJ_WSCRIPTPATH   10004
 
#define DISPID_TESTOBJ_WSCRIPTSCRIPTNAME   10005
 
#define DISPID_TESTOBJ_WSCRIPTSCRIPTFULLNAME   10006
 
#define TESTOBJ_CLSID   "{178fc166-f585-4e24-9c13-4bb7faf80646}"
 

Functions

 DEFINE_EXPECT (reportSuccess)
 
static int strcmp_wa (LPCWSTR strw, const char *stra)
 
static const WCHARmystrrchr (const WCHAR *str, WCHAR ch)
 
static BSTR a2bstr (const char *str)
 
static HRESULT WINAPI Dispatch_QueryInterface (IDispatch *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI Dispatch_AddRef (IDispatch *iface)
 
static ULONG WINAPI Dispatch_Release (IDispatch *iface)
 
static HRESULT WINAPI Dispatch_GetTypeInfoCount (IDispatch *iface, UINT *pctinfo)
 
static HRESULT WINAPI Dispatch_GetTypeInfo (IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 
static HRESULT WINAPI Dispatch_GetIDsOfNames (IDispatch *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
 
static HRESULT WINAPI Dispatch_Invoke (IDispatch *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
 
static HRESULT WINAPI ClassFactory_QueryInterface (IClassFactory *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI ClassFactory_AddRef (IClassFactory *iface)
 
static ULONG WINAPI ClassFactory_Release (IClassFactory *iface)
 
static HRESULT WINAPI ClassFactory_CreateInstance (IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
 
static HRESULT WINAPI ClassFactory_LockServer (IClassFactory *iface, BOOL dolock)
 
static void run_script_file (const char *file_name, DWORD expected_exit_code)
 
static void run_script (const char *name, const char *script_data, size_t script_size, DWORD expected_exit_code)
 
static void run_simple_script (const char *script, DWORD expected_exit_code)
 
static BOOL WINAPI test_enum_proc (HMODULE module, LPCSTR type, LPSTR name, LONG_PTR param)
 
static BOOL init_key (const char *key_name, const char *def_value, BOOL init)
 
static BOOL init_registry (BOOL init)
 
static BOOL register_activex (void)
 
 START_TEST (run)
 

Variables

static const GUID CLSID_TestObj
 
static const charscript_name
 
static HANDLE wscript_process
 
static IDispatchVtbl testobj_vtbl
 
static IDispatch testobj = { &testobj_vtbl }
 
static const IClassFactoryVtbl ClassFactoryVtbl
 
static IClassFactory testobj_cf = { &ClassFactoryVtbl }
 

Macro Definition Documentation

◆ CHECK_CALLED

#define CHECK_CALLED (   func)
Value:
do { \
ok(called_ ## func, "expected " #func "\n"); \
expect_ ## func = called_ ## func = FALSE; \
}while(0)
#define FALSE
Definition: types.h:117
GLenum func
Definition: glext.h:6028
#define expect_(expected, got, precision)
Definition: font.c:29

Definition at line 53 of file run.c.

◆ CHECK_EXPECT

#define CHECK_EXPECT (   func)
Value:
do { \
CHECK_EXPECT2(func); \
expect_ ## func = FALSE; \
}while(0)

Definition at line 47 of file run.c.

◆ CHECK_EXPECT2

#define CHECK_EXPECT2 (   func)
Value:
do { \
ok(expect_ ##func, "unexpected call " #func "\n"); \
called_ ## func = TRUE; \
}while(0)
#define TRUE
Definition: types.h:120

Definition at line 41 of file run.c.

◆ CLEAR_CALLED

#define CLEAR_CALLED (   func)     expect_ ## func = called_ ## func = FALSE

Definition at line 38 of file run.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file run.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 22 of file run.c.

◆ DEFINE_EXPECT

#define DEFINE_EXPECT (   func)     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE

Definition at line 32 of file run.c.

◆ DISPID_TESTOBJ_OK

#define DISPID_TESTOBJ_OK   10000

Definition at line 61 of file run.c.

◆ DISPID_TESTOBJ_REPORTSUCCESS

#define DISPID_TESTOBJ_REPORTSUCCESS   10002

Definition at line 63 of file run.c.

◆ DISPID_TESTOBJ_TRACE

#define DISPID_TESTOBJ_TRACE   10001

Definition at line 62 of file run.c.

◆ DISPID_TESTOBJ_WSCRIPTFULLNAME

#define DISPID_TESTOBJ_WSCRIPTFULLNAME   10003

Definition at line 64 of file run.c.

◆ DISPID_TESTOBJ_WSCRIPTPATH

#define DISPID_TESTOBJ_WSCRIPTPATH   10004

Definition at line 65 of file run.c.

◆ DISPID_TESTOBJ_WSCRIPTSCRIPTFULLNAME

#define DISPID_TESTOBJ_WSCRIPTSCRIPTFULLNAME   10006

Definition at line 67 of file run.c.

◆ DISPID_TESTOBJ_WSCRIPTSCRIPTNAME

#define DISPID_TESTOBJ_WSCRIPTSCRIPTNAME   10005

Definition at line 66 of file run.c.

◆ PSAPI_VERSION

#define PSAPI_VERSION   1

Definition at line 24 of file run.c.

◆ SET_EXPECT

#define SET_EXPECT (   func)     expect_ ## func = TRUE

Definition at line 35 of file run.c.

◆ TESTOBJ_CLSID

#define TESTOBJ_CLSID   "{178fc166-f585-4e24-9c13-4bb7faf80646}"

Definition at line 69 of file run.c.

Function Documentation

◆ a2bstr()

static BSTR a2bstr ( const char str)
static

Definition at line 95 of file run.c.

96{
97 BSTR ret;
98 int len;
99
100 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
103
104 return ret;
105}
#define NULL
Definition: types.h:112
#define CP_ACP
Definition: compat.h:109
OLECHAR * BSTR
Definition: compat.h:2293
#define MultiByteToWideChar
Definition: compat.h:110
GLenum GLsizei len
Definition: glext.h:6722
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
const WCHAR * str
int ret

◆ ClassFactory_AddRef()

static ULONG WINAPI ClassFactory_AddRef ( IClassFactory iface)
static

Definition at line 312 of file run.c.

313{
314 return 2;
315}

◆ ClassFactory_CreateInstance()

static HRESULT WINAPI ClassFactory_CreateInstance ( IClassFactory iface,
IUnknown outer,
REFIID  riid,
void **  ppv 
)
static

Definition at line 322 of file run.c.

323{
324 ok(!outer, "outer = %p\n", outer);
325 return IDispatch_QueryInterface(&testobj, riid, ppv);
326}
#define ok(value,...)
Definition: atltest.h:57
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
static IDispatch testobj
Definition: run.c:299

◆ ClassFactory_LockServer()

static HRESULT WINAPI ClassFactory_LockServer ( IClassFactory iface,
BOOL  dolock 
)
static

Definition at line 328 of file run.c.

329{
330 return S_OK;
331}
#define S_OK
Definition: intsafe.h:52

◆ ClassFactory_QueryInterface()

static HRESULT WINAPI ClassFactory_QueryInterface ( IClassFactory iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 301 of file run.c.

302{
304 *ppv = iface;
305 return S_OK;
306 }
307
308 *ppv = NULL;
309 return E_NOINTERFACE;
310}
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ ClassFactory_Release()

static ULONG WINAPI ClassFactory_Release ( IClassFactory iface)
static

Definition at line 317 of file run.c.

318{
319 return 1;
320}

◆ DEFINE_EXPECT()

DEFINE_EXPECT ( reportSuccess  )

◆ Dispatch_AddRef()

static ULONG WINAPI Dispatch_AddRef ( IDispatch iface)
static

Definition at line 118 of file run.c.

119{
120 return 2;
121}

◆ Dispatch_GetIDsOfNames()

static HRESULT WINAPI Dispatch_GetIDsOfNames ( IDispatch iface,
REFIID  riid,
LPOLESTR rgszNames,
UINT  cNames,
LCID  lcid,
DISPID rgDispId 
)
static

Definition at line 141 of file run.c.

143{
144 unsigned i;
145
146 for(i=0; i<cNames; i++) {
147 if(!strcmp_wa(rgszNames[i], "ok")) {
148 rgDispId[i] = DISPID_TESTOBJ_OK;
149 }else if(!strcmp_wa(rgszNames[i], "trace")) {
150 rgDispId[i] = DISPID_TESTOBJ_TRACE;
151 }else if(!strcmp_wa(rgszNames[i], "reportSuccess")) {
153 }else if(!strcmp_wa(rgszNames[i], "wscriptFullName")) {
155 }else if(!strcmp_wa(rgszNames[i], "wscriptPath")) {
156 rgDispId[i] = DISPID_TESTOBJ_WSCRIPTPATH;
157 }else if(!strcmp_wa(rgszNames[i], "wscriptScriptName")) {
159 }else if(!strcmp_wa(rgszNames[i], "wscriptScriptFullName")) {
161 }else {
162 ok(0, "unexpected name %s\n", wine_dbgstr_w(rgszNames[i]));
163 return DISP_E_UNKNOWNNAME;
164 }
165 }
166
167 return S_OK;
168}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define wine_dbgstr_w
Definition: kernel32.h:34
static int strcmp_wa(LPCWSTR strw, const char *stra)
Definition: run.c:219
#define DISPID_TESTOBJ_WSCRIPTFULLNAME
Definition: run.c:64
#define DISPID_TESTOBJ_REPORTSUCCESS
Definition: run.c:63
#define DISPID_TESTOBJ_WSCRIPTSCRIPTNAME
Definition: run.c:66
#define DISPID_TESTOBJ_TRACE
Definition: run.c:62
#define DISPID_TESTOBJ_OK
Definition: run.c:61
#define DISPID_TESTOBJ_WSCRIPTSCRIPTFULLNAME
Definition: run.c:67
#define DISPID_TESTOBJ_WSCRIPTPATH
Definition: run.c:65
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515

◆ Dispatch_GetTypeInfo()

static HRESULT WINAPI Dispatch_GetTypeInfo ( IDispatch iface,
UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
static

Definition at line 134 of file run.c.

136{
137 ok(0, "unexpected call\n");
138 return E_NOTIMPL;
139}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ Dispatch_GetTypeInfoCount()

static HRESULT WINAPI Dispatch_GetTypeInfoCount ( IDispatch iface,
UINT pctinfo 
)
static

Definition at line 128 of file run.c.

129{
130 ok(0, "unexpected call\n");
131 return E_NOTIMPL;
132}

◆ Dispatch_Invoke()

static HRESULT WINAPI Dispatch_Invoke ( IDispatch iface,
DISPID  dispIdMember,
REFIID  riid,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pdp,
VARIANT pVarResult,
EXCEPINFO *  pExcepInfo,
UINT puArgErr 
)
static

Definition at line 170 of file run.c.

172{
173 switch(dispIdMember) {
174 case DISPID_TESTOBJ_OK: {
175 VARIANT *expr, *msg;
176
177 ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
178 ok(pdp->cArgs == 2, "cArgs = %d\n", pdp->cArgs);
179 ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
180
181 expr = pdp->rgvarg+1;
182 if(V_VT(expr) == (VT_VARIANT|VT_BYREF))
184
185 msg = pdp->rgvarg;
186 if(V_VT(msg) == (VT_VARIANT|VT_BYREF))
188
189 ok(V_VT(msg) == VT_BSTR, "V_VT(psp->rgvargs) = %d\n", V_VT(msg));
190 ok(V_VT(expr) == VT_BOOL, "V_VT(psp->rgvargs+1) = %d\n", V_VT(expr));
191 ok(V_BOOL(expr), "%s: %s\n", script_name, wine_dbgstr_w(V_BSTR(msg)));
192 if(pVarResult)
193 V_VT(pVarResult) = VT_EMPTY;
194 break;
195 }
197 ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
198 ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
199 ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
200 ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp->rgvarg));
201 trace("%s: %s\n", script_name, wine_dbgstr_w(V_BSTR(pdp->rgvarg)));
202 if(pVarResult)
203 V_VT(pVarResult) = VT_EMPTY;
204 break;
206 CHECK_EXPECT(reportSuccess);
207
208 ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
209 ok(pdp->cArgs == 0, "cArgs = %d\n", pdp->cArgs);
210 ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
211 if(pVarResult)
212 V_VT(pVarResult) = VT_EMPTY;
213 break;
215 {
217 DWORD res;
218
219 ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
220 ok(pdp->cArgs == 0, "cArgs = %d\n", pdp->cArgs);
221 ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
222 V_VT(pVarResult) = VT_BSTR;
224 if(res == 0)
225 return E_FAIL;
226 if(!(V_BSTR(pVarResult) = SysAllocString(fullName)))
227 return E_OUTOFMEMORY;
228 break;
229 }
231 {
232 WCHAR fullPath[MAX_PATH];
233 DWORD res;
234 const WCHAR *pos;
235
236 ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
237 ok(pdp->cArgs == 0, "cArgs = %d\n", pdp->cArgs);
238 ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
239 V_VT(pVarResult) = VT_BSTR;
240 res = GetModuleFileNameExW(wscript_process, NULL, fullPath, ARRAY_SIZE(fullPath));
241 if(res == 0)
242 return E_FAIL;
243 pos = mystrrchr(fullPath, '\\');
244 if(!(V_BSTR(pVarResult) = SysAllocStringLen(fullPath, pos-fullPath)))
245 return E_OUTOFMEMORY;
246 break;
247 }
249 {
250 char fullPath[MAX_PATH];
251 char *pos;
252 long res;
253
254 ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
255 ok(pdp->cArgs == 0, "cArgs = %d\n", pdp->cArgs);
256 ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
257 V_VT(pVarResult) = VT_BSTR;
258 res = GetFullPathNameA(script_name, sizeof(fullPath), fullPath, &pos);
259 if(!res || res > sizeof(fullPath))
260 return E_FAIL;
261 if(!(V_BSTR(pVarResult) = a2bstr(pos)))
262 return E_OUTOFMEMORY;
263 break;
264 }
266 {
267 char fullPath[MAX_PATH];
268 long res;
269
270 ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
271 ok(pdp->cArgs == 0, "cArgs = %d\n", pdp->cArgs);
272 ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
273 V_VT(pVarResult) = VT_BSTR;
274 res = GetFullPathNameA(script_name, sizeof(fullPath), fullPath, NULL);
275 if(!res || res > sizeof(fullPath))
276 return E_FAIL;
277 if(!(V_BSTR(pVarResult) = a2bstr(fullPath)))
278 return E_OUTOFMEMORY;
279 break;
280 }
281 default:
282 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
283 return E_NOTIMPL;
284 }
285
286 return S_OK;
287}
#define trace
Definition: atltest.h:70
#define msg(x)
Definition: auth_time.c:54
#define ARRAY_SIZE(A)
Definition: main.h:20
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
static WCHAR fullName[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1902
#define GetModuleFileNameExW(w, x, y, z)
Definition: compat.h:922
#define MAX_PATH
Definition: compat.h:34
@ VT_BSTR
Definition: compat.h:2303
@ VT_BYREF
Definition: compat.h:2342
@ VT_VARIANT
Definition: compat.h:2307
@ VT_BOOL
Definition: compat.h:2306
@ VT_EMPTY
Definition: compat.h:2295
DWORD WINAPI GetFullPathNameA(IN LPCSTR lpFileName, IN DWORD nBufferLength, OUT LPSTR lpBuffer, OUT LPSTR *lpFilePart)
Definition: path.c:993
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
#define CHECK_EXPECT(func)
Definition: run.c:67
static BSTR a2bstr(const char *str)
Definition: run.c:207
static const WCHAR * mystrrchr(const WCHAR *str, WCHAR ch)
Definition: run.c:84
static const char * script_name
Definition: run.c:74
static HANDLE wscript_process
Definition: run.c:75
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
#define V_BOOL(A)
Definition: oleauto.h:224
#define V_VARIANTREF(A)
Definition: oleauto.h:283
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
Definition: query.h:86
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ Dispatch_QueryInterface()

static HRESULT WINAPI Dispatch_QueryInterface ( IDispatch iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 107 of file run.c.

108{
110 *ppv = iface;
111 return S_OK;
112 }
113
114 *ppv = NULL;
115 return E_NOINTERFACE;
116}
const GUID IID_IDispatch

◆ Dispatch_Release()

static ULONG WINAPI Dispatch_Release ( IDispatch iface)
static

Definition at line 123 of file run.c.

124{
125 return 1;
126}

◆ init_key()

static BOOL init_key ( const char key_name,
const char def_value,
BOOL  init 
)
static

Definition at line 435 of file run.c.

436{
437 HKEY hkey;
438 DWORD res;
439
440 if(!init) {
442 return TRUE;
443 }
444
446 if(res != ERROR_SUCCESS)
447 return FALSE;
448
449 if(def_value)
450 res = RegSetValueA(hkey, NULL, REG_SZ, def_value, strlen(def_value));
451
452 RegCloseKey(hkey);
453 return res == ERROR_SUCCESS;
454}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1179
LONG WINAPI RegSetValueA(HKEY hKeyOriginal, LPCSTR lpSubKey, DWORD dwType, LPCSTR lpData, DWORD cbData)
Definition: reg.c:4954
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1224
#define REG_SZ
Definition: layer.c:22
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
static int init
Definition: wintirpc.c:33

Referenced by init_registry().

◆ init_registry()

static BOOL init_registry ( BOOL  init)
static

Definition at line 456 of file run.c.

457{
458 return init_key("Wine.Test\\CLSID", TESTOBJ_CLSID, init);
459}
static BOOL init_key(const char *key_name, const char *def_value, BOOL init)
Definition: run.c:435
#define TESTOBJ_CLSID
Definition: run.c:69

Referenced by register_activex(), and START_TEST().

◆ mystrrchr()

static const WCHAR * mystrrchr ( const WCHAR str,
WCHAR  ch 
)
static

Definition at line 84 of file run.c.

85{
86 const WCHAR *pos = NULL, *current = str;
87 while(*current != 0) {
88 if(*current == ch)
89 pos = current;
90 ++current;
91 }
92 return pos;
93}
struct task_struct * current
Definition: linux.c:32

Referenced by Dispatch_Invoke().

◆ register_activex()

static BOOL register_activex ( void  )
static

Definition at line 461 of file run.c.

462{
463 DWORD regid;
465
466 if(!init_registry(TRUE)) {
468 return FALSE;
469 }
470
472 CLSCTX_SERVER, REGCLS_MULTIPLEUSE, &regid);
473 ok(hres == S_OK, "Could not register script engine: %08x\n", hres);
474 return TRUE;
475}
HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid, LPUNKNOWN pUnk, DWORD dwClsContext, DWORD flags, LPDWORD lpdwRegister)
Definition: compobj.c:2897
#define regid
Definition: ecma_167.h:64
HRESULT hres
Definition: protocol.c:465
static IClassFactory testobj_cf
Definition: run.c:341
static const GUID CLSID_TestObj
Definition: run.c:71
static BOOL init_registry(BOOL init)
Definition: run.c:456
@ REGCLS_MULTIPLEUSE
Definition: objbase.h:393

Referenced by START_TEST().

◆ run_script()

static void run_script ( const char name,
const char script_data,
size_t  script_size,
DWORD  expected_exit_code 
)
static

Definition at line 376 of file run.c.

377{
378 char file_name[MAX_PATH];
379 const char *ext;
380 HANDLE file;
381 DWORD size;
382 BOOL res;
383
384 ext = strrchr(name, '.');
385 ok(ext != NULL, "no script extension\n");
386 if(!ext)
387 return;
388
389 sprintf(file_name, "test%s", ext);
390
393 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
395 return;
396
397 res = WriteFile(file, script_data, script_size, &size, NULL);
399 ok(res, "Could not write to file: %u\n", GetLastError());
400 if(!res)
401 return;
402
403 run_script_file(file_name, expected_exit_code);
404
406}
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
static const WCHAR *const ext[]
Definition: module.c:53
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
#define CREATE_ALWAYS
Definition: disk.h:72
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static LPCWSTR file_name
Definition: protocol.c:147
static void run_script_file(const char *file_name, DWORD expected_exit_code)
Definition: run.c:343
#define GENERIC_WRITE
Definition: nt_native.h:90
_CRT_RESTORE_GCC_WARNINGS _CRT_DISABLE_GCC_WARNINGS _Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
Definition: fci.c:127
Definition: name.c:39
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by run_simple_script(), and test_enum_proc().

◆ run_script_file()

static void run_script_file ( const char file_name,
DWORD  expected_exit_code 
)
static

Definition at line 343 of file run.c.

344{
345 char command[MAX_PATH];
346 STARTUPINFOA si = {sizeof(si)};
349 BOOL bres;
350
352 sprintf(command, "wscript.exe %s arg1 2 ar3", file_name);
353
354 SET_EXPECT(reportSuccess);
355
356 bres = CreateProcessA(NULL, command, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
357 if(!bres) {
358 win_skip("script.exe is not available\n");
359 CLEAR_CALLED(reportSuccess);
360 return;
361 }
362
363 wscript_process = pi.hProcess;
365
366 bres = GetExitCodeProcess(pi.hProcess, &exit_code);
367 ok(bres, "GetExitCodeProcess failed: %u\n", GetLastError());
368 ok(exit_code == expected_exit_code, "exit_code = %u, expected %u\n", exit_code, expected_exit_code);
369
370 CloseHandle(pi.hThread);
371 CloseHandle(pi.hProcess);
372
373 CHECK_CALLED(reportSuccess);
374}
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1168
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4747
#define INFINITE
Definition: serial.h:102
#define SET_EXPECT(func)
Definition: run.c:58
#define CHECK_CALLED(func)
Definition: run.c:73
static UINT exit_code
Definition: process.c:78
static refpint_t pi[]
Definition: server.c:96
#define CLEAR_CALLED(func)
Definition: run.c:88
#define win_skip
Definition: test.h:163
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82

Referenced by run_script(), and START_TEST().

◆ run_simple_script()

static void run_simple_script ( const char script,
DWORD  expected_exit_code 
)
static

Definition at line 408 of file run.c.

409{
410 run_script("simple.js", script, strlen(script), expected_exit_code);
411}
static void run_script(const char *name, const char *script_data, size_t script_size, DWORD expected_exit_code)
Definition: run.c:376
script
Definition: msipriv.h:383

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( run  )

Definition at line 477 of file run.c.

478{
479 char **argv;
480 int argc;
481
483
484 if(!register_activex()) {
485 skip("Could not register ActiveX object.\n");
487 return;
488 }
489
491 if(argc > 2) {
492 run_script_file(argv[2], 0);
493 }else {
494 EnumResourceNamesA(NULL, "TESTSCRIPT", test_enum_proc, 0);
495
496 run_simple_script("var winetest = new ActiveXObject('Wine.Test');\n"
497 "winetest.reportSuccess();\n"
498 "WScript.Quit(3);\n"
499 "winetest.ok(false, 'not quit?');\n", 3);
500}
501
504}
static int argc
Definition: ServiceArgs.c:12
#define skip(...)
Definition: atltest.h:64
BOOL WINAPI EnumResourceNamesA(HMODULE hmod, LPCSTR type, ENUMRESNAMEPROCA lpfun, LONG_PTR lparam)
Definition: res.c:285
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static void run_simple_script(const char *script, DWORD expected_exit_code)
Definition: run.c:408
static BOOL register_activex(void)
Definition: run.c:461
static BOOL WINAPI test_enum_proc(HMODULE module, LPCSTR type, LPSTR name, LONG_PTR param)
Definition: run.c:413
#define argv
Definition: mplay32.c:18
@ COINIT_MULTITHREADED
Definition: objbase.h:279
int winetest_get_mainargs(char ***pargv)

◆ strcmp_wa()

static int strcmp_wa ( LPCWSTR  strw,
const char stra 
)
static

Definition at line 77 of file run.c.

78{
79 WCHAR buf[512];
81 return lstrcmpW(strw, buf);
82}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static const char * strw(LPCWSTR x)
Definition: actctx.c:49

◆ test_enum_proc()

static BOOL WINAPI test_enum_proc ( HMODULE  module,
LPCSTR  type,
LPSTR  name,
LONG_PTR  param 
)
static

Definition at line 413 of file run.c.

414{
415 const char *script_data;
416 DWORD script_size;
417 HRSRC src;
418
419 trace("running %s test...\n", name);
420
422 ok(src != NULL, "Could not find resource %s: %u\n", name, GetLastError());
423 if(!src)
424 return TRUE;
425
426 script_data = LoadResource(NULL, src);
427 script_size = SizeofResource(NULL, src);
428 while(script_size && !script_data[script_size-1])
429 script_size--;
430
431 run_script(name, script_data, script_size, 0);
432 return TRUE;
433}
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum src
Definition: glext.h:6340

Referenced by START_TEST().

Variable Documentation

◆ ClassFactoryVtbl

const IClassFactoryVtbl ClassFactoryVtbl
static
Initial value:
= {
}
static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: run.c:322
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
Definition: run.c:328
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
Definition: run.c:317
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
Definition: run.c:301
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
Definition: run.c:312

Definition at line 333 of file run.c.

◆ CLSID_TestObj

const GUID CLSID_TestObj
static
Initial value:
=
{0x178fc166,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}}

Definition at line 71 of file run.c.

Referenced by register_activex().

◆ script_name

const char* script_name
static

Definition at line 74 of file run.c.

Referenced by Dispatch_Invoke(), run_benchmark(), and run_script_file().

◆ testobj

IDispatch testobj = { &testobj_vtbl }
static

Definition at line 299 of file run.c.

Referenced by ClassFactory_CreateInstance().

◆ testobj_cf

IClassFactory testobj_cf = { &ClassFactoryVtbl }
static

Definition at line 341 of file run.c.

Referenced by register_activex().

◆ testobj_vtbl

IDispatchVtbl testobj_vtbl
static
Initial value:
= {
}
static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
Definition: run.c:128
static ULONG WINAPI Dispatch_Release(IDispatch *iface)
Definition: run.c:123
static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: run.c:170
static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: run.c:134
static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
Definition: run.c:118
static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
Definition: run.c:107
static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: run.c:141

Definition at line 289 of file run.c.

◆ wscript_process

HANDLE wscript_process
static

Definition at line 75 of file run.c.

Referenced by Dispatch_Invoke(), and run_script_file().