Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
5d5fd2fa
Commit
5d5fd2fa
authored
Nov 08, 2011
by
Thomas Faber
Committed by
Alexandre Julliard
Nov 09, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add tests for GetDllDirectory.
parent
5e1599d8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
117 additions
and
0 deletions
+117
-0
module.c
dlls/kernel32/tests/module.c
+117
-0
No files found.
dlls/kernel32/tests/module.c
View file @
5d5fd2fa
...
...
@@ -21,6 +21,11 @@
#include "wine/test.h"
#include <windows.h>
static
DWORD
(
WINAPI
*
pGetDllDirectoryA
)(
DWORD
,
LPSTR
);
static
DWORD
(
WINAPI
*
pGetDllDirectoryW
)(
DWORD
,
LPWSTR
);
static
BOOL
(
WINAPI
*
pSetDllDirectoryA
)(
LPCSTR
);
static
BOOL
is_unicode_enabled
=
TRUE
;
static
BOOL
cmpStrAW
(
const
char
*
a
,
const
WCHAR
*
b
,
DWORD
lenA
,
DWORD
lenB
)
...
...
@@ -386,6 +391,114 @@ static void testLoadLibraryEx(void)
}
static
void
testGetDllDirectory
(
void
)
{
CHAR
bufferA
[
MAX_PATH
];
WCHAR
bufferW
[
MAX_PATH
];
size_t
length
;
DWORD
ret
;
int
i
;
static
const
char
*
dll_directories
[]
=
{
""
,
"C:
\\
Some
\\
Path"
,
"C:
\\
Some
\\
Path
\\
"
,
"Q:
\\
A
\\
Long
\\
Path with spaces that
\\
probably
\\
doesn't exist!"
,
};
const
int
test_count
=
sizeof
(
dll_directories
)
/
sizeof
(
dll_directories
[
0
]);
if
(
!
pGetDllDirectoryA
||
!
pGetDllDirectoryW
)
{
win_skip
(
"GetDllDirectory not available
\n
"
);
return
;
}
if
(
!
pSetDllDirectoryA
)
{
win_skip
(
"SetDllDirectoryA not available
\n
"
);
return
;
}
for
(
i
=
0
;
i
<
test_count
;
i
++
)
{
length
=
strlen
(
dll_directories
[
i
]);
if
(
!
pSetDllDirectoryA
(
dll_directories
[
i
]))
{
skip
(
"i=%d, SetDllDirectoryA failed
\n
"
,
i
);
continue
;
}
/* no buffer, determine length */
ret
=
pGetDllDirectoryA
(
0
,
NULL
);
ok
(
ret
==
length
+
1
,
"Expected %u, got %u
\n
"
,
length
+
1
,
ret
);
ret
=
pGetDllDirectoryW
(
0
,
NULL
);
ok
(
ret
==
length
+
1
,
"Expected %u, got %u
\n
"
,
length
+
1
,
ret
);
/* buffer of exactly the right size */
bufferA
[
length
]
=
'A'
;
bufferA
[
length
+
1
]
=
'A'
;
ret
=
pGetDllDirectoryA
(
length
+
1
,
bufferA
);
ok
(
ret
==
length
,
"i=%d, Expected %u, got %u
\n
"
,
i
,
length
,
ret
);
ok
(
bufferA
[
length
+
1
]
==
'A'
,
"i=%d, Buffer overflow
\n
"
,
i
);
ok
(
strcmp
(
bufferA
,
dll_directories
[
i
])
==
0
,
"i=%d, Wrong path returned: '%s'
\n
"
,
i
,
bufferA
);
bufferW
[
length
]
=
'A'
;
bufferW
[
length
+
1
]
=
'A'
;
ret
=
pGetDllDirectoryW
(
length
+
1
,
bufferW
);
ok
(
ret
==
length
,
"i=%d, Expected %u, got %u
\n
"
,
i
,
length
,
ret
);
ok
(
bufferW
[
length
+
1
]
==
'A'
,
"i=%d, Buffer overflow
\n
"
,
i
);
ok
(
cmpStrAW
(
dll_directories
[
i
],
bufferW
,
length
,
length
),
"i=%d, Wrong path returned: %s
\n
"
,
i
,
wine_dbgstr_w
(
bufferW
));
/* zero size buffer
* the A version always null-terminates the buffer,
* the W version doesn't do it on some platforms */
bufferA
[
0
]
=
'A'
;
ret
=
pGetDllDirectoryA
(
0
,
bufferA
);
ok
(
ret
==
length
+
1
,
"i=%d, Expected %u, got %u
\n
"
,
i
,
length
+
1
,
ret
);
ok
(
bufferA
[
0
]
==
0
,
"i=%d, Buffer not null terminated
\n
"
,
i
);
bufferW
[
0
]
=
'A'
;
ret
=
pGetDllDirectoryW
(
0
,
bufferW
);
ok
(
ret
==
length
+
1
,
"i=%d, Expected %u, got %u
\n
"
,
i
,
length
+
1
,
ret
);
ok
(
bufferW
[
0
]
==
0
||
/* XP, 2003 */
broken
(
bufferW
[
0
]
==
'A'
),
"i=%d, Buffer overflow
\n
"
,
i
);
/* buffer just one too short */
bufferA
[
0
]
=
'A'
;
ret
=
pGetDllDirectoryA
(
length
,
bufferA
);
ok
(
ret
==
length
+
1
,
"i=%d, Expected %u, got %u
\n
"
,
i
,
length
+
1
,
ret
);
ok
(
bufferA
[
0
]
==
0
,
"i=%d, Buffer not null terminated
\n
"
,
i
);
bufferW
[
0
]
=
'A'
;
ret
=
pGetDllDirectoryW
(
length
,
bufferW
);
ok
(
ret
==
length
+
1
,
"i=%d, Expected %u, got %u
\n
"
,
i
,
length
+
1
,
ret
);
ok
(
bufferW
[
0
]
==
0
||
/* XP, 2003 */
broken
(
bufferW
[
0
]
==
'A'
),
"i=%d, Buffer overflow
\n
"
,
i
);
/* no buffer, but too short length */
ret
=
pGetDllDirectoryA
(
length
,
NULL
);
ok
(
ret
==
length
+
1
,
"i=%d, Expected %u, got %u
\n
"
,
i
,
length
+
1
,
ret
);
ret
=
pGetDllDirectoryW
(
length
,
NULL
);
ok
(
ret
==
length
+
1
,
"i=%d, Expected %u, got %u
\n
"
,
i
,
length
+
1
,
ret
);
}
/* unset whatever we did so following tests won't be affected */
pSetDllDirectoryA
(
NULL
);
}
static
void
init_pointers
(
void
)
{
HMODULE
hKernel32
=
GetModuleHandleA
(
"kernel32.dll"
);
#define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hKernel32, #f))
MAKEFUNC
(
GetDllDirectoryA
);
MAKEFUNC
(
GetDllDirectoryW
);
MAKEFUNC
(
SetDllDirectoryA
);
#undef MAKEFUNC
}
START_TEST
(
module
)
{
WCHAR
filenameW
[
MAX_PATH
];
...
...
@@ -400,10 +513,14 @@ START_TEST(module)
is_unicode_enabled
=
FALSE
;
}
init_pointers
();
testGetModuleFileName
(
NULL
);
testGetModuleFileName
(
"kernel32.dll"
);
testGetModuleFileName_Wrong
();
testGetDllDirectory
();
testLoadLibraryA
();
testNestedLoadLibraryA
();
testLoadLibraryA_Wrong
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment