summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/c_runtime/errno
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/c_runtime/errno
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/c_runtime/errno')
-rw-r--r--src/pal/tests/palsuite/c_runtime/errno/CMakeLists.txt5
-rw-r--r--src/pal/tests/palsuite/c_runtime/errno/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/errno/test1/test1.c43
-rw-r--r--src/pal/tests/palsuite/c_runtime/errno/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/c_runtime/errno/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/errno/test2/test2.c76
-rw-r--r--src/pal/tests/palsuite/c_runtime/errno/test2/testinfo.dat12
7 files changed, 187 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/errno/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/errno/CMakeLists.txt
new file mode 100644
index 0000000000..ef14ea5352
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/errno/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+
diff --git a/src/pal/tests/palsuite/c_runtime/errno/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/errno/test1/CMakeLists.txt
new file mode 100644
index 0000000000..89b25a4fac
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/errno/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test1.c
+)
+
+add_executable(paltest_errno_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_errno_test1 coreclrpal)
+
+target_link_libraries(paltest_errno_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/errno/test1/test1.c b/src/pal/tests/palsuite/c_runtime/errno/test1/test1.c
new file mode 100644
index 0000000000..3ae25fb02a
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/errno/test1/test1.c
@@ -0,0 +1,43 @@
+// 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: test1.c
+**
+** Purpose: Test that errno begins as 0, and sets to ERANGE when that
+** error is forced with wcstoul.
+**
+**
+**==========================================================================*/
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+ WCHAR overstr[] = {'4','2','9','4','9','6','7','2','9','6',0};
+ WCHAR *end;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ /*
+ From rotor.doc: The only value that must be supported is
+ ERANGE, in the event that wcstoul() fails due to overflow.
+ */
+
+ wcstoul(overstr, &end, 10);
+
+ if (errno != ERANGE)
+ {
+ Fail("ERROR: wcstoul did not set errno to ERANGE. Instead "
+ "the value of errno is %d\n", errno);
+ }
+
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/errno/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/errno/test1/testinfo.dat
new file mode 100644
index 0000000000..3291dbc60a
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/errno/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 = C Runtime
+Function = errno
+Name = Positive Test for errno
+TYPE = DEFAULT
+EXE1 = test1
+Description
+= Test that errno begins as 0, and sets to ERANGE when that
+= error is forced with wcstoul.
diff --git a/src/pal/tests/palsuite/c_runtime/errno/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/errno/test2/CMakeLists.txt
new file mode 100644
index 0000000000..edd4cf7975
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/errno/test2/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test2.c
+)
+
+add_executable(paltest_errno_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_errno_test2 coreclrpal)
+
+target_link_libraries(paltest_errno_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/errno/test2/test2.c b/src/pal/tests/palsuite/c_runtime/errno/test2/test2.c
new file mode 100644
index 0000000000..f418d2f199
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/errno/test2/test2.c
@@ -0,0 +1,76 @@
+// 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: test2.c
+**
+** Purpose: Test that errno is 'per-thread' as noted in the documentation.
+**
+**
+**==========================================================================*/
+
+#include <palsuite.h>
+
+/*
+ This thread function just checks that errno is initially 0 and then sets
+ it to a new value before returning.
+*/
+DWORD PALAPI ThreadFunc( LPVOID lpParam )
+{
+
+ if(errno != 0)
+ {
+ *((DWORD*)lpParam) = 1;
+ }
+
+ errno = 20;
+
+ return 0;
+}
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ DWORD dwThreadId, dwThrdParam = 0;
+ HANDLE hThread;
+
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ /* Set errno to a value within this thread */
+
+ errno = 50;
+
+ hThread = CreateThread(NULL, 0, ThreadFunc, &dwThrdParam, 0, &dwThreadId);
+
+ if (hThread == NULL)
+ {
+ Fail("ERROR: CreateThread failed to create a thread. "
+ "GetLastError() returned %d.\n",GetLastError());
+ }
+
+ WaitForSingleObject(hThread, INFINITE);
+
+ /* This checks the result of calling the thread */
+ if(dwThrdParam)
+ {
+ Fail("ERROR: errno was not set to 0 in the new thread. Each "
+ "thread should have its own value for errno.\n");
+ }
+
+ /* Check to make sure errno is still set to 50 */
+ if(errno != 50)
+ {
+ Fail("ERROR: errno should be 50 in the main thread, even though "
+ "it was set to 20 in another thread. Currently it is %d.\n",
+ errno);
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/errno/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/errno/test2/testinfo.dat
new file mode 100644
index 0000000000..90c232866f
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/errno/test2/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 = C Runtime
+Function = errno
+Name = Positive Test for errno
+TYPE = DEFAULT
+EXE1 = test2
+Description
+= Test that errno is 'per-thread' as noted in the documentation.