diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-09-28 16:01:53 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-09-28 16:01:53 +0000 |
commit | 0d573690ae0b2075e99f13f9006b959a9f0da184 (patch) | |
tree | 2e24fb0a52938b3ce89f2eda0a49ec6305e973b4 /testsuites/sptests/sp2038 | |
parent | 2011-09-28 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff) | |
download | rtems-0d573690ae0b2075e99f13f9006b959a9f0da184.tar.bz2 |
2011-09-28 Sebastian Huber <sebastian.huber@embedded-brains.de>
* sp2038/Makefile.am, sp2038/init.c, sp2038/sp2038.doc,
sp2038/sp2038.scn: New files.
* Makefile.am, configure.ac: Reflect changes above.
Diffstat (limited to 'testsuites/sptests/sp2038')
-rw-r--r-- | testsuites/sptests/sp2038/Makefile.am | 28 | ||||
-rw-r--r-- | testsuites/sptests/sp2038/init.c | 127 | ||||
-rw-r--r-- | testsuites/sptests/sp2038/sp2038.doc | 23 | ||||
-rw-r--r-- | testsuites/sptests/sp2038/sp2038.scn | 2 |
4 files changed, 180 insertions, 0 deletions
diff --git a/testsuites/sptests/sp2038/Makefile.am b/testsuites/sptests/sp2038/Makefile.am new file mode 100644 index 0000000000..38c3ca68d7 --- /dev/null +++ b/testsuites/sptests/sp2038/Makefile.am @@ -0,0 +1,28 @@ +## +## $Id$ +## + +MANAGERS = all + +rtems_tests_PROGRAMS = sp2038 +sp2038_SOURCES = init.c + +dist_rtems_tests_DATA = sp2038.scn +dist_rtems_tests_DATA += sp2038.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +sp2038_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel) + +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(sp2038_OBJECTS) $(sp2038_LDADD) +LINK_LIBS = $(sp2038_LDLIBS) + +sp2038$(EXEEXT): $(sp2038_OBJECTS) $(sp2038_DEPENDENCIES) + @rm -f sp2038$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/sptests/sp2038/init.c b/testsuites/sptests/sp2038/init.c new file mode 100644 index 0000000000..961ef3bebe --- /dev/null +++ b/testsuites/sptests/sp2038/init.c @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2011 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tmacros.h> + +#include <time.h> +#include <string.h> + +#include <rtems.h> + +#define TEST_APPLICABLE \ + (CPU_TIMESTAMP_USE_INT64 == TRUE || CPU_TIMESTAMP_USE_INT64_INLINE == TRUE) + +#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL) + +static const rtems_time_of_day nearly_problem_2038 = { + .year = 2038, + .month = 1, + .day = 19, + .hour = 3, + .minute = 14, + .second = 7 +}; + +static const rtems_time_of_day problem_2038 = { + .year = 2038, + .month = 1, + .day = 19, + .hour = 3, + .minute = 14, + .second = 8 +}; + +static const rtems_time_of_day nearly_problem_2106 = { + .year = 2106, + .month = 2, + .day = 7, + .hour = 6, + .minute = 28, + .second = 15 +}; + +static const rtems_time_of_day problem_2106 = { + .year = 2106, + .month = 2, + .day = 7, + .hour = 6, + .minute = 28, + .second = 16 +}; + +static void test_case(void) +{ +#if TEST_APPLICABLE + rtems_status_code sc = RTEMS_SUCCESSFUL; + int64_t one = 1; + int64_t large = one << 32; + time_t time_t_large = (time_t) large; + bool time_t_is_32_bit = time_t_large != large; + bool time_t_is_signed = (((time_t) 0) - ((time_t) 1)) < 0; + + if (time_t_is_32_bit) { + const rtems_time_of_day *nearly_problem = NULL; + const rtems_time_of_day *problem = NULL; + rtems_time_of_day now; + + if (time_t_is_signed) { + nearly_problem = &nearly_problem_2038; + problem = &problem_2038; + } else { + nearly_problem = &nearly_problem_2106; + problem = &problem_2106; + } + + sc = rtems_clock_set(nearly_problem); + ASSERT_SC(sc); + sc = rtems_clock_get_tod(&now); + ASSERT_SC(sc); + rtems_test_assert(memcmp(&now, nearly_problem, sizeof(now)) == 0); + + sc = rtems_clock_set(problem); + ASSERT_SC(sc); + sc = rtems_clock_get_tod(&now); + ASSERT_SC(sc); + rtems_test_assert(memcmp(&now, problem, sizeof(now)) == 0); + } +#endif /* TEST_APPLICABLE */ +} + +rtems_task Init(rtems_task_argument argument) +{ + puts("\n\n*** TEST 2038 ***"); + + test_case(); + + puts("*** END OF TEST 2038 ***"); + + rtems_test_exit(0); +} + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> diff --git a/testsuites/sptests/sp2038/sp2038.doc b/testsuites/sptests/sp2038/sp2038.doc new file mode 100644 index 0000000000..199859221e --- /dev/null +++ b/testsuites/sptests/sp2038/sp2038.doc @@ -0,0 +1,23 @@ +# +# $Id$ +# +# Copyright (c) 2011 embedded brains GmbH. All rights reserved. +# +# The license and distribution terms for this file may be +# found in the file LICENSE in this distribution or at +# http://www.rtems.com/license/LICENSE. +# + +This file describes the directives and concepts tested by this test set. + +test set name: sp2038 + +directives: + + rtems_clock_set + rtems_clock_get + time + +concepts: + ++ Ensure that special time values lead to the expected result diff --git a/testsuites/sptests/sp2038/sp2038.scn b/testsuites/sptests/sp2038/sp2038.scn new file mode 100644 index 0000000000..5849f0a2be --- /dev/null +++ b/testsuites/sptests/sp2038/sp2038.scn @@ -0,0 +1,2 @@ +*** TEST 2038 *** +*** END OF TEST 2038 *** |