Index: testsuites/psxtests/ChangeLog
===================================================================
--- testsuites/psxtests/ChangeLog	(revision 0c116189aa322379431561eef2f4710ebd41fdfc)
+++ testsuites/psxtests/ChangeLog	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
@@ -1,2 +1,13 @@
+2009-11-11	Joel Sherrill <joel.sherrill@oarcorp.com>
+
+	PR 1466/tests
+	* Makefile.am, configure.ac, psxclock/init.c, psxclock/psxclock.doc,
+	psxclock/psxclock.scn, psxkey03/init.c, psxsignal02/init.c,
+	psxsignal03/init.c, psxstack01/init.c: Remove usleep() from tests.
+	Add test specifically to test it since it is deprecated as of
+	POSIX.1-2008.
+	* psxusleep/.cvsignore, psxusleep/Makefile.am, psxusleep/init.c,
+	psxusleep/psxusleep.doc, psxusleep/psxusleep.scn: New files.
+
 2009-11-09	Joel Sherrill <joel.sherrill@oarcorp.com>
 
Index: testsuites/psxtests/Makefile.am
===================================================================
--- testsuites/psxtests/Makefile.am	(revision 0c116189aa322379431561eef2f4710ebd41fdfc)
+++ testsuites/psxtests/Makefile.am	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
@@ -15,5 +15,5 @@
     psxmutexattr01 psxobj01 psxrwlock01 psxsem01 psxsignal01 psxsignal02 \
     psxsignal03 psxsignal04 psxsignal05 psxspin01 psxspin02 psxsysconf \
-    psxtime psxtimer01 psxtimer02 psxualarm psxfatal01 psxfatal02 \
+    psxtime psxtimer01 psxtimer02 psxualarm psxusleep psxfatal01 psxfatal02 \
     psxintrcritical01 psxstack01
 endif
Index: testsuites/psxtests/configure.ac
===================================================================
--- testsuites/psxtests/configure.ac	(revision 0c116189aa322379431561eef2f4710ebd41fdfc)
+++ testsuites/psxtests/configure.ac	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
@@ -116,4 +116,5 @@
 psxtimer02/Makefile
 psxualarm/Makefile
+psxusleep/Makefile
 ])
 AC_OUTPUT
Index: testsuites/psxtests/psxclock/init.c
===================================================================
--- testsuites/psxtests/psxclock/init.c	(revision 0c116189aa322379431561eef2f4710ebd41fdfc)
+++ testsuites/psxtests/psxclock/init.c	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
@@ -35,5 +35,5 @@
   unsigned int    remaining;
   struct tm       tm;
-  useconds_t      useconds;
+  struct timespec delay_request;
 
   puts( "\n\n*** POSIX CLOCK TEST ***" );
@@ -207,7 +207,9 @@
   rtems_test_assert( !tr.tv_sec && !tr.tv_nsec );
 
-  puts( "Init: usleep - 1.35 seconds" );
-  useconds = usleep ( 1350000 );
-  rtems_test_assert( useconds < 1350000 );
+  puts( "Init: nanosleep - 1.35 seconds" );
+  delay_request.tv_sec = 1;
+  delay_request.tv_nsec = 35000000;
+  sc = nanosleep( &delay_request, NULL );
+  assert( !sc );
   
   /* print the current real time again */
Index: testsuites/psxtests/psxclock/psxclock.scn
===================================================================
--- testsuites/psxtests/psxclock/psxclock.scn	(revision 0c116189aa322379431561eef2f4710ebd41fdfc)
+++ testsuites/psxtests/psxclock/psxclock.scn	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
@@ -29,5 +29,5 @@
 Fri May 24 11:05:06 1996
 Init: sec (0), nsec (0) remaining
-Init: usleep - 1.35 seconds
+Init: nanosleep - 1.35 seconds
 Fri May 24 11:05:07 1996
 clock_gettime - CLOCK_THREAD_CPUTIME -- ENOSYS
Index: testsuites/psxtests/psxkey03/init.c
===================================================================
--- testsuites/psxtests/psxkey03/init.c	(revision 0c116189aa322379431561eef2f4710ebd41fdfc)
+++ testsuites/psxtests/psxkey03/init.c	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
@@ -41,6 +41,7 @@
 )
 {
-  pthread_t     thread;
-  int           sc;
+  pthread_t        thread;
+  int              sc;
+  struct timespec  delay_request;
 
   puts( "\n\n*** TEST KEY 03 ***" );
@@ -58,5 +59,8 @@
 
   puts( "Init - sleep - let thread run - OK" );
-  usleep(500000);
+  delay_request.tv_sec = 0;
+  delay_request.tv_nsec = 5 * 100000000;
+  sc = nanosleep( &delay_request, NULL );
+  assert( !sc );
 
   puts( "Init - pthread_key_delete - OK" );
@@ -77,5 +81,6 @@
 
   puts( "Init - sleep - let thread run - OK" );
-  usleep(500000);
+  sc = nanosleep( &delay_request, NULL );
+  assert( !sc );
 
   puts( "Init - verify destructor did NOT ran" );
Index: testsuites/psxtests/psxsignal02/init.c
===================================================================
--- testsuites/psxtests/psxsignal02/init.c	(revision 0c116189aa322379431561eef2f4710ebd41fdfc)
+++ testsuites/psxtests/psxsignal02/init.c	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
@@ -126,4 +126,5 @@
   Test_t             *test;
   struct sigaction    act;
+  struct timespec     delay_request;
 
   puts( "\n\n*** POSIX TEST SIGNAL 02 ***" );
@@ -162,5 +163,8 @@
 
     puts( "Init - sleep - let thread settle - OK" );
-    usleep(500000);
+    delay_request.tv_sec = 0;
+    delay_request.tv_nsec = 50000000;
+    sc = nanosleep( &delay_request, NULL );
+    assert( !sc );
   }
 
