kernel32/tests: Use BOOL type where appropriate.
This commit is contained in:
parent
7ab78b4e03
commit
f56e9ebe38
|
@ -51,7 +51,8 @@ static void test_Heap(void)
|
||||||
HANDLE heap;
|
HANDLE heap;
|
||||||
LPVOID mem1,mem1a,mem3;
|
LPVOID mem1,mem1a,mem3;
|
||||||
UCHAR *mem2,*mem2a;
|
UCHAR *mem2,*mem2a;
|
||||||
UINT error,i;
|
UINT i;
|
||||||
|
BOOL error;
|
||||||
DWORD dwSize;
|
DWORD dwSize;
|
||||||
|
|
||||||
/* Retrieve the page size for this system */
|
/* Retrieve the page size for this system */
|
||||||
|
@ -86,10 +87,10 @@ static void test_Heap(void)
|
||||||
ok(mem2!=NULL,"HeapAlloc failed\n");
|
ok(mem2!=NULL,"HeapAlloc failed\n");
|
||||||
if(mem2) {
|
if(mem2) {
|
||||||
ok(HeapSize(heap,0,mem2)>=memchunk,"HeapAlloc should return a big enough memory block\n");
|
ok(HeapSize(heap,0,mem2)>=memchunk,"HeapAlloc should return a big enough memory block\n");
|
||||||
error=0;
|
error=FALSE;
|
||||||
for(i=0;i<memchunk;i++) {
|
for(i=0;i<memchunk;i++) {
|
||||||
if(mem2[i]!=0) {
|
if(mem2[i]!=0) {
|
||||||
error=1;
|
error=TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ok(!error,"HeapAlloc should have zeroed out it's allocated memory\n");
|
ok(!error,"HeapAlloc should have zeroed out it's allocated memory\n");
|
||||||
|
@ -107,24 +108,24 @@ static void test_Heap(void)
|
||||||
ok(mem2a!=NULL,"HeapReAlloc failed\n");
|
ok(mem2a!=NULL,"HeapReAlloc failed\n");
|
||||||
if(mem2a) {
|
if(mem2a) {
|
||||||
ok(HeapSize(heap,0,mem2a)>=memchunk+5*sysInfo.dwPageSize,"HeapReAlloc failed\n");
|
ok(HeapSize(heap,0,mem2a)>=memchunk+5*sysInfo.dwPageSize,"HeapReAlloc failed\n");
|
||||||
error=0;
|
error=FALSE;
|
||||||
for(i=0;i<5*sysInfo.dwPageSize;i++) {
|
for(i=0;i<5*sysInfo.dwPageSize;i++) {
|
||||||
if(mem2a[memchunk+i]!=0) {
|
if(mem2a[memchunk+i]!=0) {
|
||||||
error=1;
|
error=TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ok(!error,"HeapReAlloc should have zeroed out it's allocated memory\n");
|
ok(!error,"HeapReAlloc should have zeroed out it's allocated memory\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that HeapRealloc honours HEAP_REALLOC_IN_PLACE_ONLY */
|
/* Check that HeapRealloc honours HEAP_REALLOC_IN_PLACE_ONLY */
|
||||||
error=0;
|
error=FALSE;
|
||||||
mem1a=HeapReAlloc(heap,HEAP_REALLOC_IN_PLACE_ONLY,mem1,memchunk+sysInfo.dwPageSize);
|
mem1a=HeapReAlloc(heap,HEAP_REALLOC_IN_PLACE_ONLY,mem1,memchunk+sysInfo.dwPageSize);
|
||||||
if(mem1a!=NULL) {
|
if(mem1a!=NULL) {
|
||||||
if(mem1a!=mem1) {
|
if(mem1a!=mem1) {
|
||||||
error=1;
|
error=TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ok(mem1a==NULL || error==0,"HeapReAlloc didn't honour HEAP_REALLOC_IN_PLACE_ONLY\n");
|
ok(mem1a==NULL || !error,"HeapReAlloc didn't honour HEAP_REALLOC_IN_PLACE_ONLY\n");
|
||||||
|
|
||||||
/* Check that HeapFree works correctly */
|
/* Check that HeapFree works correctly */
|
||||||
if(mem1a) {
|
if(mem1a) {
|
||||||
|
@ -168,7 +169,8 @@ static void test_Global(void)
|
||||||
ULONG memchunk;
|
ULONG memchunk;
|
||||||
HGLOBAL mem1,mem2,mem2a,mem2b;
|
HGLOBAL mem1,mem2,mem2a,mem2b;
|
||||||
UCHAR *mem2ptr;
|
UCHAR *mem2ptr;
|
||||||
UINT error,i;
|
UINT i;
|
||||||
|
BOOL error;
|
||||||
memchunk=100000;
|
memchunk=100000;
|
||||||
|
|
||||||
SetLastError(NO_ERROR);
|
SetLastError(NO_ERROR);
|
||||||
|
@ -187,10 +189,10 @@ static void test_Global(void)
|
||||||
mem2ptr=GlobalLock(mem2);
|
mem2ptr=GlobalLock(mem2);
|
||||||
ok(mem2ptr==mem2,"GlobalLock should have returned the same memory as was allocated\n");
|
ok(mem2ptr==mem2,"GlobalLock should have returned the same memory as was allocated\n");
|
||||||
if(mem2ptr) {
|
if(mem2ptr) {
|
||||||
error=0;
|
error=FALSE;
|
||||||
for(i=0;i<memchunk;i++) {
|
for(i=0;i<memchunk;i++) {
|
||||||
if(mem2ptr[i]!=0) {
|
if(mem2ptr[i]!=0) {
|
||||||
error=1;
|
error=TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ok(!error,"GlobalAlloc should have zeroed out it's allocated memory\n");
|
ok(!error,"GlobalAlloc should have zeroed out it's allocated memory\n");
|
||||||
|
@ -214,10 +216,10 @@ static void test_Global(void)
|
||||||
mem2ptr=GlobalLock(mem2a);
|
mem2ptr=GlobalLock(mem2a);
|
||||||
ok(mem2ptr!=NULL,"GlobalLock Failed\n");
|
ok(mem2ptr!=NULL,"GlobalLock Failed\n");
|
||||||
if(mem2ptr) {
|
if(mem2ptr) {
|
||||||
error=0;
|
error=FALSE;
|
||||||
for(i=0;i<memchunk;i++) {
|
for(i=0;i<memchunk;i++) {
|
||||||
if(mem2ptr[memchunk+i]!=0) {
|
if(mem2ptr[memchunk+i]!=0) {
|
||||||
error=1;
|
error=TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ok(!error,"GlobalReAlloc should have zeroed out it's allocated memory\n");
|
ok(!error,"GlobalReAlloc should have zeroed out it's allocated memory\n");
|
||||||
|
@ -260,7 +262,8 @@ static void test_Local(void)
|
||||||
ULONG memchunk;
|
ULONG memchunk;
|
||||||
HLOCAL mem1,mem2,mem2a,mem2b;
|
HLOCAL mem1,mem2,mem2a,mem2b;
|
||||||
UCHAR *mem2ptr;
|
UCHAR *mem2ptr;
|
||||||
UINT error,i;
|
UINT i;
|
||||||
|
BOOL error;
|
||||||
memchunk=100000;
|
memchunk=100000;
|
||||||
|
|
||||||
/* Check that a normal alloc works */
|
/* Check that a normal alloc works */
|
||||||
|
@ -278,16 +281,16 @@ static void test_Local(void)
|
||||||
mem2ptr=LocalLock(mem2);
|
mem2ptr=LocalLock(mem2);
|
||||||
ok(mem2ptr!=NULL,"LocalLock: error=%d\n",GetLastError());
|
ok(mem2ptr!=NULL,"LocalLock: error=%d\n",GetLastError());
|
||||||
if(mem2ptr) {
|
if(mem2ptr) {
|
||||||
error=0;
|
error=FALSE;
|
||||||
for(i=0;i<memchunk;i++) {
|
for(i=0;i<memchunk;i++) {
|
||||||
if(mem2ptr[i]!=0) {
|
if(mem2ptr[i]!=0) {
|
||||||
error=1;
|
error=TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ok(!error,"LocalAlloc should have zeroed out it's allocated memory\n");
|
ok(!error,"LocalAlloc should have zeroed out it's allocated memory\n");
|
||||||
SetLastError(0);
|
SetLastError(0);
|
||||||
error=LocalUnlock(mem2);
|
error=LocalUnlock(mem2);
|
||||||
ok(error==0 && GetLastError()==NO_ERROR,
|
ok(!error && GetLastError()==NO_ERROR,
|
||||||
"LocalUnlock Failed: rc=%d err=%d\n",error,GetLastError());
|
"LocalUnlock Failed: rc=%d err=%d\n",error,GetLastError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,10 +309,10 @@ static void test_Local(void)
|
||||||
mem2ptr=LocalLock(mem2a);
|
mem2ptr=LocalLock(mem2a);
|
||||||
ok(mem2ptr!=NULL,"LocalLock Failed\n");
|
ok(mem2ptr!=NULL,"LocalLock Failed\n");
|
||||||
if(mem2ptr) {
|
if(mem2ptr) {
|
||||||
error=0;
|
error=FALSE;
|
||||||
for(i=0;i<memchunk;i++) {
|
for(i=0;i<memchunk;i++) {
|
||||||
if(mem2ptr[memchunk+i]!=0) {
|
if(mem2ptr[memchunk+i]!=0) {
|
||||||
error=1;
|
error=TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ok(!error,"LocalReAlloc should have zeroed out it's allocated memory\n");
|
ok(!error,"LocalReAlloc should have zeroed out it's allocated memory\n");
|
||||||
|
@ -356,7 +359,8 @@ static void test_Virtual(void)
|
||||||
SYSTEM_INFO sysInfo;
|
SYSTEM_INFO sysInfo;
|
||||||
ULONG memchunk;
|
ULONG memchunk;
|
||||||
UCHAR *mem1;
|
UCHAR *mem1;
|
||||||
UINT error,i;
|
UINT i;
|
||||||
|
BOOL error;
|
||||||
|
|
||||||
/* Retrieve the page size for this system */
|
/* Retrieve the page size for this system */
|
||||||
sysInfo.dwPageSize=0;
|
sysInfo.dwPageSize=0;
|
||||||
|
@ -371,19 +375,19 @@ static void test_Virtual(void)
|
||||||
ok(mem1!=NULL,"VirtualAlloc failed\n");
|
ok(mem1!=NULL,"VirtualAlloc failed\n");
|
||||||
if(mem1) {
|
if(mem1) {
|
||||||
/* check that memory is initialized to 0 */
|
/* check that memory is initialized to 0 */
|
||||||
error=0;
|
error=FALSE;
|
||||||
for(i=0;i<memchunk;i++) {
|
for(i=0;i<memchunk;i++) {
|
||||||
if(mem1[i]!=0) {
|
if(mem1[i]!=0) {
|
||||||
error=1;
|
error=TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ok(!error,"VirtualAlloc did not initialize memory to '0's\n");
|
ok(!error,"VirtualAlloc did not initialize memory to '0's\n");
|
||||||
/* Check that we can read/write to memory */
|
/* Check that we can read/write to memory */
|
||||||
error=0;
|
error=FALSE;
|
||||||
for(i=0;i<memchunk;i+=100) {
|
for(i=0;i<memchunk;i+=100) {
|
||||||
mem1[i]='a';
|
mem1[i]='a';
|
||||||
if(mem1[i]!='a') {
|
if(mem1[i]!='a') {
|
||||||
error=1;
|
error=TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ok(!error,"Virtual memory was not writable\n");
|
ok(!error,"Virtual memory was not writable\n");
|
||||||
|
|
|
@ -2147,7 +2147,7 @@ static unsigned int map_file_access( unsigned int access )
|
||||||
return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
|
return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_sharing_compatible( DWORD access1, DWORD sharing1, DWORD access2, DWORD sharing2 )
|
static BOOL is_sharing_compatible( DWORD access1, DWORD sharing1, DWORD access2, DWORD sharing2 )
|
||||||
{
|
{
|
||||||
access1 = map_file_access( access1 );
|
access1 = map_file_access( access1 );
|
||||||
access2 = map_file_access( access2 );
|
access2 = map_file_access( access2 );
|
||||||
|
@ -2157,22 +2157,22 @@ static int is_sharing_compatible( DWORD access1, DWORD sharing1, DWORD access2,
|
||||||
if (!access1) sharing1 = FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE;
|
if (!access1) sharing1 = FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE;
|
||||||
if (!access2) sharing2 = FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE;
|
if (!access2) sharing2 = FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE;
|
||||||
|
|
||||||
if ((access1 & (FILE_READ_DATA|FILE_EXECUTE)) && !(sharing2 & FILE_SHARE_READ)) return 0;
|
if ((access1 & (FILE_READ_DATA|FILE_EXECUTE)) && !(sharing2 & FILE_SHARE_READ)) return FALSE;
|
||||||
if ((access1 & (FILE_WRITE_DATA|FILE_APPEND_DATA)) && !(sharing2 & FILE_SHARE_WRITE)) return 0;
|
if ((access1 & (FILE_WRITE_DATA|FILE_APPEND_DATA)) && !(sharing2 & FILE_SHARE_WRITE)) return FALSE;
|
||||||
if ((access1 & DELETE) && !(sharing2 & FILE_SHARE_DELETE)) return 0;
|
if ((access1 & DELETE) && !(sharing2 & FILE_SHARE_DELETE)) return FALSE;
|
||||||
if ((access2 & (FILE_READ_DATA|FILE_EXECUTE)) && !(sharing1 & FILE_SHARE_READ)) return 0;
|
if ((access2 & (FILE_READ_DATA|FILE_EXECUTE)) && !(sharing1 & FILE_SHARE_READ)) return FALSE;
|
||||||
if ((access2 & (FILE_WRITE_DATA|FILE_APPEND_DATA)) && !(sharing1 & FILE_SHARE_WRITE)) return 0;
|
if ((access2 & (FILE_WRITE_DATA|FILE_APPEND_DATA)) && !(sharing1 & FILE_SHARE_WRITE)) return FALSE;
|
||||||
if ((access2 & DELETE) && !(sharing1 & FILE_SHARE_DELETE)) return 0;
|
if ((access2 & DELETE) && !(sharing1 & FILE_SHARE_DELETE)) return FALSE;
|
||||||
return 1;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_sharing_map_compatible( DWORD map_access, DWORD access2, DWORD sharing2 )
|
static BOOL is_sharing_map_compatible( DWORD map_access, DWORD access2, DWORD sharing2 )
|
||||||
{
|
{
|
||||||
if ((map_access == PAGE_READWRITE || map_access == PAGE_EXECUTE_READWRITE) &&
|
if ((map_access == PAGE_READWRITE || map_access == PAGE_EXECUTE_READWRITE) &&
|
||||||
!(sharing2 & FILE_SHARE_WRITE)) return 0;
|
!(sharing2 & FILE_SHARE_WRITE)) return FALSE;
|
||||||
access2 = map_file_access( access2 );
|
access2 = map_file_access( access2 );
|
||||||
if ((map_access & SEC_IMAGE) && (access2 & FILE_WRITE_DATA)) return 0;
|
if ((map_access & SEC_IMAGE) && (access2 & FILE_WRITE_DATA)) return FALSE;
|
||||||
return 1;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_file_sharing(void)
|
static void test_file_sharing(void)
|
||||||
|
|
|
@ -61,7 +61,7 @@ static inline WCHAR *strchrW( const WCHAR *str, WCHAR ch )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int isdigitW( WCHAR wc )
|
static inline BOOL isdigitW( WCHAR wc )
|
||||||
{
|
{
|
||||||
WORD type;
|
WORD type;
|
||||||
GetStringTypeW( CT_CTYPE1, &wc, 1, &type );
|
GetStringTypeW( CT_CTYPE1, &wc, 1, &type );
|
||||||
|
|
|
@ -198,21 +198,22 @@ static void test_ValidPathA(const CHAR *curdir, const CHAR *subdir, const CHAR *
|
||||||
|
|
||||||
/* split path into leading directory, and 8.3 filename */
|
/* split path into leading directory, and 8.3 filename */
|
||||||
static void test_SplitShortPathA(CHAR *path,CHAR *dir,CHAR *eight,CHAR *three) {
|
static void test_SplitShortPathA(CHAR *path,CHAR *dir,CHAR *eight,CHAR *three) {
|
||||||
int done,error;
|
BOOL done = FALSE, error = FALSE;
|
||||||
int ext,fil;
|
int ext,fil;
|
||||||
int len,i;
|
int len,i;
|
||||||
len=lstrlenA(path);
|
len=lstrlenA(path);
|
||||||
ext=len; fil=len; done=0; error=0;
|
ext=len;
|
||||||
|
fil=len;
|
||||||
/* walk backwards over path looking for '.' or '\\' separators */
|
/* walk backwards over path looking for '.' or '\\' separators */
|
||||||
for(i=len-1;(i>=0) && (!done);i--) {
|
for(i=len-1;(i>=0) && (!done);i--) {
|
||||||
if(path[i]=='.')
|
if(path[i]=='.')
|
||||||
if(ext!=len) error=1; else ext=i;
|
if(ext!=len) error=TRUE; else ext=i;
|
||||||
else if(path[i]=='\\') {
|
else if(path[i]=='\\') {
|
||||||
if(i==len-1) {
|
if(i==len-1) {
|
||||||
error=1;
|
error=TRUE;
|
||||||
} else {
|
} else {
|
||||||
fil=i;
|
fil=i;
|
||||||
done=1;
|
done=TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,12 +183,12 @@ static WCHAR* decodeW(const char* str)
|
||||||
* exename: executable without the path
|
* exename: executable without the path
|
||||||
* function-pointers, which are not implemented in all windows versions
|
* function-pointers, which are not implemented in all windows versions
|
||||||
*/
|
*/
|
||||||
static int init(void)
|
static BOOL init(void)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
myARGC = winetest_get_mainargs( &myARGV );
|
myARGC = winetest_get_mainargs( &myARGV );
|
||||||
if (!GetCurrentDirectoryA(sizeof(base), base)) return 0;
|
if (!GetCurrentDirectoryA(sizeof(base), base)) return FALSE;
|
||||||
strcpy(selfname, myARGV[0]);
|
strcpy(selfname, myARGV[0]);
|
||||||
|
|
||||||
/* Strip the path of selfname */
|
/* Strip the path of selfname */
|
||||||
|
@ -206,7 +206,7 @@ static int init(void)
|
||||||
pQueryFullProcessImageNameA = (void *) GetProcAddress(hkernel32, "QueryFullProcessImageNameA");
|
pQueryFullProcessImageNameA = (void *) GetProcAddress(hkernel32, "QueryFullProcessImageNameA");
|
||||||
pQueryFullProcessImageNameW = (void *) GetProcAddress(hkernel32, "QueryFullProcessImageNameW");
|
pQueryFullProcessImageNameW = (void *) GetProcAddress(hkernel32, "QueryFullProcessImageNameW");
|
||||||
pK32GetProcessImageFileNameA = (void *) GetProcAddress(hkernel32, "K32GetProcessImageFileNameA");
|
pK32GetProcessImageFileNameA = (void *) GetProcAddress(hkernel32, "K32GetProcessImageFileNameA");
|
||||||
return 1;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
|
@ -2062,7 +2062,7 @@ static void test_DuplicateHandle(void)
|
||||||
|
|
||||||
START_TEST(process)
|
START_TEST(process)
|
||||||
{
|
{
|
||||||
int b = init();
|
BOOL b = init();
|
||||||
ok(b, "Basic init of CreateProcess test\n");
|
ok(b, "Basic init of CreateProcess test\n");
|
||||||
if (!b) return;
|
if (!b) return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue