ReactOS 0.4.16-dev-753-g705a985
data.c File Reference
#include "wine/test.h"
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <io.h>
#include <windef.h>
#include <winbase.h>
#include <winnls.h>
#include <process.h>
#include <errno.h>
#include <direct.h>
Include dependency graph for data.c:

Go to the source code of this file.

Macros

#define initterm_test(start, end, expected)
 

Typedefs

typedef void(__cdecl_INITTERMFUN) (void)
 

Functions

static int *__cdeclp___p___argc (void)
 
static char ***__cdeclp___p___argv (void)
 
static void (__cdecl *p_initterm)(_INITTERMFUN *start
 
static int (__cdecl *p_get_pgmptr)(char **p)
 
static void __cdecl initcallback (void)
 
static void test_initterm (void)
 
static void test_initvar (HMODULE hmsvcrt)
 
static void test_get_pgmptr (void)
 
static void test___getmainargs (void)
 
static void test___getmainargs_parent (char *name)
 
 START_TEST (data)
 

Variables

static _INITTERMFUNend
 
static int callbacked
 

Macro Definition Documentation

◆ initterm_test

#define initterm_test (   start,
  end,
  expected 
)
Value:
callbacked = 0; \
p_initterm(start, end); \
ok(expected == callbacked,"_initterm: callbacks count mismatch: got %i, expected %i\n", callbacked, expected);
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
BOOL expected
Definition: store.c:2063
static int callbacked
Definition: data.c:48

Definition at line 55 of file data.c.

Typedef Documentation

◆ _INITTERMFUN

typedef void(__cdecl * _INITTERMFUN) (void)

Definition at line 43 of file data.c.

Function Documentation

◆ initcallback()

static void __cdecl initcallback ( void  )
static

Definition at line 50 of file data.c.

51{
52 callbacked++;
53}

Referenced by test_initterm().

◆ int()

static int ( __cdecl p_get_pgmptr)
static

◆ p___p___argc()

static int *__cdecl * p___p___argc ( void  )
static

Referenced by START_TEST(), and test___getmainargs().

◆ p___p___argv()

static char ***__cdecl * p___p___argv ( void  )
static

Referenced by START_TEST(), and test___getmainargs().

◆ START_TEST()

START_TEST ( data  )

Definition at line 234 of file data.c.

235{
236 HMODULE hmsvcrt;
237 int arg_c;
238 char** arg_v;
239
240 hmsvcrt = GetModuleHandleA("msvcrt.dll");
241 if (!hmsvcrt)
242 hmsvcrt = GetModuleHandleA("msvcrtd.dll");
243 if (hmsvcrt)
244 {
245 p_initterm=(void*)GetProcAddress(hmsvcrt, "_initterm");
246 p_get_pgmptr=(void*)GetProcAddress(hmsvcrt, "_get_pgmptr");
247 p___p___argc=(void*)GetProcAddress(hmsvcrt, "__p___argc");
248 p___p___argv=(void*)GetProcAddress(hmsvcrt, "__p___argv");
249 }
250
251 arg_c = winetest_get_mainargs(&arg_v);
252 if(arg_c >= 3) {
254 return;
255 }
256
258 test_initvar(hmsvcrt);
261}
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void test___getmainargs_parent(char *name)
Definition: data.c:198
static char ***__cdecl * p___p___argv(void)
static void test_initvar(HMODULE hmsvcrt)
Definition: data.c:81
static int *__cdecl * p___p___argc(void)
static void test_get_pgmptr(void)
Definition: data.c:122
static void test_initterm(void)
Definition: data.c:60
static void test___getmainargs(void)
Definition: data.c:136
int winetest_get_mainargs(char ***pargv)

◆ test___getmainargs()

static void test___getmainargs ( void  )
static

Definition at line 136 of file data.c.

