diff options
Diffstat (limited to 'src/pal/tests/palsuite/loader/LoadLibraryA/test2/LoadLibraryA.c')
-rw-r--r-- | src/pal/tests/palsuite/loader/LoadLibraryA/test2/LoadLibraryA.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test2/LoadLibraryA.c b/src/pal/tests/palsuite/loader/LoadLibraryA/test2/LoadLibraryA.c new file mode 100644 index 0000000000..d7cd9cb875 --- /dev/null +++ b/src/pal/tests/palsuite/loader/LoadLibraryA/test2/LoadLibraryA.c @@ -0,0 +1,52 @@ +// 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: loadlibrarya.c +** +** Purpose: Negative test the LoadLibraryA API. +** Call LoadLibraryA with a not exist module Name +** +** +**============================================================*/ +#include <palsuite.h> + +int __cdecl main(int argc, char *argv[]) +{ + HMODULE ModuleHandle; + int err; + const char *pModuleName = "Not-exist-module-name"; + + /* Initialize the PAL environment */ + err = PAL_Initialize(argc, argv); + if(0 != err) + { + return FAIL; + } + + /*try to load a not exist module */ + ModuleHandle = LoadLibraryA(pModuleName); + if(NULL != ModuleHandle) + { + Trace("Failed to call LoadLibraryA 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; +} |