Author: tkreuzer
Date: Thu Feb 20 20:29:51 2014
New Revision: 62269
URL:
http://svn.reactos.org/svn/reactos?rev=62269&view=rev
Log:
[DLLEXPORT_TEST]
Add a test that checks the ability to link to function and data exports with cdecl,
stdcall and c++ mangled names, including forwarders. It just prints "done". Feel
free to convert it into a proper rostests, if you think it's required.
Added:
trunk/rostests/tests/dllexport/ (with props)
trunk/rostests/tests/dllexport/CMakeLists.txt (with props)
trunk/rostests/tests/dllexport/dllexport_test.c (with props)
trunk/rostests/tests/dllexport/dllexport_test_dll1.c (with props)
trunk/rostests/tests/dllexport/dllexport_test_dll1.spec (with props)
trunk/rostests/tests/dllexport/dllexport_test_dll2.c (with props)
trunk/rostests/tests/dllexport/dllexport_test_dll2.spec (with props)
Modified:
trunk/rostests/tests/CMakeLists.txt
Modified: trunk/rostests/tests/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/tests/CMakeLists.txt?rev=…
==============================================================================
--- trunk/rostests/tests/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/tests/CMakeLists.txt [iso-8859-1] Thu Feb 20 20:29:51 2014
@@ -2,3 +2,4 @@
if (NOT MSVC)
add_subdirectory(pseh2)
endif()
+add_subdirectory(dllexport)
Propchange: trunk/rostests/tests/dllexport/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Thu Feb 20 20:29:51 2014
@@ -0,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)
Propchange: trunk/rostests/tests/dllexport/
------------------------------------------------------------------------------
bugtraq:message = See issue #%BUGID% for more details.
Propchange: trunk/rostests/tests/dllexport/
------------------------------------------------------------------------------
bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Added: trunk/rostests/tests/dllexport/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/tests/dllexport/CMakeList…
==============================================================================
--- trunk/rostests/tests/dllexport/CMakeLists.txt (added)
+++ trunk/rostests/tests/dllexport/CMakeLists.txt [iso-8859-1] Thu Feb 20 20:29:51 2014
@@ -0,0 +1,21 @@
+
+spec2def(dllexport_test_dll1.dll dllexport_test_dll1.spec ADD_IMPORTLIB)
+spec2def(dllexport_test_dll2.dll dllexport_test_dll2.spec ADD_IMPORTLIB)
+
+add_library(dllexport_test_dll1 SHARED
+ dllexport_test_dll1.c
+ ${CMAKE_CURRENT_BINARY_DIR}/dllexport_test_dll1.def)
+set_module_type(dllexport_test_dll1 win32dll ENTRYPOINT 0)
+add_importlibs(dllexport_test_dll1 dllexport_test_dll2)
+
+add_library(dllexport_test_dll2 SHARED
+ dllexport_test_dll2.c
+ ${CMAKE_CURRENT_BINARY_DIR}/dllexport_test_dll2.def)
+set_module_type(dllexport_test_dll2 win32dll ENTRYPOINT 0)
+
+
+add_executable(dllexport_test
+ dllexport_test.c)
+
+set_module_type(dllexport_test win32cui)
+add_importlibs(dllexport_test dllexport_test_dll1 msvcrt kernel32 ntdll)
Propchange: trunk/rostests/tests/dllexport/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/tests/dllexport/dllexport_test.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/tests/dllexport/dllexport…
==============================================================================
--- trunk/rostests/tests/dllexport/dllexport_test.c (added)
+++ trunk/rostests/tests/dllexport/dllexport_test.c [iso-8859-1] Thu Feb 20 20:29:51 2014
@@ -0,0 +1,89 @@
+
+#include <stdio.h>
+
+#ifdef __GNUC__
+#endif
+
+__declspec(dllimport) int __cdecl CdeclFunc0(void);
+__declspec(dllimport) int __cdecl CdeclFunc1(char* a1);
+__declspec(dllimport) int __cdecl CdeclFunc2(char* a1);
+__declspec(dllimport) int __cdecl CdeclFunc3(char* a1);
+
+__declspec(dllimport) int __stdcall StdcallFunc0(void);
+__declspec(dllimport) int __stdcall StdcallFunc1(char* a1);
+__declspec(dllimport) int __stdcall StdcallFunc2(char* a1);
+__declspec(dllimport) int __stdcall StdcallFunc3(char* a1);
+__declspec(dllimport) int __stdcall StdcallFunc4(char* a1);
+__declspec(dllimport) int __stdcall StdcallFunc5(char* a1);
+
+__declspec(dllimport) int __stdcall DecoratedStdcallFunc1(char* a1);
+__declspec(dllimport) int __stdcall DecoratedStdcallFunc2(char* a1);
+__declspec(dllimport) int __stdcall DecoratedStdcallFunc3(char* a1);
+__declspec(dllimport) int __stdcall DecoratedStdcallFunc4(char* a1);
+__declspec(dllimport) int __stdcall DecoratedStdcallFunc5(char* a1);
+
+__declspec(dllimport) int __fastcall FastcallFunc0(void);
+__declspec(dllimport) int __fastcall FastcallFunc1(char* a1);
+__declspec(dllimport) int __fastcall FastcallFunc2(char* a1);
+__declspec(dllimport) int __fastcall FastcallFunc3(char* a1);
+__declspec(dllimport) int __fastcall FastcallFunc4(char* a1);
+__declspec(dllimport) int __fastcall FastcallFunc5(char* a1);
+
+__declspec(dllimport) int __fastcall DecoratedFastcallFunc1(char* a1);
+__declspec(dllimport) int __fastcall DecoratedFastcallFunc2(char* a1);
+__declspec(dllimport) int __fastcall DecoratedFastcallFunc3(char* a1);
+__declspec(dllimport) int __fastcall DecoratedFastcallFunc4(char* a1);
+__declspec(dllimport) int __fastcall DecoratedFastcallFunc5(char* a1);
+
+__declspec(dllimport) extern int DataItem1;
+__declspec(dllimport) extern int DataItem2;
+__declspec(dllimport) extern int DataItem3;
+
+#define ok_int(a, b) \
+ if ((a) != (b)) { printf("wrong result in line %d, expected 0x%x, got
0x%x\n", __LINE__, (b), (a)); }
+
+int main(int argc, char *argv[])
+{
+ char* str = "defaultstring";
+
+ if (argc > 2)
+ str = argv[1];
+
+ ok_int(CdeclFunc0(), 0);
+ ok_int(CdeclFunc1(str), 1);
+ ok_int(CdeclFunc2(str), 1);
+ ok_int(CdeclFunc3(str), 0x10001);
+
+ ok_int(StdcallFunc0(), 0x10);
+ ok_int(StdcallFunc1(str), 0x11);
+ ok_int(StdcallFunc2(str), 0x11);
+ ok_int(StdcallFunc3(str), 0x10011);
+ ok_int(StdcallFunc4(str), 0x21);
+ ok_int(StdcallFunc5(str), 0x10021);
+
+ ok_int(DecoratedStdcallFunc1(str), 0x21);
+ ok_int(DecoratedStdcallFunc2(str), 0x11);
+ //ok_int(DecoratedStdcallFunc3(str), 11);
+ ok_int(DecoratedStdcallFunc4(str), 0x21);
+ ok_int(DecoratedStdcallFunc5(str), 0x10021);
+
+ ok_int(FastcallFunc0(), 0x30);
+ ok_int(FastcallFunc1(str), 0x31);
+ ok_int(FastcallFunc2(str), 0x31);
+ ok_int(FastcallFunc3(str), 0x10031);
+ ok_int(FastcallFunc4(str), 0x42);
+ ok_int(FastcallFunc5(str), 0x10041);
+ ok_int(DecoratedFastcallFunc1(str), 0x42);
+ ok_int(DecoratedFastcallFunc2(str), 0x31);
+ //ok_int(DecoratedFastcallFunc3(str), 11);
+ ok_int(DecoratedFastcallFunc4(str), 0x42);
+ ok_int(DecoratedFastcallFunc5(str), 0x10041);
+
+ ok_int(DataItem1, 0x51);
+ ok_int(DataItem2, 0x51);
+ ok_int(DataItem3, 0x10051);
+
+ printf("done.\n");
+
+ return 0;
+}
Propchange: trunk/rostests/tests/dllexport/dllexport_test.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/tests/dllexport/dllexport_test_dll1.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/tests/dllexport/dllexport…
==============================================================================
--- trunk/rostests/tests/dllexport/dllexport_test_dll1.c (added)
+++ trunk/rostests/tests/dllexport/dllexport_test_dll1.c [iso-8859-1] Thu Feb 20 20:29:51
2014
@@ -0,0 +1,49 @@
+
+int __cdecl CdeclFunc0(void)
+{
+ return 0x0;
+}
+
+int __cdecl CdeclFunc1(char *p1)
+{
+ return 0x1;
+}
+
+int __stdcall StdcallFunc0(void)
+{
+ return 0x10;
+}
+
+int __stdcall StdcallFunc1(char *p1)
+{
+ return 0x11;
+}
+
+int __stdcall DecoratedStdcallFunc1(char *p1)
+{
+ return 0x21;
+}
+
+int __fastcall FastcallFunc0(void)
+{
+ return 0x30;
+}
+
+int __fastcall FastcallFunc1(char *p1)
+{
+ return 0x31;
+}
+
+int __fastcall DecoratedFastcallFunc1(char *p1)
+{
+ return 0x42;
+}
+
+int __stdcall ExportByOrdinal1(char *p1)
+{
+ return 0x11;
+}
+
+int DataItem1 = 0x51;
+int DataItem2 = 0x52;
+
Propchange: trunk/rostests/tests/dllexport/dllexport_test_dll1.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/tests/dllexport/dllexport_test_dll1.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/tests/dllexport/dllexport…
==============================================================================
--- trunk/rostests/tests/dllexport/dllexport_test_dll1.spec (added)
+++ trunk/rostests/tests/dllexport/dllexport_test_dll1.spec [iso-8859-1] Thu Feb 20
20:29:51 2014
@@ -0,0 +1,55 @@
+
+# Normal export of a cdecl function
+ @ cdecl CdeclFunc0()
+ @ cdecl CdeclFunc1(ptr)
+
+# Redirected cdecl function
+ @ cdecl CdeclFunc2() CdeclFunc1
+ @ cdecl CdeclFunc3() dllexport_test_dll2.CdeclFunc1
+
+# Normal export of a stdcall function
+ @ stdcall StdcallFunc0()
+ @ stdcall StdcallFunc1(ptr)
+
+# Decorated export of a stdcall function
+ @ stdcall _StdcallFunc1@4(ptr)
+ @ stdcall _DecoratedStdcallFunc1@4(ptr)
+
+# Redirected stdcall function
+ @ stdcall StdcallFunc2(ptr) StdcallFunc1
+ @ stdcall StdcallFunc3(ptr) dllexport_test_dll2.StdcallFunc1
+ @ stdcall StdcallFunc4(ptr) _DecoratedStdcallFunc1@4
+ @ stdcall StdcallFunc5(ptr) dllexport_test_dll2._DecoratedStdcallFunc1@4
+ @ stdcall _DecoratedStdcallFunc2@4(ptr) StdcallFunc1
+; @ stdcall _DecoratedStdcallFunc3@4(ptr) dllexport_test_dll2.StdcallFunc1 # This
doesn't work with MSVC!
+ @ stdcall _DecoratedStdcallFunc4@4(ptr) _DecoratedStdcallFunc1@4
+ @ stdcall _DecoratedStdcallFunc5@4(ptr) dllexport_test_dll2._DecoratedStdcallFunc1@4
+
+# Normal export of a fastcall function
+ @ fastcall FastcallFunc0()
+ @ fastcall FastcallFunc1(ptr)
+
+# Decorated export of a fastcall function
+ @ fastcall @DecoratedFastcallFunc1@4(ptr)
+
+# Redirected fastcall function
+ @ fastcall FastcallFunc2(ptr) FastcallFunc1
+ @ fastcall FastcallFunc3(ptr) dllexport_test_dll2.FastcallFunc1
+ @ fastcall FastcallFunc4(ptr) @DecoratedFastcallFunc1@4
+ @ fastcall FastcallFunc5(ptr) dllexport_test_dll2.@DecoratedFastcallFunc1@4
+
+ @ fastcall @DecoratedFastcallFunc2@4(ptr) FastcallFunc1
+; @ fastcall @DecoratedFastcallFunc3@4(ptr) dllexport_test_dll2.FastcallFunc1 # This
doesn't work with MSVC!
+ @ fastcall @DecoratedFastcallFunc4@4(ptr) @DecoratedFastcallFunc1@4
+ @ fastcall @DecoratedFastcallFunc5@4(ptr) dllexport_test_dll2.@DecoratedFastcallFunc1@4
+
+# Normal export of data
+ @ extern DataItem1
+
+# Redirected data
+ @ extern DataItem2 DataItem1
+ @ extern DataItem3 dllexport_test_dll2.DataItem1
+
+# other stuff
+ 123 stdcall @(ptr) ExportByOrdinal1
+ 218 stdcall -noname ExportByOrdinal1(ptr)
Propchange: trunk/rostests/tests/dllexport/dllexport_test_dll1.spec
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/tests/dllexport/dllexport_test_dll2.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/tests/dllexport/dllexport…
==============================================================================
--- trunk/rostests/tests/dllexport/dllexport_test_dll2.c (added)
+++ trunk/rostests/tests/dllexport/dllexport_test_dll2.c [iso-8859-1] Thu Feb 20 20:29:51
2014
@@ -0,0 +1,45 @@
+
+int __cdecl CdeclFunc0(void)
+{
+ return 0x10000;
+}
+
+int __cdecl CdeclFunc1(char *p1)
+{
+ return 0x10001;
+}
+
+int __stdcall StdcallFunc0(void)
+{
+ return 0x10010;
+}
+
+int __stdcall StdcallFunc1(char *p1)
+{
+ return 0x10011;
+}
+
+int __stdcall DecoratedStdcallFunc1(char *p1)
+{
+ return 0x10021;
+}
+
+int __fastcall FastcallFunc0(void)
+{
+ return 0x10030;
+}
+
+int __fastcall FastcallFunc1(char *p1)
+{
+ return 0x10031;
+}
+
+int __fastcall DecoratedFastcallFunc1(char *p1)
+{
+ return 0x10041;
+}
+
+int DataItem1 = 0x10051;
+int DataItem2 = 0x10052;
+
+
Propchange: trunk/rostests/tests/dllexport/dllexport_test_dll2.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/tests/dllexport/dllexport_test_dll2.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/tests/dllexport/dllexport…
==============================================================================
--- trunk/rostests/tests/dllexport/dllexport_test_dll2.spec (added)
+++ trunk/rostests/tests/dllexport/dllexport_test_dll2.spec [iso-8859-1] Thu Feb 20
20:29:51 2014
@@ -0,0 +1,23 @@
+
+# Normal export of a cdecl function
+ @ cdecl CdeclFunc0()
+ @ cdecl CdeclFunc1(ptr)
+
+# Normal export of a stdcall function
+ @ stdcall StdcallFunc0()
+ @ stdcall StdcallFunc1(ptr)
+
+# Decorated export of a stdcall function
+ @ stdcall _DecoratedStdcallFunc1@4(ptr)
+
+# Normal export of a fastcall function
+ @ fastcall FastcallFunc0()
+ @ fastcall FastcallFunc1(ptr)
+
+# Decorated export of a fastcall function
+ @ fastcall @DecoratedFastcallFunc1@4(ptr)
+
+# Normal export of data
+ @ extern DataItem1
+ @ extern DataItem2
+
Propchange: trunk/rostests/tests/dllexport/dllexport_test_dll2.spec
------------------------------------------------------------------------------
svn:eol-style = native