137{
138 int argc, new_argc, mode;
139 char **argv, **new_argv, **envp;
140 char tmppath[MAX_PATH], filepath[MAX_PATH + 14];
141 FILE *f;
142
143 ok(GetTempPathA(MAX_PATH, tmppath) != 0, "GetTempPath failed\n");
144
145 mode = 0;
146 __getmainargs(&argc, &argv, &envp, 0, &mode);
147 ok(argc == 4, "argc = %d\n", argc);
148 ok(!strcmp(argv[1], "data"), "argv[1] = %s\n", argv[1]);
149 sprintf(filepath, "%s*\\*", tmppath);
150 ok(!strcmp(argv[2], filepath), "argv[2] = %s\n", argv[2]);
151 sprintf(filepath, "%swine_test/*", tmppath);
152 ok(!strcmp(argv[3], filepath), "argv[3] = %s\n", argv[3]);
153 ok(!argv[4], "argv[4] != NULL\n");
154
156 new_argc = *p___p___argc();
157 new_argv = *p___p___argv();
158 ok(new_argc == 4, "*__p___argc() = %d\n", new_argc);
159 ok(new_argv == argv, "*__p___argv() = %p, expected %p\n", new_argv, argv);
160 }
161 else skip("__p___argc or __p___argv is not available\n");
162
163 mode = 0;
164 __getmainargs(&argc, &argv, &envp, 1, &mode);
165 ok(argc == 5, "argc = %d\n", argc);
166 ok(!strcmp(argv[1], "data"), "argv[1] = %s\n", argv[1]);
167 sprintf(filepath, "%s*\\*", tmppath);
168 ok(!strcmp(argv[2], filepath), "argv[2] = %s\n", argv[2]);
169 sprintf(filepath, "%swine_test/a", tmppath);
170 if(argv[3][strlen(argv[3])-1] == 'a') {
171 ok(!strcmp(argv[3], filepath), "argv[3] = %s\n", argv[3]);
172 sprintf(filepath, "%swine_test/test", tmppath);
173 ok(!strcmp(argv[4], filepath), "argv[4] = %s\n", argv[4]);
174 }else {
175 ok(!strcmp(argv[4], filepath), "argv[4] = %s\n", argv[4]);
176 sprintf(filepath, "%swine_test/test", tmppath);
177 ok(!strcmp(argv[3], filepath), "argv[3] = %s\n", argv[3]);
178 }
179 ok(!argv[5], "argv[5] != NULL\n");
180
182 new_argc = *p___p___argc();
183 new_argv = *p___p___argv();
184 ok(new_argc == argc, "*__p___argc() = %d, expected %d\n", new_argc, argc);
185 ok(new_argv == argv, "*__p___argv() = %p, expected %p\n", new_argv, argv);
186 }
187
188 sprintf(filepath, "%swine_test/b", tmppath);
189 f = fopen(filepath, "w");
190 ok(f != NULL, "fopen(%s) failed: %d\n", filepath, errno);
191 fclose(f);
192 mode = 0;
193 __getmainargs(&new_argc, &new_argv, &envp, 1, &mode);
194 ok(new_argc == argc+1, "new_argc = %d, expected %d\n", new_argc, argc+1);
195 _unlink(filepath);
196}
static int argc
Definition: ServiceArgs.c:12
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
void __getmainargs(int *argc, char ***argv, char ***envp, int expand_wildcards, int *new_mode)
Definition: getargs.c:182
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
GLfloat f
Definition: glext.h:7540
GLenum mode
Definition: glext.h:6217
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
#define f
Definition: ke_i.h:83
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define argv
Definition: mplay32.c:18
#define errno
Definition: errno.h:18
_Check_return_ _CRTIMP int __cdecl _unlink(_In_z_ const char *_Filename)

Referenced by START_TEST().

◆ test___getmainargs_parent()

static void test___getmainargs_parent ( char name)
static

Definition at line 198 of file data.c.

199{
200 char cmdline[3*MAX_PATH];
201 char tmppath[MAX_PATH], filepath[MAX_PATH + 14];
204 FILE *f;
205 int ret;
206
207 ok(GetTempPathA(MAX_PATH, tmppath) != 0, "GetTempPath failed\n");
208 sprintf(cmdline, "%s data %s*\\* %swine_test/*", name, tmppath, tmppath);
209
210 sprintf(filepath, "%swine_test", tmppath);
211 ret = _mkdir(filepath);
212 ok(!ret, "_mkdir failed: %d\n", errno);
213 sprintf(filepath, "%swine_test\\a", tmppath);
214 f = fopen(filepath, "w");
215 ok(f != NULL, "fopen(%s) failed: %d\n", filepath, errno);
216 fclose(f);
217 sprintf(filepath, "%swine_test\\test", tmppath);
218 f = fopen(filepath, "w");
219 ok(f != NULL, "fopen(%s) failed: %d\n", filepath, errno);
220 fclose(f);
221
222 memset(&startup, 0, sizeof(startup));
223 startup.cb = sizeof(startup);
225 wait_child_process(proc.hProcess);
226
227 _unlink(filepath);
228 sprintf(filepath, "%swine_test\\a", tmppath);
229 _unlink(filepath);
230 sprintf(filepath, "%swine_test", tmppath);
231 _rmdir(filepath);
232}
static void startup(void)
_Check_return_ _CRTIMP int __cdecl _rmdir(_In_z_ const char *_Path)
_Check_return_ _CRTIMP int __cdecl _mkdir(_In_z_ const char *_Path)
#define TRUE
Definition: types.h:120
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
static HANDLE proc()
Definition: pdb.c:34
#define wait_child_process
Definition: test.h:166
#define memset(x, y, z)
Definition: compat.h:39
TCHAR * cmdline
Definition: stretchblt.cpp:32
Definition: name.c:39
int ret
#define NORMAL_PRIORITY_CLASS
Definition: winbase.h:184
#define CREATE_DEFAULT_ERROR_MODE
Definition: winbase.h:214

