diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2016-11-23 19:09:09 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2016-11-23 19:09:09 +0900 |
commit | 4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch) | |
tree | 98110734c91668dfdbb126fcc0e15ddbd93738ca /src/pal/tests/palsuite/miscellaneous/GetUserNameW | |
parent | fa45f57ed55137c75ac870356a1b8f76c84b229c (diff) | |
download | coreclr-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/miscellaneous/GetUserNameW')
4 files changed, 88 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/miscellaneous/GetUserNameW/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetUserNameW/CMakeLists.txt new file mode 100644 index 0000000000..f6aa0cb2d9 --- /dev/null +++ b/src/pal/tests/palsuite/miscellaneous/GetUserNameW/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +add_subdirectory(test1) + diff --git a/src/pal/tests/palsuite/miscellaneous/GetUserNameW/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetUserNameW/test1/CMakeLists.txt new file mode 100644 index 0000000000..a1d5ab21b8 --- /dev/null +++ b/src/pal/tests/palsuite/miscellaneous/GetUserNameW/test1/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test.c +) + +add_executable(paltest_getusernamew_test1 + ${SOURCES} +) + +add_dependencies(paltest_getusernamew_test1 coreclrpal) + +target_link_libraries(paltest_getusernamew_test1 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/miscellaneous/GetUserNameW/test1/test.c b/src/pal/tests/palsuite/miscellaneous/GetUserNameW/test1/test.c new file mode 100644 index 0000000000..809f14c12d --- /dev/null +++ b/src/pal/tests/palsuite/miscellaneous/GetUserNameW/test1/test.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 : test.c +** +** Purpose: Positive Test for GetUserName() function +** +** +**=========================================================*/ + +#define UNICODE +#include <palsuite.h> + +int __cdecl main(int argc, char *argv[]) +{ + + WCHAR wzUserName[UNLEN+1]; + DWORD dwSize = sizeof(wzUserName)/sizeof(wzUserName[0]); + + // Initialize the PAL and return FAILURE if this fails + if(0 != (PAL_Initialize(argc, argv))) + { + Fail ("ERROR: PAL_Initialize() call failed!\n"); + } + + if (0 == GetUserName(wzUserName, &dwSize)) + { + Fail("ERROR: GetUserName failed with %d!\n", GetLastError()); + } + + // dwSize is the length of wzUserName with NULL + if (dwSize <= 0 || dwSize > (sizeof(wzUserName)/sizeof(wzUserName[0]))) + { + Fail("ERROR: GetUserName returned %S with dwSize = %u whereas the passed in buffer size is %d!\n", + wzUserName, dwSize, sizeof(wzUserName)/sizeof(wzUserName[0])); + } + + // dwSize is the length of wzUserName with NULL + if (dwSize != wcslen(wzUserName)+1) + { + Fail("ERROR: GetUserName returned %S of length %d which is not equal to dwSize-1 = %u!\n", + wzUserName, wcslen(wzUserName), dwSize-1); + } + + printf ("GetUserName returned %S of length %u\n", wzUserName, dwSize-1); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/miscellaneous/GetUserNameW/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetUserNameW/test1/testinfo.dat new file mode 100644 index 0000000000..3e0aa48bd0 --- /dev/null +++ b/src/pal/tests/palsuite/miscellaneous/GetUserNameW/test1/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 = Miscellaneous +Function = GetUserNameW +Name = Test for GetUserNameW +TYPE = DEFAULT +EXE1 = test +Description += Check to ensure that GetUserNameW returnes a decent value. + |