Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexey Alyaev
wine
Commits
7b416af6
Commit
7b416af6
authored
19 years ago
by
Paul Vriens
Committed by
Alexandre Julliard
19 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix some tests for win9x and winME.
parent
00f80c60
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/kernel/tests/module.c
+54
-18
54 additions, 18 deletions
dlls/kernel/tests/module.c
with
54 additions
and
18 deletions
dlls/kernel/tests/module.c
+
54
−
18
View file @
7b416af6
...
...
@@ -21,6 +21,8 @@
#include
"wine/test.h"
#include
<windows.h>
static
BOOL
is_unicode_enabled
=
TRUE
;
static
BOOL
cmpStrAW
(
const
char
*
a
,
const
WCHAR
*
b
,
DWORD
lenA
,
DWORD
lenB
)
{
WCHAR
aw
[
1024
];
...
...
@@ -36,7 +38,7 @@ static void testGetModuleFileName(const char* name)
HMODULE
hMod
;
char
bufA
[
MAX_PATH
];
WCHAR
bufW
[
MAX_PATH
];
DWORD
len1A
,
len1W
,
len2A
,
len2W
;
DWORD
len1A
,
len1W
=
0
,
len2A
,
len2W
=
0
;
hMod
=
(
name
)
?
GetModuleHandle
(
name
)
:
NULL
;
...
...
@@ -44,23 +46,37 @@ static void testGetModuleFileName(const char* name)
memset
(
bufA
,
'-'
,
sizeof
(
bufA
));
len1A
=
GetModuleFileNameA
(
hMod
,
bufA
,
sizeof
(
bufA
));
ok
(
len1A
>
0
,
"Getting module filename for handle %p
\n
"
,
hMod
);
memset
(
bufW
,
'-'
,
sizeof
(
bufW
));
len1W
=
GetModuleFileNameW
(
hMod
,
bufW
,
sizeof
(
bufW
)
/
sizeof
(
WCHAR
));
ok
(
len1W
>
0
,
"Getting module filename for handle %p
\n
"
,
hMod
);
if
(
is_unicode_enabled
)
{
memset
(
bufW
,
'-'
,
sizeof
(
bufW
));
len1W
=
GetModuleFileNameW
(
hMod
,
bufW
,
sizeof
(
bufW
)
/
sizeof
(
WCHAR
));
ok
(
len1W
>
0
,
"Getting module filename for handle %p
\n
"
,
hMod
);
}
ok
(
len1A
==
strlen
(
bufA
),
"Unexpected length of GetModuleFilenameA (%ld/%d)
\n
"
,
len1A
,
strlen
(
bufA
));
ok
(
len1W
==
lstrlenW
(
bufW
),
"Unexpected length of GetModuleFilenameW (%ld/%d)
\n
"
,
len1W
,
lstrlenW
(
bufW
));
ok
(
cmpStrAW
(
bufA
,
bufW
,
len1A
,
len1W
),
"Comparing GetModuleFilenameAW results
\n
"
);
if
(
is_unicode_enabled
)
{
ok
(
len1W
==
lstrlenW
(
bufW
),
"Unexpected length of GetModuleFilenameW (%ld/%d)
\n
"
,
len1W
,
lstrlenW
(
bufW
));
ok
(
cmpStrAW
(
bufA
,
bufW
,
len1A
,
len1W
),
"Comparing GetModuleFilenameAW results
\n
"
);
}
/* second test with a buffer too small */
memset
(
bufA
,
'-'
,
sizeof
(
bufA
));
len2A
=
GetModuleFileNameA
(
hMod
,
bufA
,
len1A
/
2
);
ok
(
len2A
>
0
,
"Getting module filename for handle %p
\n
"
,
hMod
);
memset
(
bufW
,
'-'
,
sizeof
(
bufW
));
len2W
=
GetModuleFileNameW
(
hMod
,
bufW
,
len1W
/
2
);
ok
(
len2W
>
0
,
"Getting module filename for handle %p
\n
"
,
hMod
);
ok
(
cmpStrAW
(
bufA
,
bufW
,
len2A
,
len2W
),
"Comparing GetModuleFilenameAW results with buffer too small
\n
"
);
if
(
is_unicode_enabled
)
{
memset
(
bufW
,
'-'
,
sizeof
(
bufW
));
len2W
=
GetModuleFileNameW
(
hMod
,
bufW
,
len1W
/
2
);
ok
(
len2W
>
0
,
"Getting module filename for handle %p
\n
"
,
hMod
);
ok
(
cmpStrAW
(
bufA
,
bufW
,
len2A
,
len2W
),
"Comparing GetModuleFilenameAW results with buffer too small
\n
"
);
ok
(
len1W
/
2
==
len2W
,
"Correct length in GetModuleFilenameW with buffer too small (%ld/%ld)
\n
"
,
len1W
/
2
,
len2W
);
}
ok
(
len1A
/
2
==
len2A
,
"Correct length in GetModuleFilenameA with buffer too small (%ld/%ld)
\n
"
,
len1A
/
2
,
len2A
);
ok
(
len1W
/
2
==
len2W
,
"Correct length in GetModuleFilenameW with buffer too small (%ld/%ld)
\n
"
,
len1W
/
2
,
len2W
);
}
static
void
testGetModuleFileName_Wrong
(
void
)
...
...
@@ -69,9 +85,12 @@ static void testGetModuleFileName_Wrong(void)
WCHAR
bufW
[
MAX_PATH
];
/* test wrong handle */
bufW
[
0
]
=
'*'
;
ok
(
GetModuleFileNameW
((
void
*
)
0xffffffff
,
bufW
,
sizeof
(
bufW
)
/
sizeof
(
WCHAR
))
==
0
,
"Unexpected success in module handle
\n
"
);
ok
(
bufW
[
0
]
==
'*'
,
"When failing, buffer shouldn't be written to
\n
"
);
if
(
is_unicode_enabled
)
{
bufW
[
0
]
=
'*'
;
ok
(
GetModuleFileNameW
((
void
*
)
0xffffffff
,
bufW
,
sizeof
(
bufW
)
/
sizeof
(
WCHAR
))
==
0
,
"Unexpected success in module handle
\n
"
);
ok
(
bufW
[
0
]
==
'*'
,
"When failing, buffer shouldn't be written to
\n
"
);
}
bufA
[
0
]
=
'*'
;
ok
(
GetModuleFileNameA
((
void
*
)
0xffffffff
,
bufA
,
sizeof
(
bufA
))
==
0
,
"Unexpected success in module handle
\n
"
);
...
...
@@ -88,7 +107,7 @@ static void testLoadLibraryA(void)
ok
(
hModule
!=
NULL
,
"ntdll.dll should be loadable
\n
"
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"GetLastError should be 0xdeadbeef but is %08lx
\n
"
,
GetLastError
());
fp
=
GetProcAddress
(
hModule
,
"
LdrLoadDll
"
);
fp
=
GetProcAddress
(
hModule
,
"
NtCreateFile
"
);
ok
(
fp
!=
NULL
,
"Call should be there
\n
"
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"GetLastError should be 0xdeadbeef but is %08lx
\n
"
,
GetLastError
());
...
...
@@ -103,7 +122,8 @@ static void testLoadLibraryA_Wrong(void)
SetLastError
(
0xdeadbeef
);
hModule
=
LoadLibraryA
(
"non_ex_pv.dll"
);
ok
(
!
hModule
,
"non_ex_pv.dll should be not loadable
\n
"
);
ok
(
GetLastError
()
==
ERROR_MOD_NOT_FOUND
,
"Expected ERROR_MOD_NOT_FOUND, got %08lx
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_MOD_NOT_FOUND
||
GetLastError
()
==
ERROR_DLL_NOT_FOUND
,
"Expected ERROR_MOD_NOT_FOUND or ERROR_DLL_NOT_FOUND (win9x), got %08lx
\n
"
,
GetLastError
());
/* Just in case */
FreeLibrary
(
hModule
);
...
...
@@ -116,14 +136,30 @@ static void testGetProcAddress_Wrong(void)
SetLastError
(
0xdeadbeef
);
fp
=
GetProcAddress
(
NULL
,
"non_ex_call"
);
ok
(
!
fp
,
"non_ex_call should not be found
\n
"
);
ok
(
GetLastError
()
==
ERROR_PROC_NOT_FOUND
,
"Expected ERROR_PROC_NOT_FOUND, got %08lx
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_PROC_NOT_FOUND
||
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_PROC_NOT_FOUND or ERROR_INVALID_HANDLE(win9x), got %08lx
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
fp
=
GetProcAddress
((
HMODULE
)
0xdeadbeef
,
"non_ex_call"
);
ok
(
!
fp
,
"non_ex_call should not be found
\n
"
);
ok
(
GetLastError
()
==
ERROR_MOD_NOT_FOUND
,
"Expected ERROR_MOD_NOT_FOUND, got %08lx
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_MOD_NOT_FOUND
||
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_HANDLE(win9x), got %08lx
\n
"
,
GetLastError
());
}
START_TEST
(
module
)
{
WCHAR
filenameW
[
MAX_PATH
];
/* Test if we can use GetModuleFileNameW */
SetLastError
(
0xdeadbeef
);
GetModuleFileNameW
(
NULL
,
filenameW
,
MAX_PATH
);
if
(
GetLastError
()
==
ERROR_CALL_NOT_IMPLEMENTED
)
{
trace
(
"GetModuleFileNameW not existing on this platform, skipping W-calls
\n
"
);
is_unicode_enabled
=
FALSE
;
}
testGetModuleFileName
(
NULL
);
testGetModuleFileName
(
"kernel32.dll"
);
testGetModuleFileName_Wrong
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment