summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/file_io/GetSystemTime/test1
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/file_io/GetSystemTime/test1
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/file_io/GetSystemTime/test1')
-rw-r--r--src/pal/tests/palsuite/file_io/GetSystemTime/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/file_io/GetSystemTime/test1/test.c124
-rw-r--r--src/pal/tests/palsuite/file_io/GetSystemTime/test1/testinfo.dat12
3 files changed, 155 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/file_io/GetSystemTime/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetSystemTime/test1/CMakeLists.txt
new file mode 100644
index 0000000000..94d5bcded9
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetSystemTime/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_getsystemtime_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getsystemtime_test1 coreclrpal)
+
+target_link_libraries(paltest_getsystemtime_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/file_io/GetSystemTime/test1/test.c b/src/pal/tests/palsuite/file_io/GetSystemTime/test1/test.c
new file mode 100644
index 0000000000..361dbef33d
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetSystemTime/test1/test.c
@@ -0,0 +1,124 @@
+// 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: Test for GetSystemTime() function
+**
+**
+**=========================================================*/
+
+/* Note: Some of the range comparisons only check
+ * the high end of the range. Since the structure
+ * contains WORDs, negative values can never be included,
+ * so there is no reason to check and see if the lower
+ * end of the spectrum is <0
+*/
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ SYSTEMTIME TheTime;
+ SYSTEMTIME firstTime;
+ SYSTEMTIME secondTime;
+
+ WORD avgDeltaFileTime = 0;
+
+ int i=0;
+
+
+ if (0 != PAL_Initialize(argc,argv))
+ {
+ return FAIL;
+ }
+
+ GetSystemTime(&TheTime);
+
+ /* Go through each item in the structure and ensure it is a valid value.
+ We can't ensure they have the exact values of the current time, but
+ at least that they have been set to a valid range of values for that
+ item.
+ */
+
+ /* Year */
+ if(TheTime.wYear < (WORD)2001)
+ {
+ Fail("ERROR: The year is %d, when it should be at least 2001.",
+ TheTime.wYear);
+ }
+
+ /* Month */
+ if(TheTime.wMonth > (WORD)12 || TheTime.wMonth < (WORD)1)
+ {
+ Fail("ERROR: The month should be between 1 and 12, and it is "
+ "showing up as %d.",TheTime.wMonth);
+ }
+
+ /* Weekday */
+ if(TheTime.wDayOfWeek > 6)
+ {
+ Fail("ERROR: The day of the week should be between 0 and 6, "
+ "and it is showing up as %d.",TheTime.wDayOfWeek);
+ }
+
+ /* Day of the Month */
+ if(TheTime.wDay > 31 || TheTime.wDay < 1)
+ {
+ Fail("ERROR: The day of the month should be between 1 and "
+ "31, and it is showing up as %d.",TheTime.wDay);
+ }
+
+ /* Hour */
+ if(TheTime.wHour > 23)
+ {
+ Fail("ERROR: The hour should be between 0 and 23, and it is "
+ "showing up as %d.",TheTime.wHour);
+ }
+
+ /* Minute */
+ if(TheTime.wMinute > 59)
+ {
+ Fail("ERROR: The minute should be between 0 and 59 and it is "
+ "showing up as %d.",TheTime.wMinute);
+ }
+
+ /* Second */
+ if(TheTime.wSecond > 59)
+ {
+ Fail("ERROR: The second should be between 0 and 59 and it is"
+ " showing up as %d.",TheTime.wSecond);
+ }
+
+ /* Millisecond */
+ if(TheTime.wMilliseconds > 999)
+ {
+ Fail("ERROR: The milliseconds should be between 0 and 999 "
+ "and it is currently showing %d.",TheTime.wMilliseconds);
+ }
+
+ /* check if two consecutive calls to system time return */
+ /* correct time in ms after sleep() call. */
+ for (i = 0; i<5 ;i++)
+ {
+ GetSystemTime(&firstTime);
+ Sleep(1000);
+ GetSystemTime(&secondTime);
+ avgDeltaFileTime += abs(firstTime.wSecond - secondTime.wSecond );
+
+ }
+
+ if( (avgDeltaFileTime/5) < 1.0)
+ {
+ Fail("ERROR: 2 calls for GetSystemTime interrupted"
+ " by a 1000 ms sleep failed Value[%f]", avgDeltaFileTime/5 );
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/file_io/GetSystemTime/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetSystemTime/test1/testinfo.dat
new file mode 100644
index 0000000000..05169f65c6
--- /dev/null
+++ b/src/pal/tests/palsuite/file_io/GetSystemTime/test1/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 = Miscellaneous
+Function = GetSystemTime
+Name = Positive test of GetSystemTime
+Type = DEFAULT
+EXE1 = test
+Description
+= Tests the PAL implementation of the GetSystemTime API