summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/miscellaneous/GetComputerNameW
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/miscellaneous/GetComputerNameW')
-rw-r--r--src/pal/tests/palsuite/miscellaneous/GetComputerNameW/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/test.c53
-rw-r--r--src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/testinfo.dat13
4 files changed, 89 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/CMakeLists.txt
new file mode 100644
index 0000000000..f6aa0cb2d9
--- /dev/null
+++ b/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/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/GetComputerNameW/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/CMakeLists.txt
new file mode 100644
index 0000000000..980dae88ae
--- /dev/null
+++ b/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/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_getcomputernamew_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getcomputernamew_test1 coreclrpal)
+
+target_link_libraries(paltest_getcomputernamew_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/test.c b/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/test.c
new file mode 100644
index 0000000000..7a00cad598
--- /dev/null
+++ b/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/test.c
@@ -0,0 +1,53 @@
+// 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 GetComputerName() function
+**
+**
+**=========================================================*/
+
+#define UNICODE
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+
+ int HOST_NAME_MAX = 255;
+ WCHAR wzComputerName[HOST_NAME_MAX+1];
+ DWORD dwSize = sizeof(wzComputerName)/sizeof(wzComputerName[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 == GetComputerName(wzComputerName, &dwSize))
+ {
+ Fail("ERROR: GetComputerName failed with %d!\n", GetLastError());
+ }
+
+ // dwSize is the length of wzComputerName without NULL
+ if (dwSize < 0 || dwSize > (sizeof(wzComputerName)/sizeof(wzComputerName[0]) - 1))
+ {
+ Fail("ERROR: GetComputerName returned %S with dwSize = %u whereas the passed in buffer size is %d!\n",
+ wzComputerName, dwSize, sizeof(wzComputerName)/sizeof(wzComputerName[0]));
+ }
+
+ // dwSize is the length of wzComputerName without NULL
+ if (dwSize != wcslen(wzComputerName))
+ {
+ Fail("ERROR: GetComputerName returned %S of length %d which is not equal to dwSize = %u!\n",
+ wzComputerName, wcslen(wzComputerName), dwSize);
+ }
+
+ printf ("GetComputerName returned %S of length %u\n", wzComputerName, dwSize);
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/testinfo.dat
new file mode 100644
index 0000000000..d45bca1c25
--- /dev/null
+++ b/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/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 = GetComputerNameW
+Name = Test for GetComputerNameW
+TYPE = DEFAULT
+EXE1 = test
+Description
+= Check to ensure that GetComputerNameW returnes a decent value.
+