Index: testsuites/psxtests/psxsignal03/init.c
===================================================================
--- testsuites/psxtests/psxsignal03/init.c	(revision 0c116189aa322379431561eef2f4710ebd41fdfc)
+++ testsuites/psxtests/psxsignal03/init.c	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
@@ -149,4 +149,5 @@
   bool                trueArg = true;
   bool                falseArg = false;
+  struct timespec     delay_request;
 
   puts( "\n\n*** POSIX TEST SIGNAL " TEST_NAME " ***" );
@@ -169,8 +170,12 @@
 
   puts( "Init - sleep - let threads settle - OK" );
-  usleep(500000);
+  delay_request.tv_sec = 0;
+  delay_request.tv_nsec = 5 * 100000000;
+  sc = nanosleep( &delay_request, NULL );
+  assert( !sc );
 
   puts( "Init - sleep - SignalBlocked thread settle - OK" );
-  usleep(500000);
+  sc = nanosleep( &delay_request, NULL );
+  assert( !sc );
 
   printf( "Init - sending %s - deliver to one thread\n",
Index: testsuites/psxtests/psxstack01/init.c
===================================================================
--- testsuites/psxtests/psxstack01/init.c	(revision 0c116189aa322379431561eef2f4710ebd41fdfc)
+++ testsuites/psxtests/psxstack01/init.c	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
@@ -50,4 +50,5 @@
   pthread_t           id;
   pthread_attr_t      attr;
+  struct timespec     delay_request;
 
   puts( "\n\n*** POSIX STACK ATTRIBUTE TEST 01 ***" );
@@ -73,5 +74,8 @@
 
   puts( "Init - let other thread run" );
-  usleep( 500000 );
+  delay_request.tv_sec = 0;
+  delay_request.tv_nsec = 5 * 100000000;
+  sc = nanosleep( &delay_request, NULL );
+  assert( !sc );
 
   puts( "*** END OF POSIX STACK ATTRIBUTE TEST 01 ***" );
Index: testsuites/psxtests/psxusleep/.cvsignore
===================================================================
--- testsuites/psxtests/psxusleep/.cvsignore	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
+++ testsuites/psxtests/psxusleep/.cvsignore	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
Index: testsuites/psxtests/psxusleep/Makefile.am
===================================================================
--- testsuites/psxtests/psxusleep/Makefile.am	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
+++ testsuites/psxtests/psxusleep/Makefile.am	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
@@ -0,0 +1,29 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxusleep
+psxusleep_SOURCES = init.c ../include/pmacros.h
+
+dist_rtems_tests_DATA = psxusleep.scn
+dist_rtems_tests_DATA += psxusleep.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+psxusleep_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
+AM_CPPFLAGS += -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(psxusleep_OBJECTS) $(psxusleep_LDADD)
+LINK_LIBS = $(psxusleep_LDLIBS)
+
+psxusleep$(EXEEXT): $(psxusleep_OBJECTS) $(psxusleep_DEPENDENCIES)
+	@rm -f psxusleep$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
Index: testsuites/psxtests/psxusleep/init.c
===================================================================
--- testsuites/psxtests/psxusleep/init.c	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
+++ testsuites/psxtests/psxusleep/init.c	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
@@ -0,0 +1,68 @@
+/*
+ *  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 tm       tm;
+  struct timespec tv;
+  useconds_t      remaining;
+  int             sc;
+
+  puts( "\n\n*** POSIX USLEEP TEST ***" );
+
+  tm_build_time( &tm, TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
+
+  /* set the time of day, and print our buffer in multiple ways */
+
+  tv.tv_nsec = 0;
+  tv.tv_sec = mktime( &tm );
+  rtems_test_assert( tv.tv_sec != -1 );
+
+  /* now set the time of day */
+
+  printf( asctime( &tm ) );
+  puts( "Init: clock_settime - SUCCESSFUL" );
+  sc = clock_settime( CLOCK_REALTIME, &tv );
+  rtems_test_assert( !sc );
+
+  printf( asctime( &tm ) );
+  printf( ctime( &tv.tv_sec ) );
+
+  /* use sleep to delay */
+
+  remaining = usleep( 3 * 1000000 );
+  rtems_test_assert( !remaining );
+  
+  sc = clock_gettime( CLOCK_REALTIME, &tv );
+  rtems_test_assert( !sc );
+
+  printf( ctime( &tv.tv_sec ) );
+
+  puts( "*** END OF POSIX USLEEP 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>
Index: testsuites/psxtests/psxusleep/psxusleep.scn
===================================================================
--- testsuites/psxtests/psxusleep/psxusleep.scn	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
+++ testsuites/psxtests/psxusleep/psxusleep.scn	(revision ea7d86b2450f3d4587e13c21b900ad10211aed60)
@@ -0,0 +1,7 @@
+*** POSIX USLEEP TEST ***
+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
+Fri May 24 11:05:03 1996
+*** END OF POSIX USLEEP TEST ***
