summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg')
-rw-r--r--src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/reg_unreg_libraryw_neg.c62
-rw-r--r--src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/testinfo.dat14
3 files changed, 95 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/CMakeLists.txt
new file mode 100644
index 0000000000..bbcb35933e
--- /dev/null
+++ b/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ reg_unreg_libraryw_neg.c
+)
+
+add_executable(paltest_reg_unreg_libraryw_neg
+ ${SOURCES}
+)
+
+add_dependencies(paltest_reg_unreg_libraryw_neg coreclrpal)
+
+target_link_libraries(paltest_reg_unreg_libraryw_neg
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/reg_unreg_libraryw_neg.c b/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/reg_unreg_libraryw_neg.c
new file mode 100644
index 0000000000..a15ff5745b
--- /dev/null
+++ b/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/reg_unreg_libraryw_neg.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: pal_registerlibraryw_unregisterlibraryw_neg.c
+**
+** Purpose: Negative test the PAL_RegisterLibrary API.
+** Call PAL_RegisterLibrary to map a non-existant module
+** into the calling process address space.
+**
+**
+**============================================================*/
+#define UNICODE
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+ HMODULE ModuleHandle;
+ char ModuleName[64];
+ WCHAR *wpModuleName = NULL;
+ int err;
+
+ /*Initialize the PAL environment*/
+ err = PAL_Initialize(argc, argv);
+ if(0 != err)
+ {
+ return FAIL;
+ }
+
+ memset(ModuleName, 0, 64);
+ sprintf(ModuleName, "%s", "not_exist_module_name");
+
+ /*convert a normal string to a wide one*/
+ wpModuleName = convert(ModuleName);
+
+ /*load a not exist module*/
+ ModuleHandle = PAL_RegisterLibrary(wpModuleName);
+
+ /*free the memory*/
+ free(wpModuleName);
+
+ if(NULL != ModuleHandle)
+ {
+ Trace("ERROR: PAL_RegisterLibrary successfully mapped "
+ "a module that does not exist into the calling process\n");
+
+ /*decrement the reference count of the loaded DLL*/
+ err = PAL_UnregisterLibrary(ModuleHandle);
+ if(0 == err)
+ {
+ Trace("\nFailed to call PAL_UnregisterLibrary API to decrement the "
+ "count of the loaded DLL module!\n");
+ }
+ Fail("");
+
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/testinfo.dat b/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/testinfo.dat
new file mode 100644
index 0000000000..3322633291
--- /dev/null
+++ b/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/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 = pal_specific
+Function = PAL_RegisterLibraryW and PAL_UnregisterLibraryW API
+Name = Negative test for PAL_RegisterLibraryW and PAL_UnregisterLibaryW API to map and unmap a non-existant module
+TYPE = DEFAULT
+EXE1 = pal_registerlibraryw_unregisterlibraryw_neg
+Description
+=Test the PAL_RegisterLibraryW and PAL_UnregisterLibraryW to map a non-existant
+=module into calling process address space
+