summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/loader/LoadLibraryW
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-11-23 19:09:09 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2016-11-23 19:09:09 +0900
commit4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch)
tree98110734c91668dfdbb126fcc0e15ddbd93738ca /src/pal/tests/palsuite/loader/LoadLibraryW
parentfa45f57ed55137c75ac870356a1b8f76c84b229c (diff)
downloadcoreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.gz
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.bz2
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.zip
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'src/pal/tests/palsuite/loader/LoadLibraryW')
-rw-r--r--src/pal/tests/palsuite/loader/LoadLibraryW/CMakeLists.txt7
-rw-r--r--src/pal/tests/palsuite/loader/LoadLibraryW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/loader/LoadLibraryW/test1/LoadLibraryW.c62
-rw-r--r--src/pal/tests/palsuite/loader/LoadLibraryW/test1/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/loader/LoadLibraryW/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/loader/LoadLibraryW/test2/loadlibraryw.c62
-rw-r--r--src/pal/tests/palsuite/loader/LoadLibraryW/test2/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/loader/LoadLibraryW/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/loader/LoadLibraryW/test3/loadlibraryw.c41
-rw-r--r--src/pal/tests/palsuite/loader/LoadLibraryW/test3/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/loader/LoadLibraryW/test5/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/loader/LoadLibraryW/test5/loadlibraryw.c71
-rw-r--r--src/pal/tests/palsuite/loader/LoadLibraryW/test5/testinfo.dat14
13 files changed, 370 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryW/CMakeLists.txt
new file mode 100644
index 0000000000..37abc032af
--- /dev/null
+++ b/src/pal/tests/palsuite/loader/LoadLibraryW/CMakeLists.txt
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+add_subdirectory(test3)
+add_subdirectory(test5)
+
diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test1/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryW/test1/CMakeLists.txt
new file mode 100644
index 0000000000..87038012b7
--- /dev/null
+++ b/src/pal/tests/palsuite/loader/LoadLibraryW/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ LoadLibraryW.c
+)
+
+add_executable(paltest_loadlibraryw_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_loadlibraryw_test1 coreclrpal)
+
+target_link_libraries(paltest_loadlibraryw_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test1/LoadLibraryW.c b/src/pal/tests/palsuite/loader/LoadLibraryW/test1/LoadLibraryW.c
new file mode 100644
index 0000000000..4c1a551de1
--- /dev/null
+++ b/src/pal/tests/palsuite/loader/LoadLibraryW/test1/LoadLibraryW.c
@@ -0,0 +1,62 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/*=============================================================
+**
+** Source: loadlibraryw.c
+**
+** Purpose: Positive test the LoadLibrary API.
+** Call LoadLibrary to map a module into the calling
+** process address space(DLL file)
+**
+**
+**============================================================*/
+#define UNICODE
+#include <palsuite.h>
+/* SHLEXT is defined only for Unix variants */
+
+#if defined(SHLEXT)
+#define ModuleName "librotor_pal"SHLEXT
+#else
+#define ModuleName "rotor_pal.dll"
+#endif
+
+int __cdecl main(int argc, char *argv[])
+{
+ HMODULE ModuleHandle;
+ int err;
+ WCHAR *lpModuleName;
+
+ /* Initialize the PAL environment */
+ err = PAL_Initialize(argc, argv);
+ if(0 != err)
+ {
+ ExitProcess(FAIL);
+ }
+
+ /* convert a normal string to a wide one */
+ lpModuleName = convert(ModuleName);
+
+ /* load a module */
+ ModuleHandle = LoadLibrary(lpModuleName);
+
+ /* free the memory */
+ free(lpModuleName);
+
+ if(!ModuleHandle)
+ {
+ Fail("Failed to call LoadLibrary API!\n");
+ }
+
+
+ /* decrement the reference count of the loaded dll */
+ err = FreeLibrary(ModuleHandle);
+ if(0 == err)
+ {
+ Fail("\nFailed to all FreeLibrary API!\n");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test1/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryW/test1/testinfo.dat
new file mode 100644
index 0000000000..c5c4adc75a
--- /dev/null
+++ b/src/pal/tests/palsuite/loader/LoadLibraryW/test1/testinfo.dat
@@ -0,0 +1,12 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+Version = 1.0
+Section = Loader
+Function = LoadLibraryW
+Name = Positive test for LoadLibraryW API to load a dynamic library module
+TYPE = DEFAULT
+EXE1 = loadlibraryw
+Description
+=Test the LoadLibraryW to map module into calling process address space
diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test2/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryW/test2/CMakeLists.txt
new file mode 100644
index 0000000000..5e8486d23b
--- /dev/null
+++ b/src/pal/tests/palsuite/loader/LoadLibraryW/test2/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ loadlibraryw.c
+)
+
+add_executable(paltest_loadlibraryw_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_loadlibraryw_test2 coreclrpal)
+
+target_link_libraries(paltest_loadlibraryw_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test2/loadlibraryw.c b/src/pal/tests/palsuite/loader/LoadLibraryW/test2/loadlibraryw.c
new file mode 100644
index 0000000000..e8aebf77e9
--- /dev/null
+++ b/src/pal/tests/palsuite/loader/LoadLibraryW/test2/loadlibraryw.c
@@ -0,0 +1,62 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/*=============================================================
+**
+** Source: loadlibraryw.c
+**
+** Purpose: Negative test the LoadLibraryW API.
+** Call LoadLibraryW with a not exist module Name
+**
+**
+**============================================================*/
+#define UNICODE
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+ HMODULE ModuleHandle;
+ int err;
+ WCHAR *pwModuleName;
+ const char *pModuleName = "Not-exist-module-name";
+
+ /* Initialize the PAL environment */
+ err = PAL_Initialize(argc, argv);
+ if(0 != err)
+ {
+ return FAIL;
+ }
+
+ /* convert a normal string to a wide one */
+ pwModuleName = convert((char *)pModuleName);
+
+
+ /*try to load a not exist module */
+ ModuleHandle = LoadLibraryW(pwModuleName);
+
+ /* free the memory */
+ free(pwModuleName);
+
+ if(NULL != ModuleHandle)
+ {
+ Trace("Failed to call LoadLibraryW with a not exist mudule name, "
+ "a NULL module handle is expected, but no NULL module handle "
+ "is returned, error code=%u\n", GetLastError());
+
+ /* decrement the reference count of the loaded module */
+ err = FreeLibrary(ModuleHandle);
+ if(0 == err)
+ {
+ Trace("\nFailed to all FreeLibrary API to decrement "
+ "the reference count of the loaded module, "
+ "error code = %u\n", GetLastError());
+
+ }
+
+ Fail("");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test2/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryW/test2/testinfo.dat
new file mode 100644
index 0000000000..bc107f0069
--- /dev/null
+++ b/src/pal/tests/palsuite/loader/LoadLibraryW/test2/testinfo.dat
@@ -0,0 +1,13 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+Version = 1.0
+Section = Loader
+Function = LoadLibraryW
+Name = Negative test LoadLibraryW API to load a not exist module
+TYPE = DEFAULT
+EXE1 = loadlibraryw
+Description
+=Test the LoadLibraryW to load a not exist module
+
diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test3/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryW/test3/CMakeLists.txt
new file mode 100644
index 0000000000..2c96fa23da
--- /dev/null
+++ b/src/pal/tests/palsuite/loader/LoadLibraryW/test3/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ loadlibraryw.c
+)
+
+add_executable(paltest_loadlibraryw_test3
+ ${SOURCES}
+)
+
+add_dependencies(paltest_loadlibraryw_test3 coreclrpal)
+
+target_link_libraries(paltest_loadlibraryw_test3
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test3/loadlibraryw.c b/src/pal/tests/palsuite/loader/LoadLibraryW/test3/loadlibraryw.c
new file mode 100644
index 0000000000..c722edaf13
--- /dev/null
+++ b/src/pal/tests/palsuite/loader/LoadLibraryW/test3/loadlibraryw.c
@@ -0,0 +1,41 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/*=============================================================
+**
+** Source: loadlibraryw.c
+**
+** Purpose: Negative test the loadlibraryw API.
+** Call loadlibraryw with NULL module name
+**
+**
+**============================================================*/
+#define UNICODE
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+ HMODULE ModuleHandle;
+ int err;
+
+ /* Initialize the PAL environment */
+ err = PAL_Initialize(argc, argv);
+ if(0 != err)
+ {
+ return FAIL;
+ }
+
+ /* load a module with a NULL module name */
+ ModuleHandle = LoadLibraryW(NULL);
+ if(NULL != ModuleHandle)
+ {
+ Fail("\nFailed to call loadlibraryw API for a negative test, "
+ "call loadibraryw with NULL moudle name, a NULL module "
+ "handle is expected, but no NULL module handle is returned, "
+ "error code =%u\n", GetLastError());
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test3/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryW/test3/testinfo.dat
new file mode 100644
index 0000000000..bd20aaf995
--- /dev/null
+++ b/src/pal/tests/palsuite/loader/LoadLibraryW/test3/testinfo.dat
@@ -0,0 +1,12 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+Version = 1.0
+Section = Loader
+Function = LoadLibraryW
+Name = Negative test loadlibraryw API with a NULL module name
+TYPE = DEFAULT
+EXE1 = loadlibraryw
+Description
+=Test the LoadLibraryW with a NULL module name
diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test5/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryW/test5/CMakeLists.txt
new file mode 100644
index 0000000000..7b8931a961
--- /dev/null
+++ b/src/pal/tests/palsuite/loader/LoadLibraryW/test5/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ loadlibraryw.c
+)
+
+add_executable(paltest_loadlibraryw_test5
+ ${SOURCES}
+)
+
+add_dependencies(paltest_loadlibraryw_test5 coreclrpal)
+
+target_link_libraries(paltest_loadlibraryw_test5
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test5/loadlibraryw.c b/src/pal/tests/palsuite/loader/LoadLibraryW/test5/loadlibraryw.c
new file mode 100644
index 0000000000..acaa200a06
--- /dev/null
+++ b/src/pal/tests/palsuite/loader/LoadLibraryW/test5/loadlibraryw.c
@@ -0,0 +1,71 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/*=============================================================
+**
+** Source: loadlibraryw.c
+**
+** Purpose: Negative test the LoadLibraryW API.
+** Call LoadLibraryW by passing a module name
+** without extension but with a trailing dot.
+**
+**
+**============================================================*/
+#define UNICODE
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+ HMODULE ModuleHandle;
+ int err;
+ WCHAR *lpModuleName;
+ char ModuleName[_MAX_FNAME];
+
+ /* Initialize the PAL environment */
+ err = PAL_Initialize(argc, argv);
+ if(0 != err)
+ {
+ return FAIL;
+ }
+
+ memset(ModuleName, 0, _MAX_FNAME);
+
+ /*Module name without extension but with a trailing dot*/
+#if WIN32
+ sprintf(ModuleName,"%s","rotor_pal.");
+#else
+ sprintf(ModuleName,"%s","librotor_pal.");
+#endif
+
+ /* convert a normal string to a wide one */
+ lpModuleName = convert(ModuleName);
+
+ /* load a module */
+ ModuleHandle = LoadLibraryW(lpModuleName);
+
+ /* free the memory */
+ free(lpModuleName);
+
+ if(NULL != ModuleHandle)
+ {
+ Trace("Failed to call LoadLibraryW API for a negative test "
+ "call LoadLibraryW with module name which does not have "
+ "extension except a trailing dot, a NULL module handle is"
+ "expected, but no NULL module handle is returned, "
+ "error code = %u\n", GetLastError());
+
+ /* decrement the reference count of the loaded dll */
+ err = FreeLibrary(ModuleHandle);
+ if(0 == err)
+ {
+ Trace("\nFailed to call FreeLibrary API, "
+ "error code = %u\n", GetLastError());
+ }
+
+ Fail("");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test5/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryW/test5/testinfo.dat
new file mode 100644
index 0000000000..8275f41644
--- /dev/null
+++ b/src/pal/tests/palsuite/loader/LoadLibraryW/test5/testinfo.dat
@@ -0,0 +1,14 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+Version = 1.0
+Section = Loader
+Function = LoadLibraryw
+Name = Negative test for LoadLibraryW API by passing a module name without extension but with a trailing dot.
+TYPE = DEFAULT
+EXE1 = loadlibraryw
+Description
+=Test the LoadLibraryW by passing a module name without extension
+=but with a trailing dot.
+