summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxclock
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-09-13 20:36:36 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-09-13 20:36:36 +0000
commit88271c3308aef5db023687bf32ea30c60becc080 (patch)
treefd443cbf2d3209e8a1499c516773eb317a29624b /testsuites/psxtests/psxclock
parent2009-09-13 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-88271c3308aef5db023687bf32ea30c60becc080.tar.bz2
2009-09-13 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, configure.ac, psx01/init.c, psx01/psx01.scn: Add new test to exercise clock and delay services enabled when POSIX threads are disabled. This is split from psx01. POSIX test suite now enabled when POSIX threads are disabled so only enable tests which are appropriate. * psxclock/.cvsignore, psxclock/Makefile.am, psxclock/init.c, psxclock/psxclock.doc, psxclock/psxclock.scn: New files.
Diffstat (limited to 'testsuites/psxtests/psxclock')
-rw-r--r--testsuites/psxtests/psxclock/.cvsignore2
-rw-r--r--testsuites/psxtests/psxclock/Makefile.am29
-rw-r--r--testsuites/psxtests/psxclock/init.c206
-rw-r--r--testsuites/psxtests/psxclock/psxclock.doc28
-rw-r--r--testsuites/psxtests/psxclock/psxclock.scn31
5 files changed, 296 insertions, 0 deletions
diff --git a/testsuites/psxtests/psxclock/.cvsignore b/testsuites/psxtests/psxclock/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/psxtests/psxclock/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/psxtests/psxclock/Makefile.am b/testsuites/psxtests/psxclock/Makefile.am
new file mode 100644
index 0000000000..e456cb76dc
--- /dev/null
+++ b/testsuites/psxtests/psxclock/Makefile.am
@@ -0,0 +1,29 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxclock
+psxclock_SOURCES = init.c ../include/pmacros.h
+
+dist_rtems_tests_DATA = psxclock.scn
+dist_rtems_tests_DATA += psxclock.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+psxclock_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
+AM_CPPFLAGS += -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(psxclock_OBJECTS) $(psxclock_LDADD)
+LINK_LIBS = $(psxclock_LDLIBS)
+
+psxclock$(EXEEXT): $(psxclock_OBJECTS) $(psxclock_DEPENDENCIES)
+ @rm -f psxclock$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxclock/init.c b/testsuites/psxtests/psxclock/init.c
new file mode 100644
index 0000000000..9f8c5671d9
--- /dev/null
+++ b/testsuites/psxtests/psxclock/init.c
@@ -0,0 +1,206 @@
+/*
+ * COPYRIGHT (c) 1989-2009.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * 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$
+ */
+
+#include <pmacros.h>
+#include <time.h>
+#include <errno.h>
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ struct timespec tv;
+ struct timespec tr;
+ int status;
+ int priority;
+ pthread_t thread_id;
+ time_t seconds;
+ time_t seconds1;
+ unsigned int remaining;
+ struct tm tm;
+ useconds_t useconds;
+
+ puts( "\n\n*** POSIX CLOCK TEST ***" );
+
+ tm_build_time( &tm, TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
+
+ /* error cases in clock_gettime and clock_settime */
+
+ puts( "Init: clock_gettime - EINVAL (NULL timespec)" );
+ status = clock_gettime( CLOCK_REALTIME, NULL );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == EINVAL );
+
+ puts( "Init: clock_gettime - EINVAL (invalid clockid)" );
+ status = clock_gettime( (clockid_t)-1, &tv );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == EINVAL );
+
+ puts( "Init: clock_settime - EINVAL (invalid clockid)" );
+ status = clock_settime( (clockid_t)-1, &tv );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == EINVAL );
+
+ /* way back near the dawn of time :D */
+ tv.tv_sec = 1;
+ tv.tv_nsec = 0;
+ printf( ctime( &tv.tv_sec ) );
+ puts( "Init: clock_settime - before 1988 EINVAL" );
+ status = clock_settime( CLOCK_REALTIME, &tv );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == EINVAL );
+
+ /* exercise clock_getres */
+
+ puts( "Init: clock_getres - EINVAL (invalid clockid)" );
+ status = clock_getres( (clockid_t) -1, &tv );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == EINVAL );
+
+ puts( "Init: clock_getres - EINVAL (NULL resolution)" );
+ status = clock_getres( CLOCK_REALTIME, NULL );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == EINVAL );
+
+ puts( "Init: clock_getres - SUCCESSFUL" );
+ status = clock_getres( CLOCK_REALTIME, &tv );
+ printf( "Init: resolution = sec (%ld), nsec (%ld)\n", tv.tv_sec, tv.tv_nsec );
+ rtems_test_assert( !status );
+
+ /* set the time of day, and print our buffer in multiple ways */
+
+ tv.tv_sec = mktime( &tm );
+ rtems_test_assert( tv.tv_sec != -1 );
+
+ tv.tv_nsec = 0;
+
+ /* now set the time of day */
+
+ empty_line();
+
+ printf( asctime( &tm ) );
+ puts( "Init: clock_settime - SUCCESSFUL" );
+ status = clock_settime( CLOCK_REALTIME, &tv );
+ rtems_test_assert( !status );
+
+ printf( asctime( &tm ) );
+ printf( ctime( &tv.tv_sec ) );
+
+ /* use sleep to delay */
+
+ remaining = sleep( 3 );
+ rtems_test_assert( !remaining );
+
+ /* print new times to make sure it has changed and we can get the realtime */
+ status = clock_gettime( CLOCK_PROCESS_CPUTIME, &tv );
+ rtems_test_assert( !status );
+ printf("Time since boot: (%d, %d)\n", tv.tv_sec,tv.tv_nsec );
+
+ status = clock_gettime( CLOCK_REALTIME, &tv );
+ rtems_test_assert( !status );
+
+ printf( ctime( &tv.tv_sec ) );
+
+ seconds = time( NULL );
+ printf( ctime( &seconds ) );
+
+ /* just to have the value copied out through the parameter */
+
+ seconds = time( &seconds1 );
+ rtems_test_assert( seconds == seconds1 );
+
+ /* check the time remaining */
+
+ printf( "Init: seconds remaining (%d)\n", (int)remaining );
+ rtems_test_assert( !remaining );
+
+ /* error cases in nanosleep */
+
+ empty_line();
+ puts( "Init: nanosleep - EINVAL (NULL time)" );
+ status = nanosleep ( NULL, &tr );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == EINVAL );
+
+ tv.tv_sec = 0;
+ tv.tv_nsec = TOD_NANOSECONDS_PER_SECOND * 2;
+ puts( "Init: nanosleep - EINVAL (too many nanoseconds)" );
+ status = nanosleep ( &tv, &tr );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == EINVAL );
+
+ /* this is actually a small delay or yield */
+ tv.tv_sec = -1;
+ tv.tv_nsec = 0;
+ puts( "Init: nanosleep - negative seconds small delay " );
+ status = nanosleep ( &tv, &tr );
+ rtems_test_assert( status == -1 );
+ rtems_test_assert( errno == EINVAL );
+
+ /* use nanosleep to yield */
+
+ tv.tv_sec = 0;
+ tv.tv_nsec = 0;
+
+ puts( "Init: nanosleep - yield with remaining" );
+ status = nanosleep ( &tv, &tr );
+ rtems_test_assert( !status );
+ rtems_test_assert( !tr.tv_sec );
+ rtems_test_assert( !tr.tv_nsec );
+
+ puts( "Init: nanosleep - yield with NULL time remaining" );
+ status = nanosleep ( &tv, NULL );
+ rtems_test_assert( !status );
+ rtems_test_assert( !tr.tv_sec );
+ rtems_test_assert( !tr.tv_nsec );
+
+ /* use nanosleep to delay */
+
+ tv.tv_sec = 3;
+ tv.tv_nsec = 500000;
+
+ puts( "Init: nanosleep - 1.05 seconds" );
+ status = nanosleep ( &tv, &tr );
+ rtems_test_assert( !status );
+
+ /* print the current real time again */
+ status = clock_gettime( CLOCK_REALTIME, &tv );
+ rtems_test_assert( !status );
+ printf( ctime( &tv.tv_sec ) );
+
+ /* check the time remaining */
+
+ printf( "Init: sec (%ld), nsec (%ld) remaining\n", tr.tv_sec, tr.tv_nsec );
+ rtems_test_assert( !tr.tv_sec && !tr.tv_nsec );
+
+ puts( "Init: usleep - 1.35 seconds" );
+ useconds = usleep ( 1350000 );
+ rtems_test_assert( useconds < 1350000 );
+
+ /* print the current real time again */
+ status = clock_gettime( CLOCK_REALTIME, &tv );
+ rtems_test_assert( !status );
+ printf( ctime( &tv.tv_sec ) );
+
+ puts( "*** END OF POSIX CLOCK TEST ***" );
+ rtems_test_exit(0);
+}
+
+
+/* configuration information */
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+#define CONFIGURE_MAXIMUM_TASKS 1
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
diff --git a/testsuites/psxtests/psxclock/psxclock.doc b/testsuites/psxtests/psxclock/psxclock.doc
new file mode 100644
index 0000000000..8bb4c5e6c3
--- /dev/null
+++ b/testsuites/psxtests/psxclock/psxclock.doc
@@ -0,0 +1,28 @@
+#
+# $Id$
+#
+# COPYRIGHT (c) 1989-2009.
+# On-Line Applications Research Corporation (OAR).
+#
+# 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: psxclock
+
+directives:
+ clock_settime
+ clock_gettime
+ nanosleep
+ usleep
+ sleep
+
+concepts:
+
++ This is a non-POSIX threads test which uses POSIX services which
+ are available when RTEMS is configured with --disable-posix.
+
++ Ensures that the above listed services have 100% object coverage.
diff --git a/testsuites/psxtests/psxclock/psxclock.scn b/testsuites/psxtests/psxclock/psxclock.scn
new file mode 100644
index 0000000000..6814210d9b
--- /dev/null
+++ b/testsuites/psxtests/psxclock/psxclock.scn
@@ -0,0 +1,31 @@
+*** POSIX CLOCK TEST ***
+Init: clock_gettime - EINVAL (NULL timespec)
+Init: clock_gettime - EINVAL (invalid clockid)
+Init: clock_settime - EINVAL (invalid clockid)
+Thu Jan 1 00:00:01 1970
+Init: clock_settime - before 1988 EINVAL
+Init: clock_getres - EINVAL (invalid clockid)
+Init: clock_getres - EINVAL (NULL resolution)
+Init: clock_getres - SUCCESSFUL
+Init: resolution = sec (0), nsec (10000000)
+
+Fri May 24 11:05:00 1996
+Init: clock_settime - SUCCESSFUL
+Fri May 24 11:05:00 1996
+Fri May 24 11:05:00 1996
+Time since boot: (3, 10131000)
+Fri May 24 11:05:03 1996
+Fri May 24 11:05:03 1996
+Init: seconds remaining (0)
+
+Init: nanosleep - EINVAL (NULL time)
+Init: nanosleep - EINVAL (too many nanoseconds)
+Init: nanosleep - negative seconds small delay
+Init: nanosleep - yield with remaining
+Init: nanosleep - yield with NULL time remaining
+Init: nanosleep - 1.05 seconds
+Fri May 24 11:05:06 1996
+Init: sec (0), nsec (0) remaining
+Init: usleep - 1.35 seconds
+Fri May 24 11:05:07 1996
+*** END OF POSIX CLOCK TEST ***