Referenced by START_TEST().

◆ test_get_pgmptr()

static void test_get_pgmptr ( void  )
static

Definition at line 122 of file data.c.

123{
124 char *pgm = NULL;
125 int res;
126
127 if (!p_get_pgmptr)
128 return;
129
130 res = p_get_pgmptr(&pgm);
131
132 ok( res == 0, "Wrong _get_pgmptr return value %d expected 0\n", res);
133 ok( pgm != NULL, "_get_pgmptr returned a NULL pointer\n" );
134}
GLuint res
Definition: glext.h:9613

Referenced by START_TEST().

◆ test_initterm()

static void test_initterm ( void  )
static

Definition at line 60 of file data.c.

61{
62 int i;
63 static _INITTERMFUN callbacks[4];
64
65 if (!p_initterm)
66 return;
67
68 for (i = 0; i < 4; i++)
69 {
71 }
72
76
77 callbacks[1] = NULL;
79}
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
static void __cdecl initcallback(void)
Definition: data.c:50
void(__cdecl * _INITTERMFUN)(void)
Definition: data.c:43
#define initterm_test(start, end, expected)
Definition: data.c:55
static int callbacks
Definition: xmllint.c:838

Referenced by START_TEST().

◆ test_initvar()

static void test_initvar ( HMODULE  hmsvcrt)
static

Definition at line 81 of file data.c.

82{
84 int *pp_winver = (int*)GetProcAddress(hmsvcrt, "_winver");
85 int *pp_winmajor = (int*)GetProcAddress(hmsvcrt, "_winmajor");
86 int *pp_winminor = (int*)GetProcAddress(hmsvcrt, "_winminor");
87 int *pp_osver = (int*)GetProcAddress(hmsvcrt, "_osver");
88 int *pp_osplatform = (int*)GetProcAddress(hmsvcrt, "_osplatform");
89 unsigned int winver, winmajor, winminor, osver, osplatform;
90
91 if( !( pp_winmajor && pp_winminor && pp_winver)) {
92 win_skip("_winver variables are not available\n");
93 return;
94 }
95 winver = *pp_winver;
96 winminor = *pp_winminor;
97 winmajor = *pp_winmajor;
99 ok( winminor == osvi.dwMinorVersion, "Wrong value for _winminor %02x expected %02lx\n",
100 winminor, osvi.dwMinorVersion);
101 ok( winmajor == osvi.dwMajorVersion, "Wrong value for _winmajor %02x expected %02lx\n",
102 winmajor, osvi.dwMajorVersion);
103 ok( winver == ((osvi.dwMajorVersion << 8) | osvi.dwMinorVersion),
104 "Wrong value for _winver %02x expected %02lx\n",
105 winver, ((osvi.dwMajorVersion << 8) | osvi.dwMinorVersion));
106 if( !pp_osver || !pp_osplatform ) {
107 win_skip("_osver variables are not available\n");
108 return;
109 }
110 osver = *pp_osver;
111 osplatform = *pp_osplatform;
112 ok( osver == (osvi.dwBuildNumber & 0xffff) ||
114 ((osvi.dwBuildNumber >> 16) & 0xff) == osvi.dwMinorVersion), /* 95/98/ME */
115 "Wrong value for _osver %04x expected %04lx\n",
116 osver, osvi.dwBuildNumber);
117 ok(osplatform == osvi.dwPlatformId,
118 "Wrong value for _osplatform %x expected %lx\n",
119 osplatform, osvi.dwPlatformId);
120}
BOOL WINAPI GetVersionExA(IN LPOSVERSIONINFOA lpVersionInformation)
Definition: version.c:69
#define win_skip
Definition: test.h:164
ULONG dwPlatformId
Definition: rtltypes.h:241
ULONG dwMajorVersion
Definition: rtltypes.h:238
ULONG dwBuildNumber
Definition: rtltypes.h:240
ULONG dwMinorVersion
Definition: rtltypes.h:239
OSVERSIONINFO osvi
Definition: ver.c:28
struct _OSVERSIONINFOA OSVERSIONINFOA

Referenced by START_TEST().

◆ void()

static void ( __cdecl p_initterm)
static

Variable Documentation

◆ callbacked

int callbacked
static

Definition at line 48 of file data.c.

Referenced by initcallback().

◆ end

Definition at line 44 of file data.c.