2009-12-08 Joel Sherrill <joel.sherrill@oarcorp.com>

* include/pmacros.h, psx01/task.c, psx02/init.c, psx02/task.c,
	psx03/init.c, psx03/task.c, psx04/init.c, psx04/task1.c,
	psx04/task2.c, psx04/task3.c, psx05/init.c, psx05/task.c,
	psx05/task2.c, psx05/task3.c, psx06/init.c, psx06/task.c,
	psx06/task2.c, psx07/init.c, psx08/init.c, psx08/task2.c,
	psx08/task3.c, psx09/init.c, psx10/init.c, psx10/task.c,
	psx10/task2.c, psx10/task3.c, psx11/init.c, psx11/task.c,
	psx12/init.c, psxalarm01/init.c, psxbarrier01/test.c,
	psxcancel01/init.c, psxchroot01/test.c, psxclock/init.c,
	psxfile01/test.c, psxfile01/test_cat.c, psxfile01/test_extend.c,
	psxfile01/test_write.c, psxitimer/init.c, psxkey01/task.c,
	psxkey02/init.c, psxkey03/init.c, psxmount/test.c, psxmsgq01/init.c,
	psxmsgq03/init.c, psxmsgq04/init.c, psxreaddir/test.c,
	psxrwlock01/test.c, psxsem01/init.c, psxsignal01/init.c,
	psxsignal01/task1.c, psxsignal02/init.c, psxsignal03/init.c,
	psxsignal05/init.c, psxspin01/test.c, psxspin02/test.c,
	psxstack01/init.c, psxstat/test.c, psxtime/test.c, psxualarm/init.c:
	Use rtems_test_assert() consistently instead of system assert().
	rtems_test_assert() is designed to integrate into the RTEMS test
	suite infrastructure.
This commit is contained in:
Joel Sherrill
2009-12-08 17:52:53 +00:00
parent 500fcd5c88
commit 2317457e10
61 changed files with 998 additions and 948 deletions

View File

@@ -1,3 +1,26 @@
2009-12-08 Joel Sherrill <joel.sherrill@oarcorp.com>
* include/pmacros.h, psx01/task.c, psx02/init.c, psx02/task.c,
psx03/init.c, psx03/task.c, psx04/init.c, psx04/task1.c,
psx04/task2.c, psx04/task3.c, psx05/init.c, psx05/task.c,
psx05/task2.c, psx05/task3.c, psx06/init.c, psx06/task.c,
psx06/task2.c, psx07/init.c, psx08/init.c, psx08/task2.c,
psx08/task3.c, psx09/init.c, psx10/init.c, psx10/task.c,
psx10/task2.c, psx10/task3.c, psx11/init.c, psx11/task.c,
psx12/init.c, psxalarm01/init.c, psxbarrier01/test.c,
psxcancel01/init.c, psxchroot01/test.c, psxclock/init.c,
psxfile01/test.c, psxfile01/test_cat.c, psxfile01/test_extend.c,
psxfile01/test_write.c, psxitimer/init.c, psxkey01/task.c,
psxkey02/init.c, psxkey03/init.c, psxmount/test.c, psxmsgq01/init.c,
psxmsgq03/init.c, psxmsgq04/init.c, psxreaddir/test.c,
psxrwlock01/test.c, psxsem01/init.c, psxsignal01/init.c,
psxsignal01/task1.c, psxsignal02/init.c, psxsignal03/init.c,
psxsignal05/init.c, psxspin01/test.c, psxspin02/test.c,
psxstack01/init.c, psxstat/test.c, psxtime/test.c, psxualarm/init.c:
Use rtems_test_assert() consistently instead of system assert().
rtems_test_assert() is designed to integrate into the RTEMS test
suite infrastructure.
2009-12-03 Joel Sherrill <joel.sherrill@oarcorp.com> 2009-12-03 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, configure.ac: New test to exercise getgrnam and getpwnam * Makefile.am, configure.ac: New test to exercise getgrnam and getpwnam

View File

@@ -1,4 +1,11 @@
/* /*
* 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$ * $Id$
*/ */
@@ -9,7 +16,6 @@
#include <bsp.h> #include <bsp.h>
#endif #endif
#include <pthread.h> #include <pthread.h>
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
@@ -64,10 +70,10 @@
\ \
tv.tv_sec = mktime( &tm ); \ tv.tv_sec = mktime( &tm ); \
tv.tv_nsec = 0; \ tv.tv_nsec = 0; \
assert( tv.tv_sec != -1 ); \ rtems_test_assert( tv.tv_sec != -1 ); \
\ \
status = clock_settime( CLOCK_REALTIME, &tv ); \ status = clock_settime( CLOCK_REALTIME, &tv ); \
assert( !status ); \ rtems_test_assert( !status ); \
} while ( 0 ) } while ( 0 )
#define print_current_time(s1, s2) \ #define print_current_time(s1, s2) \
@@ -77,7 +83,7 @@
struct timespec _tv; \ struct timespec _tv; \
\ \
_status = clock_gettime( CLOCK_REALTIME, &_tv ); \ _status = clock_gettime( CLOCK_REALTIME, &_tv ); \
assert( !_status ); \ rtems_test_assert( !_status ); \
\ \
(void) ctime_r( &_tv.tv_sec, _time_buffer ); \ (void) ctime_r( &_tv.tv_sec, _time_buffer ); \
_time_buffer[ strlen( _time_buffer ) - 1 ] = 0; \ _time_buffer[ strlen( _time_buffer ) - 1 ] = 0; \

View File

@@ -37,7 +37,7 @@ void *Task_1_through_3(
puts( "Task_1: sched_yield to Init" ); puts( "Task_1: sched_yield to Init" );
status = sched_yield(); status = sched_yield();
assert( !status ); rtems_test_assert( !status );
/* switch to Task_1 */ /* switch to Task_1 */
@@ -55,38 +55,38 @@ void *Task_1_through_3(
status = pthread_equal( Task_id, Task_id ); status = pthread_equal( Task_id, Task_id );
if ( status ) if ( status )
puts( "Task_1: pthread_equal - match case passed" ); puts( "Task_1: pthread_equal - match case passed" );
assert( status ); rtems_test_assert( status );
status = pthread_equal( Init_id, Task_id ); status = pthread_equal( Init_id, Task_id );
if ( !status ) if ( !status )
puts( "Task_1: pthread_equal - different case passed" ); puts( "Task_1: pthread_equal - different case passed" );
assert( !status ); rtems_test_assert( !status );
puts( "Task_1: pthread_equal - first id bad" ); puts( "Task_1: pthread_equal - first id bad" );
status = pthread_equal( (pthread_t) -1, Task_id ); status = pthread_equal( (pthread_t) -1, Task_id );
assert( !status ); rtems_test_assert( !status );
puts( "Task_1: pthread_equal - second id bad" ); puts( "Task_1: pthread_equal - second id bad" );
status = pthread_equal( Init_id, (pthread_t) -1 ); status = pthread_equal( Init_id, (pthread_t) -1 );
assert( !status ); rtems_test_assert( !status );
/* exercise pthread_once */ /* exercise pthread_once */
puts( "Task_1: pthread_once - EINVAL (NULL once_control)" ); puts( "Task_1: pthread_once - EINVAL (NULL once_control)" );
status = pthread_once( NULL, Test_init_routine ); status = pthread_once( NULL, Test_init_routine );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Task_1: pthread_once - EINVAL (NULL init_routine)" ); puts( "Task_1: pthread_once - EINVAL (NULL init_routine)" );
status = pthread_once( &once, NULL ); status = pthread_once( &once, NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Task_1: pthread_once - SUCCESSFUL (init_routine executes)" ); puts( "Task_1: pthread_once - SUCCESSFUL (init_routine executes)" );
status = pthread_once( &once, Test_init_routine ); status = pthread_once( &once, Test_init_routine );
assert( !status ); rtems_test_assert( !status );
puts( "Task_1: pthread_once - SUCCESSFUL (init_routine does not execute)" ); puts( "Task_1: pthread_once - SUCCESSFUL (init_routine does not execute)" );
status = pthread_once( &once, Test_init_routine ); status = pthread_once( &once, Test_init_routine );
assert( !status ); rtems_test_assert( !status );
puts( "*** END OF POSIX TEST 1 ***" ); puts( "*** END OF POSIX TEST 1 ***" );
rtems_test_exit( 0 ); rtems_test_exit( 0 );

View File

@@ -56,7 +56,7 @@ void *POSIX_Init(
/* install a signal handler */ /* install a signal handler */
status = sigemptyset( &act.sa_mask ); status = sigemptyset( &act.sa_mask );
assert( !status ); rtems_test_assert( !status );
act.sa_handler = Signal_handler; act.sa_handler = Signal_handler;
act.sa_flags = 0; act.sa_flags = 0;
@@ -69,43 +69,43 @@ void *POSIX_Init(
Signal_occurred = 0; Signal_occurred = 0;
status = pthread_kill( Init_id, SIGUSR1 ); status = pthread_kill( Init_id, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
Signal_occurred = 0; Signal_occurred = 0;
/* now block the signal, send it, see if it is pending, and unblock it */ /* now block the signal, send it, see if it is pending, and unblock it */
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGUSR1 ); status = sigaddset( &mask, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
printf( "Init: Block SIGUSR1\n" ); printf( "Init: Block SIGUSR1\n" );
status = sigprocmask( SIG_BLOCK, &mask, NULL ); status = sigprocmask( SIG_BLOCK, &mask, NULL );
assert( !status ); rtems_test_assert( !status );
status = sigpending( &pending_set ); status = sigpending( &pending_set );
assert( !status ); rtems_test_assert( !status );
printf( "Init: Signals pending 0x%08x\n", (unsigned int) pending_set ); printf( "Init: Signals pending 0x%08x\n", (unsigned int) pending_set );
printf( "Init: send SIGUSR1 to self\n" ); printf( "Init: send SIGUSR1 to self\n" );
status = pthread_kill( Init_id, SIGUSR1 ); status = pthread_kill( Init_id, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
status = sigpending( &pending_set ); status = sigpending( &pending_set );
assert( !status ); rtems_test_assert( !status );
printf( "Init: Signals pending 0x%08x\n", (unsigned int) pending_set ); printf( "Init: Signals pending 0x%08x\n", (unsigned int) pending_set );
printf( "Init: Unblock SIGUSR1\n" ); printf( "Init: Unblock SIGUSR1\n" );
status = sigprocmask( SIG_UNBLOCK, &mask, NULL ); status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
assert( !status ); rtems_test_assert( !status );
/* create a thread */ /* create a thread */
status = pthread_create( &Task_id, NULL, Task_1_through_3, NULL ); status = pthread_create( &Task_id, NULL, Task_1_through_3, NULL );
assert( !status ); rtems_test_assert( !status );
/* /*
* Loop for 5 seconds seeing how many signals we catch * Loop for 5 seconds seeing how many signals we catch
@@ -122,10 +122,10 @@ void *POSIX_Init(
status = nanosleep ( &tv, &tr ); status = nanosleep ( &tv, &tr );
if ( status == -1 ) { if ( status == -1 ) {
assert( errno == EINTR ); rtems_test_assert( errno == EINTR );
assert( tr.tv_nsec || tr.tv_sec ); rtems_test_assert( tr.tv_nsec || tr.tv_sec );
} else if ( !status ) { } else if ( !status ) {
assert( !tr.tv_nsec && !tr.tv_sec ); rtems_test_assert( !tr.tv_nsec && !tr.tv_sec );
} }
printf( printf(

View File

@@ -32,10 +32,10 @@ void *Task_1_through_3(
for ( i=0 ; i<5 ; i++ ) { for ( i=0 ; i<5 ; i++ ) {
print_current_time( "Task1: ", "" ); print_current_time( "Task1: ", "" );
status = pthread_kill( Init_id, SIGUSR1 ); status = pthread_kill( Init_id, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
seconds = sleep( 1 ); seconds = sleep( 1 );
assert( !seconds ); rtems_test_assert( !seconds );
} }
puts( "*** END OF POSIX TEST 2 ***" ); puts( "*** END OF POSIX TEST 2 ***" );
rtems_test_exit( 0 ); rtems_test_exit( 0 );

View File

@@ -58,7 +58,7 @@ void *POSIX_Init(
/* install a signal handler */ /* install a signal handler */
status = sigemptyset( &act.sa_mask ); status = sigemptyset( &act.sa_mask );
assert( !status ); rtems_test_assert( !status );
act.sa_handler = Signal_handler; act.sa_handler = Signal_handler;
act.sa_flags = 0; act.sa_flags = 0;
@@ -77,17 +77,17 @@ void *POSIX_Init(
/* initialize the signal set we will wait for to SIGUSR1 */ /* initialize the signal set we will wait for to SIGUSR1 */
status = sigemptyset( &waitset ); status = sigemptyset( &waitset );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &waitset, SIGUSR1 ); status = sigaddset( &waitset, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
timeout.tv_sec = 3; timeout.tv_sec = 3;
timeout.tv_nsec = 0; timeout.tv_nsec = 0;
puts( "Init: waiting on any signal for 3 seconds." ); puts( "Init: waiting on any signal for 3 seconds." );
signo = sigtimedwait( &waitset, &siginfo, &timeout ); signo = sigtimedwait( &waitset, &siginfo, &timeout );
assert( signo == -1 ); rtems_test_assert( signo == -1 );
if ( errno == EAGAIN ) if ( errno == EAGAIN )
puts( "Init: correctly timed out waiting for SIGUSR1." ); puts( "Init: correctly timed out waiting for SIGUSR1." );
@@ -105,19 +105,19 @@ void *POSIX_Init(
/* initialize a mask to block SIGUSR2 */ /* initialize a mask to block SIGUSR2 */
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGUSR2 ); status = sigaddset( &mask, SIGUSR2 );
assert( !status ); rtems_test_assert( !status );
printf( "Init: Block SIGUSR2\n" ); printf( "Init: Block SIGUSR2\n" );
status = sigprocmask( SIG_BLOCK, &mask, NULL ); status = sigprocmask( SIG_BLOCK, &mask, NULL );
assert( !status ); rtems_test_assert( !status );
/* create a thread */ /* create a thread */
status = pthread_create( &Task_id, NULL, Task_1, NULL ); status = pthread_create( &Task_id, NULL, Task_1, NULL );
assert( !status ); rtems_test_assert( !status );
/* signal handler is still installed, waitset is still set for SIGUSR1 */ /* signal handler is still installed, waitset is still set for SIGUSR1 */
@@ -133,7 +133,7 @@ void *POSIX_Init(
puts( "Init: correctly timed out waiting for SIGUSR1." ); puts( "Init: correctly timed out waiting for SIGUSR1." );
else else
printf( "sigtimedwait returned wrong errno - %d\n", errno ); printf( "sigtimedwait returned wrong errno - %d\n", errno );
assert( signo == -1 ); rtems_test_assert( signo == -1 );
/* /*
* wait on SIGUSR1 for 3 seconds, Task_2 will send it to us * wait on SIGUSR1 for 3 seconds, Task_2 will send it to us
@@ -144,7 +144,7 @@ void *POSIX_Init(
/* create a thread */ /* create a thread */
status = pthread_create( &Task_id, NULL, Task_2, NULL ); status = pthread_create( &Task_id, NULL, Task_2, NULL );
assert( !status ); rtems_test_assert( !status );
/* signal handler is still installed, waitset is still set for SIGUSR1 */ /* signal handler is still installed, waitset is still set for SIGUSR1 */
@@ -162,38 +162,38 @@ void *POSIX_Init(
puts( "Init: waiting on any signal for 3 seconds." ); puts( "Init: waiting on any signal for 3 seconds." );
signo = sigtimedwait( &waitset, &siginfo, &timeout ); signo = sigtimedwait( &waitset, &siginfo, &timeout );
printf( "Init: received (%d) SIGUSR1=%d\n", siginfo.si_signo, SIGUSR1 ); printf( "Init: received (%d) SIGUSR1=%d\n", siginfo.si_signo, SIGUSR1 );
assert( signo == SIGUSR1 ); rtems_test_assert( signo == SIGUSR1 );
assert( siginfo.si_signo == SIGUSR1 ); rtems_test_assert( siginfo.si_signo == SIGUSR1 );
assert( siginfo.si_code == SI_USER ); rtems_test_assert( siginfo.si_code == SI_USER );
assert( siginfo.si_value.sival_int != -1 ); /* rtems does always set this */ rtems_test_assert( siginfo.si_value.sival_int != -1 ); /* rtems does always set this */
/* try out a process signal */ /* try out a process signal */
empty_line(); empty_line();
puts( "Init: kill with SIGUSR2." ); puts( "Init: kill with SIGUSR2." );
status = kill( getpid(), SIGUSR2 ); status = kill( getpid(), SIGUSR2 );
assert( !status ); rtems_test_assert( !status );
siginfo.si_code = -1; siginfo.si_code = -1;
siginfo.si_signo = -1; siginfo.si_signo = -1;
siginfo.si_value.sival_int = -1; siginfo.si_value.sival_int = -1;
status = sigemptyset( &waitset ); status = sigemptyset( &waitset );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &waitset, SIGUSR1 ); status = sigaddset( &waitset, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &waitset, SIGUSR2 ); status = sigaddset( &waitset, SIGUSR2 );
assert( !status ); rtems_test_assert( !status );
puts( "Init: waiting on any signal for 3 seconds." ); puts( "Init: waiting on any signal for 3 seconds." );
signo = sigtimedwait( &waitset, &siginfo, &timeout ); signo = sigtimedwait( &waitset, &siginfo, &timeout );
printf( "Init: received (%d) SIGUSR2=%d\n", siginfo.si_signo, SIGUSR2 ); printf( "Init: received (%d) SIGUSR2=%d\n", siginfo.si_signo, SIGUSR2 );
assert( signo == SIGUSR2 ); rtems_test_assert( signo == SIGUSR2 );
assert( siginfo.si_signo == SIGUSR2 ); rtems_test_assert( siginfo.si_signo == SIGUSR2 );
assert( siginfo.si_code == SI_USER ); rtems_test_assert( siginfo.si_code == SI_USER );
assert( siginfo.si_value.sival_int != -1 ); /* rtems does always set this */ rtems_test_assert( siginfo.si_value.sival_int != -1 ); /* rtems does always set this */
/* exit this thread */ /* exit this thread */

View File

@@ -8,7 +8,7 @@
* *
* Output parameters: NONE * Output parameters: NONE
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -33,7 +33,7 @@ void *Task_1(
puts( "Task_1: pthread_kill - SIGUSR2 to Init" ); puts( "Task_1: pthread_kill - SIGUSR2 to Init" );
status = pthread_kill( Init_id, SIGUSR2 ); status = pthread_kill( Init_id, SIGUSR2 );
assert( !status ); rtems_test_assert( !status );
pthread_exit( NULL ); pthread_exit( NULL );
@@ -54,7 +54,7 @@ void *Task_2(
puts( "Task_1: pthread_kill - SIGUSR1 to Init" ); puts( "Task_1: pthread_kill - SIGUSR1 to Init" );
status = pthread_kill( Init_id, SIGUSR1 ); status = pthread_kill( Init_id, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
pthread_exit( NULL ); pthread_exit( NULL );

View File

@@ -85,44 +85,44 @@ void *POSIX_Init(
status = sigwait( NULL, NULL ); status = sigwait( NULL, NULL );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d (%s)\n", status, strerror(status) ); printf( "status = %d (%s)\n", status, strerror(status) );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: sigwait - EINVAL (NULL set)" ); puts( "Init: sigwait - EINVAL (NULL set)" );
status = sigtimedwait( NULL, NULL, NULL ); status = sigtimedwait( NULL, NULL, NULL );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: sigwait - EINVAL (NULL set)" ); puts( "Init: sigwait - EINVAL (NULL set)" );
/* install a signal handler for SIGUSR1 */ /* install a signal handler for SIGUSR1 */
status = sigemptyset( &act.sa_mask ); status = sigemptyset( &act.sa_mask );
assert( !status ); rtems_test_assert( !status );
printf( "Init: sigemptyset - set= 0x%08x\n", (unsigned int) act.sa_mask ); printf( "Init: sigemptyset - set= 0x%08x\n", (unsigned int) act.sa_mask );
/* test sigfillset following the above sigemptyset */ /* test sigfillset following the above sigemptyset */
status = sigfillset( &act.sa_mask ); status = sigfillset( &act.sa_mask );
assert( !status ); rtems_test_assert( !status );
printf( "Init: sigfillset - set= 0x%08x\n", (unsigned int) act.sa_mask ); printf( "Init: sigfillset - set= 0x%08x\n", (unsigned int) act.sa_mask );
/* test sigdelset */ /* test sigdelset */
status = sigdelset( &act.sa_mask, SIGUSR1 ); status = sigdelset( &act.sa_mask, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
printf( "Init: sigdelset - delete SIGUSR1 set= 0x%08x\n", printf( "Init: sigdelset - delete SIGUSR1 set= 0x%08x\n",
(unsigned int) act.sa_mask ); (unsigned int) act.sa_mask );
/* test sigismember - FALSE */ /* test sigismember - FALSE */
status = sigismember( &act.sa_mask, SIGUSR1 ); status = sigismember( &act.sa_mask, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
puts( "Init: sigismember - FALSE since SIGUSR1 is not a member" ); puts( "Init: sigismember - FALSE since SIGUSR1 is not a member" );
/* test sigismember - TRUE */ /* test sigismember - TRUE */
status = sigismember( &act.sa_mask, SIGUSR2 ); status = sigismember( &act.sa_mask, SIGUSR2 );
assert( status ); rtems_test_assert( status );
puts( "Init: sigismember - TRUE since SIGUSR2 is a member" ); puts( "Init: sigismember - TRUE since SIGUSR2 is a member" );
/* return the set to empty */ /* return the set to empty */
@@ -139,7 +139,7 @@ void *POSIX_Init(
puts( "Init: send SIGUSR1 to process" ); puts( "Init: send SIGUSR1 to process" );
status = kill( getpid(), SIGUSR1 ); status = kill( getpid(), SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
/* end of install a signal handler for SIGUSR1 */ /* end of install a signal handler for SIGUSR1 */
@@ -150,10 +150,10 @@ void *POSIX_Init(
empty_line(); empty_line();
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGUSR1 ); status = sigaddset( &mask, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Block SIGUSR1" ); puts( "Init: Block SIGUSR1" );
act.sa_handler = Signal_handler; act.sa_handler = Signal_handler;
@@ -168,7 +168,7 @@ void *POSIX_Init(
puts( "Init: send SIGUSR1 to process" ); puts( "Init: send SIGUSR1 to process" );
status = kill( getpid(), SIGUSR1 ); status = kill( getpid(), SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
Signal_occurred = 0; Signal_occurred = 0;
@@ -177,30 +177,30 @@ void *POSIX_Init(
empty_line(); empty_line();
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGUSR1 ); status = sigaddset( &mask, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Block SIGUSR1" ); puts( "Init: Block SIGUSR1" );
status = sigprocmask( SIG_BLOCK, &mask, NULL ); status = sigprocmask( SIG_BLOCK, &mask, NULL );
assert( !status ); rtems_test_assert( !status );
status = sigpending( &pending_set ); status = sigpending( &pending_set );
assert( !status ); rtems_test_assert( !status );
printf( "Init: Signals pending 0x%08x\n", (unsigned int) pending_set ); printf( "Init: Signals pending 0x%08x\n", (unsigned int) pending_set );
puts( "Init: send SIGUSR1 to process" ); puts( "Init: send SIGUSR1 to process" );
status = kill( getpid(), SIGUSR1 ); status = kill( getpid(), SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
status = sigpending( &pending_set ); status = sigpending( &pending_set );
assert( !status ); rtems_test_assert( !status );
printf( "Init: Signals pending 0x%08x\n", (unsigned int) pending_set ); printf( "Init: Signals pending 0x%08x\n", (unsigned int) pending_set );
puts( "Init: Unblock SIGUSR1" ); puts( "Init: Unblock SIGUSR1" );
status = sigprocmask( SIG_UNBLOCK, &mask, NULL ); status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
assert( !status ); rtems_test_assert( !status );
/* now let another task get interrupted by a signal */ /* now let another task get interrupted by a signal */
@@ -208,33 +208,33 @@ void *POSIX_Init(
puts( "Init: create a thread interested in SIGUSR1" ); puts( "Init: create a thread interested in SIGUSR1" );
status = pthread_create( &Task1_id, NULL, Task_1, NULL ); status = pthread_create( &Task1_id, NULL, Task_1, NULL );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Block SIGUSR1" ); puts( "Init: Block SIGUSR1" );
status = sigprocmask( SIG_BLOCK, &mask, NULL ); status = sigprocmask( SIG_BLOCK, &mask, NULL );
assert( !status ); rtems_test_assert( !status );
status = sigpending( &pending_set ); status = sigpending( &pending_set );
assert( !status ); rtems_test_assert( !status );
printf( "Init: Signals pending 0x%08x\n", (unsigned int) pending_set ); printf( "Init: Signals pending 0x%08x\n", (unsigned int) pending_set );
puts( "Init: sleep so the other task can block" ); puts( "Init: sleep so the other task can block" );
remaining = sleep( 1 ); remaining = sleep( 1 );
assert( !status ); rtems_test_assert( !status );
/* switch to task 1 */ /* switch to task 1 */
puts( "Init: send SIGUSR1 to process" ); puts( "Init: send SIGUSR1 to process" );
status = kill( getpid(), SIGUSR1 ); status = kill( getpid(), SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
status = sigpending( &pending_set ); status = sigpending( &pending_set );
assert( !status ); rtems_test_assert( !status );
printf( "Init: Signals pending 0x%08x\n", (unsigned int) pending_set ); printf( "Init: Signals pending 0x%08x\n", (unsigned int) pending_set );
puts( "Init: sleep so the other task can catch signal" ); puts( "Init: sleep so the other task can catch signal" );
remaining = sleep( 1 ); remaining = sleep( 1 );
assert( !status ); rtems_test_assert( !status );
/* switch to task 1 */ /* switch to task 1 */
@@ -245,7 +245,7 @@ void *POSIX_Init(
/* install a signal handler for SIGALRM and unblock it */ /* install a signal handler for SIGALRM and unblock it */
status = sigemptyset( &act.sa_mask ); status = sigemptyset( &act.sa_mask );
assert( !status ); rtems_test_assert( !status );
act.sa_handler = Signal_handler; act.sa_handler = Signal_handler;
act.sa_flags = 0; act.sa_flags = 0;
@@ -253,65 +253,65 @@ void *POSIX_Init(
sigaction( SIGALRM, &act, NULL ); sigaction( SIGALRM, &act, NULL );
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGALRM ); status = sigaddset( &mask, SIGALRM );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Unblock SIGALRM" ); puts( "Init: Unblock SIGALRM" );
status = sigprocmask( SIG_UNBLOCK, &mask, NULL ); status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
assert( !status ); rtems_test_assert( !status );
/* schedule the alarm */ /* schedule the alarm */
puts( "Init: Firing alarm in 5 seconds" ); puts( "Init: Firing alarm in 5 seconds" );
remaining = alarm( 5 ); remaining = alarm( 5 );
printf( "Init: %d seconds left on previous alarm\n", status ); printf( "Init: %d seconds left on previous alarm\n", status );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Firing alarm in 2 seconds" ); puts( "Init: Firing alarm in 2 seconds" );
remaining = alarm( 2 ); remaining = alarm( 2 );
printf( "Init: %d seconds left on previous alarm\n", remaining ); printf( "Init: %d seconds left on previous alarm\n", remaining );
assert( remaining == 5 ); rtems_test_assert( remaining == 5 );
puts( "Init: Wait 4 seconds for alarm" ); puts( "Init: Wait 4 seconds for alarm" );
remaining = sleep( 4 ); remaining = sleep( 4 );
printf( "Init: %d seconds left in sleep\n", remaining ); printf( "Init: %d seconds left in sleep\n", remaining );
assert( remaining == 2 ); rtems_test_assert( remaining == 2 );
/* test SIG_SETMASK case and returning oset of pthread_sigmask */ /* test SIG_SETMASK case and returning oset of pthread_sigmask */
empty_line(); empty_line();
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGUSR1 ); status = sigaddset( &mask, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGUSR2 ); status = sigaddset( &mask, SIGUSR2 );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Block SIGUSR1 and SIGUSR2 only" ); puts( "Init: Block SIGUSR1 and SIGUSR2 only" );
status = pthread_sigmask( SIG_SETMASK, &mask, &oset ); status = pthread_sigmask( SIG_SETMASK, &mask, &oset );
printf( "Init: Previous blocked set was 0x%08x\n", (unsigned int) oset ); printf( "Init: Previous blocked set was 0x%08x\n", (unsigned int) oset );
assert( !status ); rtems_test_assert( !status );
/* test inquiry about current blocked set with pthread_sigmask */ /* test inquiry about current blocked set with pthread_sigmask */
status = pthread_sigmask( 0, NULL, &oset ); status = pthread_sigmask( 0, NULL, &oset );
printf( "Init: Current blocked set is 0x%08x\n", (unsigned int) oset ); printf( "Init: Current blocked set is 0x%08x\n", (unsigned int) oset );
assert( !status ); rtems_test_assert( !status );
/* return blocked mask to no signals blocked */ /* return blocked mask to no signals blocked */
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Unblock all signals" ); puts( "Init: Unblock all signals" );
status = pthread_sigmask( SIG_SETMASK, &mask, &oset ); status = pthread_sigmask( SIG_SETMASK, &mask, &oset );
printf( "Init: Previous blocked set was 0x%08x\n", (unsigned int) oset ); printf( "Init: Previous blocked set was 0x%08x\n", (unsigned int) oset );
assert( !status ); rtems_test_assert( !status );
/* test sigsuspend */ /* test sigsuspend */
@@ -319,14 +319,14 @@ void *POSIX_Init(
puts( "Init: create a thread to send Init SIGUSR1" ); puts( "Init: create a thread to send Init SIGUSR1" );
status = pthread_create( &Task2_id, NULL, Task_2, NULL ); status = pthread_create( &Task2_id, NULL, Task_2, NULL );
assert( !status ); rtems_test_assert( !status );
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
puts( "Init: sigsuspend for any signal" ); puts( "Init: sigsuspend for any signal" );
status = sigsuspend( &mask ); status = sigsuspend( &mask );
assert( status ); rtems_test_assert( status );
printf( "Init: awakended from sigsuspend status=%08d \n", status ); printf( "Init: awakended from sigsuspend status=%08d \n", status );
/* test a SIGINFO case, these are signals sent to a process only */ /* test a SIGINFO case, these are signals sent to a process only */
@@ -335,7 +335,7 @@ void *POSIX_Init(
puts( "Init: create a thread to sent Process SIGUSR1 with SA_SIGINFO" ); puts( "Init: create a thread to sent Process SIGUSR1 with SA_SIGINFO" );
status = pthread_create( &Task3_id, NULL, Task_3, NULL ); status = pthread_create( &Task3_id, NULL, Task_3, NULL );
assert( !status ); rtems_test_assert( !status );
/* set action on SIGUSR1 to an info case */ /* set action on SIGUSR1 to an info case */
act.sa_handler = Signal_handler; act.sa_handler = Signal_handler;
@@ -346,7 +346,7 @@ void *POSIX_Init(
puts( "Init: sleep so the Task_3 can sigqueue SIGUSR1" ); puts( "Init: sleep so the Task_3 can sigqueue SIGUSR1" );
remaining = sleep( 1 ); remaining = sleep( 1 );
assert( !status ); rtems_test_assert( !status );
/* switch to task 1 */ /* switch to task 1 */
@@ -355,68 +355,68 @@ void *POSIX_Init(
/* Send SIGUSR1, Task_3 has issued a sigwaitinfo */ /* Send SIGUSR1, Task_3 has issued a sigwaitinfo */
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGUSR1 ); status = sigaddset( &mask, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Block SIGUSR1" ); puts( "Init: Block SIGUSR1" );
status = sigprocmask( SIG_BLOCK, &mask, NULL ); status = sigprocmask( SIG_BLOCK, &mask, NULL );
assert( !status ); rtems_test_assert( !status );
puts( "Init: send SIGUSR1 to process" ); puts( "Init: send SIGUSR1 to process" );
status = kill( getpid(), SIGUSR1 ); status = kill( getpid(), SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
puts( "Init: sleep so the Task_3 can receive SIGUSR1" ); puts( "Init: sleep so the Task_3 can receive SIGUSR1" );
remaining = sleep( 1 ); remaining = sleep( 1 );
assert( !status ); rtems_test_assert( !status );
/* Send SIGUSR1, Task_3 has issued a sigwait */ /* Send SIGUSR1, Task_3 has issued a sigwait */
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGUSR1 ); status = sigaddset( &mask, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Block SIGUSR1" ); puts( "Init: Block SIGUSR1" );
status = sigprocmask( SIG_BLOCK, &mask, NULL ); status = sigprocmask( SIG_BLOCK, &mask, NULL );
assert( !status ); rtems_test_assert( !status );
puts( "Init: send SIGUSR1 to process" ); puts( "Init: send SIGUSR1 to process" );
status = kill( getpid(), SIGUSR1 ); status = kill( getpid(), SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
puts( "Init: sleep so the Task_3 can receive SIGUSR1" ); puts( "Init: sleep so the Task_3 can receive SIGUSR1" );
remaining = sleep( 1 ); remaining = sleep( 1 );
assert( !status ); rtems_test_assert( !status );
/* Send SIGUSR1, Task_3 has issued a sigwaitinfo */ /* Send SIGUSR1, Task_3 has issued a sigwaitinfo */
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGUSR2 ); status = sigaddset( &mask, SIGUSR2 );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Block SIGUSR2" ); puts( "Init: Block SIGUSR2" );
status = sigprocmask( SIG_BLOCK, &mask, NULL ); status = sigprocmask( SIG_BLOCK, &mask, NULL );
assert( !status ); rtems_test_assert( !status );
puts( "Init: send SIGUSR2 to process" ); puts( "Init: send SIGUSR2 to process" );
status = kill( getpid(), SIGUSR2 ); status = kill( getpid(), SIGUSR2 );
assert( !status ); rtems_test_assert( !status );
puts( "Init: sleep so the Task_3 can receive SIGUSR2" ); puts( "Init: sleep so the Task_3 can receive SIGUSR2" );
remaining = sleep( 1 ); remaining = sleep( 1 );
assert( !status ); rtems_test_assert( !status );
/* Suspend for signal that has already be sent */ /* Suspend for signal that has already be sent */
puts( "Init: sigsuspend for any signal" ); puts( "Init: sigsuspend for any signal" );
status = sigsuspend( &mask ); status = sigsuspend( &mask );
assert( status ); rtems_test_assert( status );
printf( "Init: awakended from sigsuspend status=%d \n", status ); printf( "Init: awakended from sigsuspend status=%d \n", status );
/* generate error cases for psignal */ /* generate error cases for psignal */
@@ -426,156 +426,156 @@ void *POSIX_Init(
status = sigemptyset( NULL ); status = sigemptyset( NULL );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: sigemptyset - EINVAL (set invalid)" ); puts( "Init: sigemptyset - EINVAL (set invalid)" );
status = sigfillset( NULL ); status = sigfillset( NULL );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: sigfillset - EINVAL (set invalid)" ); puts( "Init: sigfillset - EINVAL (set invalid)" );
status = sigaddset( NULL, SIGUSR1 ); status = sigaddset( NULL, SIGUSR1 );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: sigaddset - EINVAL (set invalid)" ); puts( "Init: sigaddset - EINVAL (set invalid)" );
status = sigaddset( &mask, 0 ); status = sigaddset( &mask, 0 );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: sigaddset - EINVAL (signal = 0)" ); puts( "Init: sigaddset - EINVAL (signal = 0)" );
status = sigaddset( &mask, 999 ); status = sigaddset( &mask, 999 );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: sigaddset - EINVAL (set invalid)" ); puts( "Init: sigaddset - EINVAL (set invalid)" );
status = sigdelset( NULL, SIGUSR1 ); status = sigdelset( NULL, SIGUSR1 );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: sigdelset - EINVAL (set invalid)" ); puts( "Init: sigdelset - EINVAL (set invalid)" );
status = sigdelset( &mask, 0 ); status = sigdelset( &mask, 0 );
assert( !status ); rtems_test_assert( !status );
puts( "Init: sigdelset - SUCCESSFUL (signal = 0)" ); puts( "Init: sigdelset - SUCCESSFUL (signal = 0)" );
status = sigdelset( &mask, 999 ); status = sigdelset( &mask, 999 );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: sigdelset - EINVAL (set invalid)" ); puts( "Init: sigdelset - EINVAL (set invalid)" );
status = sigismember( NULL, SIGUSR1 ); status = sigismember( NULL, SIGUSR1 );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: sigismember - EINVAL (set invalid)" ); puts( "Init: sigismember - EINVAL (set invalid)" );
status = sigismember( &mask, 0 ); status = sigismember( &mask, 0 );
assert( !status ); rtems_test_assert( !status );
puts( "Init: sigismember - SUCCESSFUL (signal = 0)" ); puts( "Init: sigismember - SUCCESSFUL (signal = 0)" );
status = sigismember( &mask, 999 ); status = sigismember( &mask, 999 );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: sigismember - EINVAL (signal invalid)" ); puts( "Init: sigismember - EINVAL (signal invalid)" );
status = sigaction( 0, &act, 0 ); status = sigaction( 0, &act, 0 );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: sigaction - EINVAL (signal = 0)" ); puts( "Init: sigaction - EINVAL (signal = 0)" );
status = sigaction( 999, &act, NULL ); status = sigaction( 999, &act, NULL );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: sigaction - EINVAL (signal invalid)" ); puts( "Init: sigaction - EINVAL (signal invalid)" );
status = sigaction( SIGKILL, &act, NULL ); status = sigaction( SIGKILL, &act, NULL );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: sigaction - EINVAL (SIGKILL)" ); puts( "Init: sigaction - EINVAL (SIGKILL)" );
status = pthread_sigmask( SIG_BLOCK, NULL, NULL ); status = pthread_sigmask( SIG_BLOCK, NULL, NULL );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: pthread_sigmask - EINVAL (set and oset invalid)" ); puts( "Init: pthread_sigmask - EINVAL (set and oset invalid)" );
status = pthread_sigmask( 999, &pending_set, NULL ); status = pthread_sigmask( 999, &pending_set, NULL );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: pthread_sigmask - EINVAL (how invalid)" ); puts( "Init: pthread_sigmask - EINVAL (how invalid)" );
status = sigpending( NULL ); status = sigpending( NULL );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: sigpending - EINVAL (set invalid)" ); puts( "Init: sigpending - EINVAL (set invalid)" );
timeout.tv_nsec = -1; timeout.tv_nsec = -1;
status = sigtimedwait( &mask, &info, &timeout ); status = sigtimedwait( &mask, &info, &timeout );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: pthread_sigmask - EINVAL (timout->nsec invalid < 0)" ); puts( "Init: pthread_sigmask - EINVAL (timout->nsec invalid < 0)" );
timeout.tv_nsec = 0x7fffffff; timeout.tv_nsec = 0x7fffffff;
status = sigtimedwait( &mask, &info, &timeout ); status = sigtimedwait( &mask, &info, &timeout );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: pthread_sigmask - EINVAL (timout->nsec invalid to large)" ); puts( "Init: pthread_sigmask - EINVAL (timout->nsec invalid to large)" );
status = pthread_kill( Init_id, 999 ); status = pthread_kill( Init_id, 999 );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: pthread_kill - EINVAL (sig invalid)" ); puts( "Init: pthread_kill - EINVAL (sig invalid)" );
status = pthread_kill( 0, SIGUSR2 ); status = pthread_kill( 0, SIGUSR2 );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == ESRCH ); rtems_test_assert( errno == ESRCH );
puts( "Init: pthread_kill - ESRCH (signal SA_SIGINFO)" ); puts( "Init: pthread_kill - ESRCH (signal SA_SIGINFO)" );
status = pthread_kill( Init_id, 0 ); status = pthread_kill( Init_id, 0 );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: pthread_kill - EINVAL (signal = 0)" ); puts( "Init: pthread_kill - EINVAL (signal = 0)" );
act.sa_handler = SIG_IGN; act.sa_handler = SIG_IGN;
act.sa_flags = 0; act.sa_flags = 0;
sigaction( SIGUSR2, &act, NULL ); sigaction( SIGUSR2, &act, NULL );
status = pthread_kill( Init_id, SIGUSR2 ); status = pthread_kill( Init_id, SIGUSR2 );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_kill - SUCCESSFUL (signal = SIG_IGN)" ); puts( "Init: pthread_kill - SUCCESSFUL (signal = SIG_IGN)" );
status = kill( INT_MAX, SIGUSR1 ); status = kill( INT_MAX, SIGUSR1 );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == ESRCH ); rtems_test_assert( errno == ESRCH );
puts( "Init: kill - ESRCH (pid invalid)" ); puts( "Init: kill - ESRCH (pid invalid)" );
status = kill( getpid(), 0 ); status = kill( getpid(), 0 );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: kill - EINVAL (signal = 0)" ); puts( "Init: kill - EINVAL (signal = 0)" );
status = kill( getpid(), 999 ); status = kill( getpid(), 999 );
if ( status != -1 ) if ( status != -1 )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "Init: kill - EINVAL (sig invalid)" ); puts( "Init: kill - EINVAL (sig invalid)" );
/* exit this thread */ /* exit this thread */

View File

@@ -30,7 +30,7 @@ void *Task_1(
seconds = sleep( 5 ); seconds = sleep( 5 );
printf( "Task_1: %d seconds left\n", seconds ); printf( "Task_1: %d seconds left\n", seconds );
assert( seconds ); rtems_test_assert( seconds );
/* switch to Init */ /* switch to Init */

View File

@@ -7,7 +7,7 @@
* *
* Output parameters: NONE * Output parameters: NONE
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -28,7 +28,7 @@ void *Task_2(
printf( "Task_2: sending SIGUSR1\n" ); printf( "Task_2: sending SIGUSR1\n" );
status = pthread_kill( Init_id, SIGUSR1 ); status = pthread_kill( Init_id, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
/* switch to Init */ /* switch to Init */

View File

@@ -35,24 +35,24 @@ void *Task_3(
printf( "Task_3: sigqueue SIGUSR1 with value= %d\n", value.sival_int ); printf( "Task_3: sigqueue SIGUSR1 with value= %d\n", value.sival_int );
status = sigqueue( getpid(), SIGUSR1, value ); status = sigqueue( getpid(), SIGUSR1, value );
assert( !status ); rtems_test_assert( !status );
/* catch signal with sigwaitinfo */ /* catch signal with sigwaitinfo */
empty_line(); empty_line();
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGUSR1 ); status = sigaddset( &mask, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
printf( "Task_3: sigwaitinfo SIGUSR1 with value= %d\n", value.sival_int ); printf( "Task_3: sigwaitinfo SIGUSR1 with value= %d\n", value.sival_int );
status = sigwaitinfo( &mask, &info ); status = sigwaitinfo( &mask, &info );
/* switch to Init */ /* switch to Init */
assert( !(status==-1) ); rtems_test_assert( !(status==-1) );
printf( printf(
"Task_3: si_signo= %d si_code= %d value= %d\n", "Task_3: si_signo= %d si_code= %d value= %d\n",
info.si_signo, info.si_signo,
@@ -65,17 +65,17 @@ void *Task_3(
empty_line(); empty_line();
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGUSR1 ); status = sigaddset( &mask, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
printf( "Task_3: sigwait SIGUSR1\n" ); printf( "Task_3: sigwait SIGUSR1\n" );
status = sigwait( &mask, &sig ); status = sigwait( &mask, &sig );
/* switch to Init */ /* switch to Init */
assert( !status ); rtems_test_assert( !status );
printf( "Task_3: signo= %d\n", sig ); printf( "Task_3: signo= %d\n", sig );
/* catch signal with pause */ /* catch signal with pause */
@@ -83,17 +83,17 @@ void *Task_3(
empty_line(); empty_line();
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGUSR1 ); status = sigaddset( &mask, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
printf( "Task_3: pause\n" ); printf( "Task_3: pause\n" );
status = pause( ); status = pause( );
/* switch to Init */ /* switch to Init */
assert( !(status==-1) ); rtems_test_assert( !(status==-1) );
printf( "Task_3: pause= %d\n", status ); printf( "Task_3: pause= %d\n", status );
@@ -103,11 +103,11 @@ void *Task_3(
printf( "Task_3: sending SIGUSR2\n" ); printf( "Task_3: sending SIGUSR2\n" );
status = pthread_kill( Init_id, SIGUSR2 ); status = pthread_kill( Init_id, SIGUSR2 );
assert( !status ); rtems_test_assert( !status );
printf( "Task_3: sleep so the Init task can reguest a signal\n" ); printf( "Task_3: sleep so the Init task can reguest a signal\n" );
remaining = sleep( 1 ); remaining = sleep( 1 );
assert( !status ); rtems_test_assert( !status );
/* end of task 3 */ /* end of task 3 */
printf( "Task_3: exit\n" ); printf( "Task_3: exit\n" );

View File

@@ -42,7 +42,7 @@ void Print_mutexattr(
/* protocol */ /* protocol */
status = pthread_mutexattr_getprotocol( attr, &protocol ); status = pthread_mutexattr_getprotocol( attr, &protocol );
assert( !status ); rtems_test_assert( !status );
printf( "%smutex protocol is (%d) -- ", msg, protocol ); printf( "%smutex protocol is (%d) -- ", msg, protocol );
switch ( protocol ) { switch ( protocol ) {
@@ -57,20 +57,20 @@ void Print_mutexattr(
break; break;
default: default:
puts( "UNKNOWN" ); puts( "UNKNOWN" );
assert( 0 ); rtems_test_assert( 0 );
break; break;
} }
/* priority ceiling */ /* priority ceiling */
status = pthread_mutexattr_getprioceiling( attr, &prioceiling ); status = pthread_mutexattr_getprioceiling( attr, &prioceiling );
assert( !status ); rtems_test_assert( !status );
printf( "%smutex priority ceiling is %d\n", msg, prioceiling ); printf( "%smutex priority ceiling is %d\n", msg, prioceiling );
/* process shared */ /* process shared */
status = pthread_mutexattr_getpshared( attr, &pshared ); status = pthread_mutexattr_getpshared( attr, &pshared );
assert( !status ); rtems_test_assert( !status );
printf( "%smutex process shared is (%d) -- ", msg, pshared ); printf( "%smutex process shared is (%d) -- ", msg, pshared );
switch ( pshared ) { switch ( pshared ) {
case PTHREAD_PROCESS_PRIVATE: case PTHREAD_PROCESS_PRIVATE:
@@ -81,7 +81,7 @@ void Print_mutexattr(
break; break;
default: default:
puts( "UNKNOWN" ); puts( "UNKNOWN" );
assert( 0 ); rtems_test_assert( 0 );
break; break;
} }
} }
@@ -123,7 +123,7 @@ void *POSIX_Init(
int old_ceiling; int old_ceiling;
int priority; int priority;
assert( MUTEX_BAD_ID != PTHREAD_MUTEX_INITIALIZER ); rtems_test_assert( MUTEX_BAD_ID != PTHREAD_MUTEX_INITIALIZER );
Mutex_bad_id = MUTEX_BAD_ID; Mutex_bad_id = MUTEX_BAD_ID;
puts( "\n\n*** POSIX TEST 5 ***" ); puts( "\n\n*** POSIX TEST 5 ***" );
@@ -141,30 +141,30 @@ void *POSIX_Init(
puts( "Init: pthread_mutexattr_init - EINVAL (NULL attr)" ); puts( "Init: pthread_mutexattr_init - EINVAL (NULL attr)" );
status = pthread_mutexattr_init( NULL ); status = pthread_mutexattr_init( NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutexattr_init - SUCCESSFUL" ); puts( "Init: pthread_mutexattr_init - SUCCESSFUL" );
status = pthread_mutexattr_init( &attr ); status = pthread_mutexattr_init( &attr );
assert( !status ); rtems_test_assert( !status );
Print_mutexattr( "Init: ", &attr ); Print_mutexattr( "Init: ", &attr );
/* create an "uninitialized" attribute structure */ /* create an "uninitialized" attribute structure */
status = pthread_mutexattr_init( &destroyed_attr ); status = pthread_mutexattr_init( &destroyed_attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutexattr_destroy - SUCCESSFUL" ); puts( "Init: pthread_mutexattr_destroy - SUCCESSFUL" );
status = pthread_mutexattr_destroy( &destroyed_attr ); status = pthread_mutexattr_destroy( &destroyed_attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutexattr_destroy - EINVAL (NULL attr)" ); puts( "Init: pthread_mutexattr_destroy - EINVAL (NULL attr)" );
status = pthread_mutexattr_destroy( NULL ); status = pthread_mutexattr_destroy( NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutexattr_destroy - EINVAL (not initialized)" ); puts( "Init: pthread_mutexattr_destroy - EINVAL (not initialized)" );
status = pthread_mutexattr_destroy( &destroyed_attr ); status = pthread_mutexattr_destroy( &destroyed_attr );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* error cases for set and get pshared attribute */ /* error cases for set and get pshared attribute */
@@ -172,25 +172,25 @@ void *POSIX_Init(
puts( "Init: pthread_mutexattr_getpshared - EINVAL (NULL attr)" ); puts( "Init: pthread_mutexattr_getpshared - EINVAL (NULL attr)" );
status = pthread_mutexattr_getpshared( NULL, &pshared ); status = pthread_mutexattr_getpshared( NULL, &pshared );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutexattr_getpshared - EINVAL (NULL pshared)" ); puts( "Init: pthread_mutexattr_getpshared - EINVAL (NULL pshared)" );
status = pthread_mutexattr_getpshared( &attr, NULL ); status = pthread_mutexattr_getpshared( &attr, NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutexattr_getpshared - EINVAL (not initialized)" ); puts( "Init: pthread_mutexattr_getpshared - EINVAL (not initialized)" );
status = pthread_mutexattr_getpshared( &destroyed_attr, &pshared ); status = pthread_mutexattr_getpshared( &destroyed_attr, &pshared );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
pshared = PTHREAD_PROCESS_PRIVATE; pshared = PTHREAD_PROCESS_PRIVATE;
puts( "Init: pthread_mutexattr_setpshared - EINVAL (NULL attr)" ); puts( "Init: pthread_mutexattr_setpshared - EINVAL (NULL attr)" );
status = pthread_mutexattr_setpshared( NULL, pshared ); status = pthread_mutexattr_setpshared( NULL, pshared );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
pshared = PTHREAD_PROCESS_PRIVATE; pshared = PTHREAD_PROCESS_PRIVATE;
puts( "Init: pthread_mutexattr_setpshared - EINVAL (not initialized)" ); puts( "Init: pthread_mutexattr_setpshared - EINVAL (not initialized)" );
status = pthread_mutexattr_setpshared( &destroyed_attr, pshared ); status = pthread_mutexattr_setpshared( &destroyed_attr, pshared );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* error cases for set and get protocol attribute */ /* error cases for set and get protocol attribute */
@@ -198,27 +198,27 @@ void *POSIX_Init(
puts( "Init: pthread_mutexattr_getprotocol - EINVAL (NULL attr)" ); puts( "Init: pthread_mutexattr_getprotocol - EINVAL (NULL attr)" );
status = pthread_mutexattr_getprotocol( NULL, &protocol ); status = pthread_mutexattr_getprotocol( NULL, &protocol );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutexattr_getprotocol - EINVAL (NULL protocol)" ); puts( "Init: pthread_mutexattr_getprotocol - EINVAL (NULL protocol)" );
status = pthread_mutexattr_getprotocol( &attr, NULL ); status = pthread_mutexattr_getprotocol( &attr, NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutexattr_getprotocol - EINVAL (not initialized)" ); puts( "Init: pthread_mutexattr_getprotocol - EINVAL (not initialized)" );
status = pthread_mutexattr_getprotocol( &destroyed_attr, &protocol ); status = pthread_mutexattr_getprotocol( &destroyed_attr, &protocol );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutexattr_setprotocol - EINVAL (NULL attr)" ); puts( "Init: pthread_mutexattr_setprotocol - EINVAL (NULL attr)" );
status = pthread_mutexattr_setprotocol( NULL, PTHREAD_PRIO_NONE ); status = pthread_mutexattr_setprotocol( NULL, PTHREAD_PRIO_NONE );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutexattr_setprotocol - EINVAL (invalid protocol)" ); puts( "Init: pthread_mutexattr_setprotocol - EINVAL (invalid protocol)" );
status = pthread_mutexattr_setprotocol( &attr, -1 ); status = pthread_mutexattr_setprotocol( &attr, -1 );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutexattr_setprotocol - EINVAL (not initialized)" ); puts( "Init: pthread_mutexattr_setprotocol - EINVAL (not initialized)" );
status = pthread_mutexattr_setprotocol( &destroyed_attr, -1 ); status = pthread_mutexattr_setprotocol( &destroyed_attr, -1 );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* error cases for set and get prioceiling attribute */ /* error cases for set and get prioceiling attribute */
@@ -226,34 +226,34 @@ void *POSIX_Init(
puts( "Init: pthread_mutexattr_getprioceiling - EINVAL (NULL attr)" ); puts( "Init: pthread_mutexattr_getprioceiling - EINVAL (NULL attr)" );
status = pthread_mutexattr_getprioceiling( NULL, &ceiling ); status = pthread_mutexattr_getprioceiling( NULL, &ceiling );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutexattr_getprioceiling - EINVAL (NULL prioceiling)" ); puts( "Init: pthread_mutexattr_getprioceiling - EINVAL (NULL prioceiling)" );
status = pthread_mutexattr_getprioceiling( &attr, NULL ); status = pthread_mutexattr_getprioceiling( &attr, NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutexattr_getprioceiling - EINVAL (not initialized)" ); puts( "Init: pthread_mutexattr_getprioceiling - EINVAL (not initialized)" );
status = pthread_mutexattr_getprioceiling( &destroyed_attr, &ceiling ); status = pthread_mutexattr_getprioceiling( &destroyed_attr, &ceiling );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutexattr_setprioceiling - EINVAL (NULL attr)" ); puts( "Init: pthread_mutexattr_setprioceiling - EINVAL (NULL attr)" );
status = pthread_mutexattr_setprioceiling( NULL, 128 ); status = pthread_mutexattr_setprioceiling( NULL, 128 );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutexattr_setprioceiling - EINVAL (invalid priority)" ); puts( "Init: pthread_mutexattr_setprioceiling - EINVAL (invalid priority)" );
status = pthread_mutexattr_setprioceiling( &attr, 512 ); status = pthread_mutexattr_setprioceiling( &attr, 512 );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutexattr_setprioceiling - EINVAL (not initialized)" ); puts( "Init: pthread_mutexattr_setprioceiling - EINVAL (not initialized)" );
status = pthread_mutexattr_setprioceiling( &destroyed_attr, -1 ); status = pthread_mutexattr_setprioceiling( &destroyed_attr, -1 );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* create a thread */ /* create a thread */
status = pthread_create( &Task_id, NULL, Task_1, NULL ); status = pthread_create( &Task_id, NULL, Task_1, NULL );
assert( !status ); rtems_test_assert( !status );
/* now try some basic mutex operations */ /* now try some basic mutex operations */
@@ -261,18 +261,18 @@ void *POSIX_Init(
puts( "Init: pthread_mutex_init - EINVAL (NULL mutex_id)" ); puts( "Init: pthread_mutex_init - EINVAL (NULL mutex_id)" );
status = pthread_mutex_init( NULL, &attr ); status = pthread_mutex_init( NULL, &attr );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutex_init - EINVAL (not initialized attr)" ); puts( "Init: pthread_mutex_init - EINVAL (not initialized attr)" );
status = pthread_mutex_init( &Mutex_id, &destroyed_attr ); status = pthread_mutex_init( &Mutex_id, &destroyed_attr );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* must get around error checks in attribute set routines */ /* must get around error checks in attribute set routines */
attr.protocol = -1; attr.protocol = -1;
puts( "Init: pthread_mutex_init - EINVAL (bad protocol)" ); puts( "Init: pthread_mutex_init - EINVAL (bad protocol)" );
status = pthread_mutex_init( &Mutex_id, &attr ); status = pthread_mutex_init( &Mutex_id, &attr );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* must get around error checks in attribute set routines */ /* must get around error checks in attribute set routines */
attr.protocol = PTHREAD_PRIO_INHERIT; attr.protocol = PTHREAD_PRIO_INHERIT;
@@ -280,56 +280,56 @@ void *POSIX_Init(
puts( "Init: pthread_mutex_init - EINVAL (bad priority ceiling)" ); puts( "Init: pthread_mutex_init - EINVAL (bad priority ceiling)" );
status = pthread_mutex_init( &Mutex_id, &attr ); status = pthread_mutex_init( &Mutex_id, &attr );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* must get around various error checks before checking bad scope */ /* must get around various error checks before checking bad scope */
puts( "Init: Resetting mutex attributes" ); puts( "Init: Resetting mutex attributes" );
status = pthread_mutexattr_init( &attr ); status = pthread_mutexattr_init( &attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_init - ENOSYS (process wide scope)" ); puts( "Init: pthread_mutex_init - ENOSYS (process wide scope)" );
attr.process_shared = PTHREAD_PROCESS_SHARED; attr.process_shared = PTHREAD_PROCESS_SHARED;
status = pthread_mutex_init( &Mutex_id, &attr ); status = pthread_mutex_init( &Mutex_id, &attr );
assert( status == ENOSYS ); rtems_test_assert( status == ENOSYS );
puts( "Init: pthread_mutex_init - EINVAL (invalid scope)" ); puts( "Init: pthread_mutex_init - EINVAL (invalid scope)" );
attr.process_shared = -1; attr.process_shared = -1;
status = pthread_mutex_init( &Mutex_id, &attr ); status = pthread_mutex_init( &Mutex_id, &attr );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* bad kind */ /* bad kind */
status = pthread_mutexattr_init( &attr ); status = pthread_mutexattr_init( &attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_init - EINVAL (invalid type)" ); puts( "Init: pthread_mutex_init - EINVAL (invalid type)" );
attr.type = -1; attr.type = -1;
status = pthread_mutex_init( &Mutex_id, &attr ); status = pthread_mutex_init( &Mutex_id, &attr );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* now set up for a success pthread_mutex_init */ /* now set up for a success pthread_mutex_init */
puts( "Init: Resetting mutex attributes" ); puts( "Init: Resetting mutex attributes" );
status = pthread_mutexattr_init( &attr ); status = pthread_mutexattr_init( &attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Changing mutex attributes" ); puts( "Init: Changing mutex attributes" );
status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT ); status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT );
assert( !status ); rtems_test_assert( !status );
status = pthread_mutexattr_setprioceiling( status = pthread_mutexattr_setprioceiling(
&attr, &attr,
(sched_get_priority_max(SCHED_FIFO) / 2) + 1 (sched_get_priority_max(SCHED_FIFO) / 2) + 1
); );
assert( !status ); rtems_test_assert( !status );
status = pthread_mutexattr_setpshared( &attr, PTHREAD_PROCESS_SHARED ); status = pthread_mutexattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
assert( !status ); rtems_test_assert( !status );
Print_mutexattr( "Init: ", &attr ); Print_mutexattr( "Init: ", &attr );
puts( "Init: Resetting mutex attributes" ); puts( "Init: Resetting mutex attributes" );
status = pthread_mutexattr_init( &attr ); status = pthread_mutexattr_init( &attr );
assert( !status ); rtems_test_assert( !status );
/* /*
* Set the protocol to priority ceiling so the owner check happens * Set the protocol to priority ceiling so the owner check happens
@@ -337,13 +337,13 @@ void *POSIX_Init(
*/ */
status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT ); status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_init - SUCCESSFUL" ); puts( "Init: pthread_mutex_init - SUCCESSFUL" );
status = pthread_mutex_init( &Mutex_id, &attr ); status = pthread_mutex_init( &Mutex_id, &attr );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
/* /*
* This is not required to be an error and when it is, there are * This is not required to be an error and when it is, there are
@@ -355,44 +355,44 @@ void *POSIX_Init(
status = pthread_mutex_init( &Mutex_id, &attr ); status = pthread_mutex_init( &Mutex_id, &attr );
if ( !status ) if ( !status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EBUSY ); rtems_test_assert( status == EBUSY );
#endif #endif
puts( "Init: pthread_mutex_trylock - EINVAL (illegal ID)" ); puts( "Init: pthread_mutex_trylock - EINVAL (illegal ID)" );
status = pthread_mutex_trylock( &Mutex_bad_id ); status = pthread_mutex_trylock( &Mutex_bad_id );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutex_trylock - SUCCESSFUL" ); puts( "Init: pthread_mutex_trylock - SUCCESSFUL" );
status = pthread_mutex_trylock( &Mutex_id ); status = pthread_mutex_trylock( &Mutex_id );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_trylock - EDEADLK (already locked)" ); puts( "Init: pthread_mutex_trylock - EDEADLK (already locked)" );
status = pthread_mutex_trylock( &Mutex_id ); status = pthread_mutex_trylock( &Mutex_id );
if ( status != EDEADLK ) if ( status != EDEADLK )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EDEADLK ); rtems_test_assert( status == EDEADLK );
puts( "Init: pthread_mutex_lock - EINVAL (NULL id)" ); puts( "Init: pthread_mutex_lock - EINVAL (NULL id)" );
status = pthread_mutex_lock( NULL ); status = pthread_mutex_lock( NULL );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutex_unlock - EINVAL (NULL id)" ); puts( "Init: pthread_mutex_unlock - EINVAL (NULL id)" );
status = pthread_mutex_unlock( NULL ); status = pthread_mutex_unlock( NULL );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutex_lock - EDEADLK (already locked)" ); puts( "Init: pthread_mutex_lock - EDEADLK (already locked)" );
status = pthread_mutex_lock( &Mutex_id ); status = pthread_mutex_lock( &Mutex_id );
if ( status != EDEADLK ) if ( status != EDEADLK )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EDEADLK ); rtems_test_assert( status == EDEADLK );
puts( "Init: Sleep 1 second" ); puts( "Init: Sleep 1 second" );
@@ -404,19 +404,19 @@ void *POSIX_Init(
status = pthread_mutex_unlock( &Mutex_bad_id ); status = pthread_mutex_unlock( &Mutex_bad_id );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutex_unlock - SUCCESSFUL" ); puts( "Init: pthread_mutex_unlock - SUCCESSFUL" );
status = pthread_mutex_unlock( &Mutex_id ); status = pthread_mutex_unlock( &Mutex_id );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_unlock - EPERM (not owner)" ); puts( "Init: pthread_mutex_unlock - EPERM (not owner)" );
status = pthread_mutex_unlock( &Mutex_id ); status = pthread_mutex_unlock( &Mutex_id );
if ( status != EPERM ) if ( status != EPERM )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EPERM ); rtems_test_assert( status == EPERM );
puts( "Init: pthread_mutex_timedlock - time out in 1/2 second" ); puts( "Init: pthread_mutex_timedlock - time out in 1/2 second" );
calculate_abstimeout( &times, 0, (TOD_NANOSECONDS_PER_SECOND / 2) ); calculate_abstimeout( &times, 0, (TOD_NANOSECONDS_PER_SECOND / 2) );
@@ -424,7 +424,7 @@ void *POSIX_Init(
status = pthread_mutex_timedlock( &Mutex_id, &times ); status = pthread_mutex_timedlock( &Mutex_id, &times );
if ( status != ETIMEDOUT ) if ( status != ETIMEDOUT )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == ETIMEDOUT ); rtems_test_assert( status == ETIMEDOUT );
puts( "Init: pthread_mutex_timedlock - time out in the past" ); puts( "Init: pthread_mutex_timedlock - time out in the past" );
calculate_abstimeout( &times, -1, (TOD_NANOSECONDS_PER_SECOND / 2) ); calculate_abstimeout( &times, -1, (TOD_NANOSECONDS_PER_SECOND / 2) );
@@ -432,7 +432,7 @@ void *POSIX_Init(
status = pthread_mutex_timedlock( &Mutex_id, &times ); status = pthread_mutex_timedlock( &Mutex_id, &times );
if ( status != EBUSY ) if ( status != EBUSY )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EBUSY ); rtems_test_assert( status == EBUSY );
/* switch to idle */ /* switch to idle */
@@ -446,23 +446,23 @@ void *POSIX_Init(
status = pthread_mutex_init( &Mutex2_id, &attr ); status = pthread_mutex_init( &Mutex2_id, &attr );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_init - EAGAIN (too many)" ); puts( "Init: pthread_mutex_init - EAGAIN (too many)" );
status = pthread_mutex_init( &Mutex3_id, &attr ); status = pthread_mutex_init( &Mutex3_id, &attr );
assert( status == EAGAIN ); rtems_test_assert( status == EAGAIN );
puts( "Init: pthread_mutexattr_destroy - SUCCESSFUL" ); puts( "Init: pthread_mutexattr_destroy - SUCCESSFUL" );
status = pthread_mutexattr_destroy( &attr ); status = pthread_mutexattr_destroy( &attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_destroy - SUCCESSFUL" ); puts( "Init: pthread_mutex_destroy - SUCCESSFUL" );
status = pthread_mutex_destroy( &Mutex2_id ); status = pthread_mutex_destroy( &Mutex2_id );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_destroy - EINVAL (invalid id)" ); puts( "Init: pthread_mutex_destroy - EINVAL (invalid id)" );
status = pthread_mutex_destroy( &Mutex_bad_id ); status = pthread_mutex_destroy( &Mutex_bad_id );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* destroy a busy mutex */ /* destroy a busy mutex */
@@ -470,31 +470,31 @@ void *POSIX_Init(
puts( "Init: pthread_mutexattr_init - SUCCESSFUL" ); puts( "Init: pthread_mutexattr_init - SUCCESSFUL" );
status = pthread_mutexattr_init( &attr ); status = pthread_mutexattr_init( &attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_init - SUCCESSFUL" ); puts( "Init: pthread_mutex_init - SUCCESSFUL" );
status = pthread_mutex_init( &Mutex2_id, &attr ); status = pthread_mutex_init( &Mutex2_id, &attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_trylock - SUCCESSFUL" ); puts( "Init: pthread_mutex_trylock - SUCCESSFUL" );
status = pthread_mutex_trylock( &Mutex2_id ); status = pthread_mutex_trylock( &Mutex2_id );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_destroy - EBUSY (already locked)" ); puts( "Init: pthread_mutex_destroy - EBUSY (already locked)" );
status = pthread_mutex_destroy( &Mutex2_id ); status = pthread_mutex_destroy( &Mutex2_id );
if ( status != EBUSY ) if ( status != EBUSY )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EBUSY ); rtems_test_assert( status == EBUSY );
puts( "Init: pthread_mutex_unlock - SUCCESSFUL" ); puts( "Init: pthread_mutex_unlock - SUCCESSFUL" );
status = pthread_mutex_unlock( &Mutex2_id ); status = pthread_mutex_unlock( &Mutex2_id );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_destroy - SUCCESSFUL" ); puts( "Init: pthread_mutex_destroy - SUCCESSFUL" );
status = pthread_mutex_destroy( &Mutex2_id ); status = pthread_mutex_destroy( &Mutex2_id );
assert( !status ); rtems_test_assert( !status );
/* priority inherit mutex */ /* priority inherit mutex */
@@ -502,26 +502,26 @@ void *POSIX_Init(
puts( "Init: pthread_mutexattr_init - SUCCESSFUL" ); puts( "Init: pthread_mutexattr_init - SUCCESSFUL" );
status = pthread_mutexattr_init( &attr ); status = pthread_mutexattr_init( &attr );
assert( !status ); rtems_test_assert( !status );
puts( puts(
"Init: pthread_mutexattr_setprotocol - SUCCESSFUL (PTHREAD_PRIO_INHERIT)" "Init: pthread_mutexattr_setprotocol - SUCCESSFUL (PTHREAD_PRIO_INHERIT)"
); );
status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT ); status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_init - SUCCESSFUL" ); puts( "Init: pthread_mutex_init - SUCCESSFUL" );
status = pthread_mutex_init( &Mutex2_id, &attr ); status = pthread_mutex_init( &Mutex2_id, &attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_trylock - SUCCESSFUL" ); puts( "Init: pthread_mutex_trylock - SUCCESSFUL" );
status = pthread_mutex_trylock( &Mutex2_id ); status = pthread_mutex_trylock( &Mutex2_id );
assert( !status ); rtems_test_assert( !status );
/* create a thread at a lower priority */ /* create a thread at a lower priority */
status = pthread_create( &Task2_id, NULL, Task_2, NULL ); status = pthread_create( &Task2_id, NULL, Task_2, NULL );
assert( !status ); rtems_test_assert( !status );
/* set priority of Task2 to highest priority */ /* set priority of Task2 to highest priority */
@@ -529,25 +529,25 @@ void *POSIX_Init(
puts( "Init: pthread_setschedparam - Setting Task2 priority to highest" ); puts( "Init: pthread_setschedparam - Setting Task2 priority to highest" );
status = pthread_setschedparam( Task2_id, SCHED_FIFO, &param ); status = pthread_setschedparam( Task2_id, SCHED_FIFO, &param );
assert( !status ); rtems_test_assert( !status );
/* switching to Task2 */ /* switching to Task2 */
status = pthread_getschedparam( pthread_self(), &policy, &param ); status = pthread_getschedparam( pthread_self(), &policy, &param );
assert( !status ); rtems_test_assert( !status );
printf( "Init: pthread_getschedparam - priority = %d\n", param.sched_priority); printf( "Init: pthread_getschedparam - priority = %d\n", param.sched_priority);
puts( "Init: pthread_mutex_unlock - SUCCESSFUL" ); puts( "Init: pthread_mutex_unlock - SUCCESSFUL" );
status = pthread_mutex_unlock( &Mutex2_id ); status = pthread_mutex_unlock( &Mutex2_id );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutexattr_destroy - SUCCESSFUL" ); puts( "Init: pthread_mutexattr_destroy - SUCCESSFUL" );
status = pthread_mutexattr_destroy( &attr ); status = pthread_mutexattr_destroy( &attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_destroy - SUCCESSFUL" ); puts( "Init: pthread_mutex_destroy - SUCCESSFUL" );
status = pthread_mutex_destroy( &Mutex2_id ); status = pthread_mutex_destroy( &Mutex2_id );
assert( !status ); rtems_test_assert( !status );
/* priority ceiling mutex */ /* priority ceiling mutex */
@@ -555,41 +555,41 @@ void *POSIX_Init(
puts( "Init: pthread_mutexattr_init - SUCCESSFUL" ); puts( "Init: pthread_mutexattr_init - SUCCESSFUL" );
status = pthread_mutexattr_init( &attr ); status = pthread_mutexattr_init( &attr );
assert( !status ); rtems_test_assert( !status );
puts( puts(
"Init: pthread_mutexattr_setprotocol - SUCCESSFUL (PTHREAD_PRIO_PROTECT)" "Init: pthread_mutexattr_setprotocol - SUCCESSFUL (PTHREAD_PRIO_PROTECT)"
); );
status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_PROTECT ); status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_PROTECT );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_init - SUCCESSFUL" ); puts( "Init: pthread_mutex_init - SUCCESSFUL" );
status = pthread_mutex_init( &Mutex2_id, &attr ); status = pthread_mutex_init( &Mutex2_id, &attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_mutex_getprioceiling - EINVAL (invalid id)" ); puts( "Init: pthread_mutex_getprioceiling - EINVAL (invalid id)" );
status = pthread_mutex_getprioceiling( &Mutex_bad_id, &ceiling ); status = pthread_mutex_getprioceiling( &Mutex_bad_id, &ceiling );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutex_getprioceiling - EINVAL (NULL ceiling)" ); puts( "Init: pthread_mutex_getprioceiling - EINVAL (NULL ceiling)" );
status = pthread_mutex_getprioceiling( &Mutex2_id, NULL ); status = pthread_mutex_getprioceiling( &Mutex2_id, NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
status = pthread_mutex_getprioceiling( &Mutex2_id, &ceiling ); status = pthread_mutex_getprioceiling( &Mutex2_id, &ceiling );
assert( !status ); rtems_test_assert( !status );
printf( "Init: pthread_mutex_getprioceiling - %d\n", ceiling ); printf( "Init: pthread_mutex_getprioceiling - %d\n", ceiling );
puts( "Init: pthread_mutex_setprioceiling - EINVAL (invalid id)" ); puts( "Init: pthread_mutex_setprioceiling - EINVAL (invalid id)" );
status = pthread_mutex_setprioceiling( &Mutex_bad_id, 200, &old_ceiling ); status = pthread_mutex_setprioceiling( &Mutex_bad_id, 200, &old_ceiling );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutex_setprioceiling - EINVAL (illegal priority)" ); puts( "Init: pthread_mutex_setprioceiling - EINVAL (illegal priority)" );
status = pthread_mutex_setprioceiling( &Mutex2_id, 512, &old_ceiling ); status = pthread_mutex_setprioceiling( &Mutex2_id, 512, &old_ceiling );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_mutex_setprioceiling - EINVAL (NULL ceiling)" ); puts( "Init: pthread_mutex_setprioceiling - EINVAL (NULL ceiling)" );
status = pthread_mutex_setprioceiling( &Mutex2_id, 128, NULL ); status = pthread_mutex_setprioceiling( &Mutex2_id, 128, NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* normal cases of set priority ceiling */ /* normal cases of set priority ceiling */
@@ -598,23 +598,23 @@ void *POSIX_Init(
printf( "Init: pthread_mutex_setprioceiling - new ceiling = %d\n", priority ); printf( "Init: pthread_mutex_setprioceiling - new ceiling = %d\n", priority );
status = pthread_mutex_setprioceiling( &Mutex2_id, priority, &old_ceiling ); status = pthread_mutex_setprioceiling( &Mutex2_id, priority, &old_ceiling );
assert( !status ); rtems_test_assert( !status );
printf( printf(
"Init: pthread_mutex_setprioceiling - old ceiling = %d\n",old_ceiling "Init: pthread_mutex_setprioceiling - old ceiling = %d\n",old_ceiling
); );
status = pthread_getschedparam( pthread_self(), &policy, &param ); status = pthread_getschedparam( pthread_self(), &policy, &param );
assert( !status ); rtems_test_assert( !status );
printf( printf(
"Init: pthread_getschedparam - priority = %d\n", param.sched_priority "Init: pthread_getschedparam - priority = %d\n", param.sched_priority
); );
puts( "Init: pthread_mutex_trylock - SUCCESSFUL" ); puts( "Init: pthread_mutex_trylock - SUCCESSFUL" );
status = pthread_mutex_trylock( &Mutex2_id ); status = pthread_mutex_trylock( &Mutex2_id );
assert( !status ); rtems_test_assert( !status );
status = pthread_getschedparam( pthread_self(), &policy, &param ); status = pthread_getschedparam( pthread_self(), &policy, &param );
assert( !status ); rtems_test_assert( !status );
printf( printf(
"Init: pthread_getschedparam - priority = %d\n", param.sched_priority "Init: pthread_getschedparam - priority = %d\n", param.sched_priority
); );
@@ -622,30 +622,30 @@ void *POSIX_Init(
/* create a thread at a higher priority */ /* create a thread at a higher priority */
status = pthread_create( &Task3_id, NULL, Task_3, NULL ); status = pthread_create( &Task3_id, NULL, Task_3, NULL );
assert( !status ); rtems_test_assert( !status );
/* set priority of Task3 to highest priority */ /* set priority of Task3 to highest priority */
param.sched_priority = --priority; param.sched_priority = --priority;
status = pthread_setschedparam( Task3_id, SCHED_FIFO, &param ); status = pthread_setschedparam( Task3_id, SCHED_FIFO, &param );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_setschedparam - set Task3 priority to highest" ); puts( "Init: pthread_setschedparam - set Task3 priority to highest" );
/* DOES NOT SWITCH to Task3 */ /* DOES NOT SWITCH to Task3 */
puts( "Init: Sleep 1 second" ); puts( "Init: Sleep 1 second" );
assert( !status ); rtems_test_assert( !status );
sleep( 1 ); sleep( 1 );
/* switch to task 3 */ /* switch to task 3 */
puts( "Init: pthread_mutex_unlock - SUCCESSFUL" ); puts( "Init: pthread_mutex_unlock - SUCCESSFUL" );
status = pthread_mutex_unlock( &Mutex2_id ); status = pthread_mutex_unlock( &Mutex2_id );
assert( !status ); rtems_test_assert( !status );
status = pthread_mutex_getprioceiling( &Mutex2_id, &ceiling ); status = pthread_mutex_getprioceiling( &Mutex2_id, &ceiling );
assert( !status ); rtems_test_assert( !status );
printf( "Init: pthread_mutex_getprioceiling- ceiling = %d\n", ceiling ); printf( "Init: pthread_mutex_getprioceiling- ceiling = %d\n", ceiling );
/* set priority of Init to highest priority */ /* set priority of Init to highest priority */
@@ -653,14 +653,14 @@ void *POSIX_Init(
param.sched_priority = sched_get_priority_max(SCHED_FIFO); param.sched_priority = sched_get_priority_max(SCHED_FIFO);
status = pthread_setschedparam( Init_id, SCHED_FIFO, &param ); status = pthread_setschedparam( Init_id, SCHED_FIFO, &param );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_setschedparam - set Init priority to highest" ); puts( "Init: pthread_setschedparam - set Init priority to highest" );
puts( "Init: pthread_mutex_lock - EINVAL (priority ceiling violation)" ); puts( "Init: pthread_mutex_lock - EINVAL (priority ceiling violation)" );
status = pthread_mutex_lock( &Mutex2_id ); status = pthread_mutex_lock( &Mutex2_id );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* mutexinit.c: Initialising recursive mutex */ /* mutexinit.c: Initialising recursive mutex */
@@ -678,7 +678,7 @@ void *POSIX_Init(
status = pthread_mutex_init( &Mutex2_id, &attr ); status = pthread_mutex_init( &Mutex2_id, &attr );
if ( status ) if ( status )
printf( "status recursive mutex :%d\n", status ); printf( "status recursive mutex :%d\n", status );
assert( !status ); rtems_test_assert( !status );
puts( "*** END OF POSIX TEST 5 ***" ); puts( "*** END OF POSIX TEST 5 ***" );
rtems_test_exit( 0 ); rtems_test_exit( 0 );

View File

@@ -8,7 +8,7 @@
* *
* Output parameters: NONE * Output parameters: NONE
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -31,13 +31,13 @@ void *Task_1(
status = pthread_mutex_trylock( &Mutex_id ); status = pthread_mutex_trylock( &Mutex_id );
if ( status != EBUSY ) if ( status != EBUSY )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EBUSY ); rtems_test_assert( status == EBUSY );
printf( "Task: pthread_mutex_lock unavailable\n" ); printf( "Task: pthread_mutex_lock unavailable\n" );
status = pthread_mutex_lock( &Mutex_id ); status = pthread_mutex_lock( &Mutex_id );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
/* switch to init */ /* switch to init */

View File

@@ -7,7 +7,7 @@
* *
* Output parameters: NONE * Output parameters: NONE
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -30,14 +30,14 @@ void *Task_2(
status = pthread_mutex_lock( &Mutex2_id ); status = pthread_mutex_lock( &Mutex2_id );
if ( status ) if ( status )
printf( "status =%d\n", status ); printf( "status =%d\n", status );
assert( !status ); rtems_test_assert( !status );
printf( "Task 2: mutex acquired\n" ); printf( "Task 2: mutex acquired\n" );
/* switch to init */ /* switch to init */
printf( "Task 2: unlock Mutex 2\n" ); printf( "Task 2: unlock Mutex 2\n" );
status = pthread_mutex_unlock( &Mutex2_id ); status = pthread_mutex_unlock( &Mutex2_id );
assert( !status ); rtems_test_assert( !status );
printf( "Task 2: exit\n" ); printf( "Task 2: exit\n" );
pthread_exit( NULL ); pthread_exit( NULL );

View File

@@ -7,7 +7,7 @@
* *
* Output parameters: NONE * Output parameters: NONE
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -31,14 +31,14 @@ void *Task_3(
printf( "Task 3: pthread_mutex_lock unavailable (inherit case)\n" ); printf( "Task 3: pthread_mutex_lock unavailable (inherit case)\n" );
status = pthread_mutex_lock( &Mutex2_id ); status = pthread_mutex_lock( &Mutex2_id );
printf( "Task 3: mutex acquired\n" ); printf( "Task 3: mutex acquired\n" );
assert( !status ); rtems_test_assert( !status );
printf( "Task 3: unlock Mutex 2\n" ); printf( "Task 3: unlock Mutex 2\n" );
status = pthread_mutex_unlock( &Mutex2_id ); status = pthread_mutex_unlock( &Mutex2_id );
assert( !status ); rtems_test_assert( !status );
status = pthread_getschedparam( pthread_self(), &policy, &param ); status = pthread_getschedparam( pthread_self(), &policy, &param );
assert( !status ); rtems_test_assert( !status );
printf( "Task 3: pthread_getschedparam priority = %d\n", param.sched_priority ); printf( "Task 3: pthread_getschedparam priority = %d\n", param.sched_priority );
printf( "Task 3: exit\n" ); printf( "Task 3: exit\n" );

View File

@@ -52,10 +52,10 @@ void *POSIX_Init(
/* create a couple of threads */ /* create a couple of threads */
status = pthread_create( &Task_id, NULL, Task_1, NULL ); status = pthread_create( &Task_id, NULL, Task_1, NULL );
assert( !status ); rtems_test_assert( !status );
status = pthread_create( &Task2_id, NULL, Task_2, NULL ); status = pthread_create( &Task2_id, NULL, Task_2, NULL );
assert( !status ); rtems_test_assert( !status );
/* create a key */ /* create a key */
@@ -66,31 +66,31 @@ void *POSIX_Init(
status = pthread_key_create( &Key_id, Key_destructor ); status = pthread_key_create( &Key_id, Key_destructor );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
printf( "Destructor invoked %d times\n", Destructor_invoked ); printf( "Destructor invoked %d times\n", Destructor_invoked );
puts( "Init: pthread_key_create - EAGAIN (too many keys)" ); puts( "Init: pthread_key_create - EAGAIN (too many keys)" );
status = pthread_key_create( &Key_id, Key_destructor ); status = pthread_key_create( &Key_id, Key_destructor );
assert( status == EAGAIN ); rtems_test_assert( status == EAGAIN );
puts( "Init: pthread_setspecific - EINVAL (invalid key)" ); puts( "Init: pthread_setspecific - EINVAL (invalid key)" );
status = pthread_setspecific( (pthread_t) -1, &Data_array[ 0 ] ); status = pthread_setspecific( (pthread_t) -1, &Data_array[ 0 ] );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_getspecific - EINVAL (invalid key)" ); puts( "Init: pthread_getspecific - EINVAL (invalid key)" );
key_data = pthread_getspecific( (pthread_t) -1 ); key_data = pthread_getspecific( (pthread_t) -1 );
assert( !key_data ); rtems_test_assert( !key_data );
puts( "Init: pthread_key_delete - EINVAL (invalid key)" ); puts( "Init: pthread_key_delete - EINVAL (invalid key)" );
status = pthread_key_delete( (pthread_t) -1 ); status = pthread_key_delete( (pthread_t) -1 );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
printf( "Init: Setting the key to %d\n", 0 ); printf( "Init: Setting the key to %d\n", 0 );
status = pthread_setspecific( Key_id, &Data_array[ 0 ] ); status = pthread_setspecific( Key_id, &Data_array[ 0 ] );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
/* switch to task 1 */ /* switch to task 1 */
@@ -101,7 +101,7 @@ void *POSIX_Init(
remaining = sleep( 3 ); remaining = sleep( 3 );
if ( remaining ) if ( remaining )
printf( "seconds remaining = %d\n", remaining ); printf( "seconds remaining = %d\n", remaining );
assert( !remaining ); rtems_test_assert( !remaining );
/* switch to task 1 */ /* switch to task 1 */
@@ -111,7 +111,7 @@ void *POSIX_Init(
status = pthread_key_delete( Key_id ); status = pthread_key_delete( Key_id );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
printf( "Destructor invoked %d times\n", Destructor_invoked ); printf( "Destructor invoked %d times\n", Destructor_invoked );

View File

@@ -8,7 +8,7 @@
* *
* Output parameters: NONE * Output parameters: NONE
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -32,14 +32,14 @@ void *Task_1(
status = pthread_setspecific( Key_id, &Data_array[ 1 ] ); status = pthread_setspecific( Key_id, &Data_array[ 1 ] );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
key_data = pthread_getspecific( Key_id ); key_data = pthread_getspecific( Key_id );
printf( "Task_1: Got the key value of %ld\n", printf( "Task_1: Got the key value of %ld\n",
(unsigned long) ((uint32_t *)key_data - Data_array) ); (unsigned long) ((uint32_t *)key_data - Data_array) );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
puts( "Task_1: exitting" ); puts( "Task_1: exitting" );
pthread_exit( NULL ); pthread_exit( NULL );

View File

@@ -7,7 +7,7 @@
* *
* Output parameters: NONE * Output parameters: NONE
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -33,14 +33,14 @@ void *Task_2(
status = pthread_setspecific( Key_id, &Data_array[ 2 ] ); status = pthread_setspecific( Key_id, &Data_array[ 2 ] );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
key_data = pthread_getspecific( Key_id ); key_data = pthread_getspecific( Key_id );
printf( "Task_2: Got the key value of %ld\n", printf( "Task_2: Got the key value of %ld\n",
(unsigned long) ((uint32_t *)key_data - Data_array) ); (unsigned long) ((uint32_t *)key_data - Data_array) );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
puts( "Task2: exitting" ); puts( "Task2: exitting" );
pthread_exit( NULL ); pthread_exit( NULL );

View File

@@ -582,7 +582,7 @@ void *POSIX_Init(
puts( "Init - pthread_attr_setinheritsched - EXPLICIT - SUCCESSFUL" ); puts( "Init - pthread_attr_setinheritsched - EXPLICIT - SUCCESSFUL" );
status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
assert( !status ); rtems_test_assert( !status );
schedparam.ss_replenish_period.tv_sec = 3; schedparam.ss_replenish_period.tv_sec = 3;
schedparam.ss_replenish_period.tv_nsec = 3; schedparam.ss_replenish_period.tv_nsec = 3;
@@ -599,7 +599,7 @@ void *POSIX_Init(
posix_service_failed( status, "pthread_attr_setschedparam"); posix_service_failed( status, "pthread_attr_setschedparam");
status = pthread_create( &Task2_id, &attr, Task_2, NULL ); status = pthread_create( &Task2_id, &attr, Task_2, NULL );
assert( !status ); rtems_test_assert( !status );
status = pthread_join( Task2_id, NULL ); status = pthread_join( Task2_id, NULL );
posix_service_failed( status, " pthread_join"); posix_service_failed( status, " pthread_join");

View File

@@ -33,22 +33,22 @@ void *POSIX_Init(
puts( "Init: pthread_detach - ESRCH (invalid id)" ); puts( "Init: pthread_detach - ESRCH (invalid id)" );
status = pthread_detach( (pthread_t) -1 ); status = pthread_detach( (pthread_t) -1 );
assert( status == ESRCH ); rtems_test_assert( status == ESRCH );
/* detach this thread */ /* detach this thread */
puts( "Init: pthread_detach self" ); puts( "Init: pthread_detach self" );
status = pthread_detach( pthread_self() ); status = pthread_detach( pthread_self() );
assert( !status ); rtems_test_assert( !status );
/* create thread */ /* create thread */
status = pthread_create( &Task1_id, NULL, Task_1, NULL ); status = pthread_create( &Task1_id, NULL, Task_1, NULL );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_join - ESRCH (invalid id)" ); puts( "Init: pthread_join - ESRCH (invalid id)" );
status = pthread_join( (pthread_t) -1, &return_pointer ); status = pthread_join( (pthread_t) -1, &return_pointer );
assert( status == ESRCH ); rtems_test_assert( status == ESRCH );
puts( "Init: pthread_join - SUCCESSFUL" ); puts( "Init: pthread_join - SUCCESSFUL" );
status = pthread_join( Task1_id, &return_pointer ); status = pthread_join( Task1_id, &return_pointer );
@@ -56,7 +56,7 @@ void *POSIX_Init(
puts( "Init: returned from pthread_join through return" ); puts( "Init: returned from pthread_join through return" );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
if ( return_pointer == &Task1_id ) if ( return_pointer == &Task1_id )
puts( "Init: pthread_join returned correct pointer" ); puts( "Init: pthread_join returned correct pointer" );
@@ -69,10 +69,10 @@ void *POSIX_Init(
puts( "Init: creating two pthreads" ); puts( "Init: creating two pthreads" );
status = pthread_create( &Task2_id, NULL, Task_2, NULL ); status = pthread_create( &Task2_id, NULL, Task_2, NULL );
assert( !status ); rtems_test_assert( !status );
status = pthread_create( &Task3_id, NULL, Task_3, NULL ); status = pthread_create( &Task3_id, NULL, Task_3, NULL );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_join - SUCCESSFUL" ); puts( "Init: pthread_join - SUCCESSFUL" );
status = pthread_join( Task2_id, &return_pointer ); status = pthread_join( Task2_id, &return_pointer );
@@ -81,7 +81,7 @@ void *POSIX_Init(
puts( "Init: returned from pthread_join through pthread_exit" ); puts( "Init: returned from pthread_join through pthread_exit" );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
if ( return_pointer == &Task2_id ) if ( return_pointer == &Task2_id )
puts( "Init: pthread_join returned correct pointer" ); puts( "Init: pthread_join returned correct pointer" );

View File

@@ -8,7 +8,7 @@
* *
* Output parameters: NONE * Output parameters: NONE
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -37,13 +37,13 @@ void *Task_2(
status = pthread_join( Init_id, NULL ); status = pthread_join( Init_id, NULL );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Task_2: join to self task (Init) -- EDEADLK" ); puts( "Task_2: join to self task (Init) -- EDEADLK" );
status = pthread_join( pthread_self(), NULL ); status = pthread_join( pthread_self(), NULL );
if ( status != EDEADLK ) if ( status != EDEADLK )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EDEADLK ); rtems_test_assert( status == EDEADLK );
puts( "Task_2: exitting" ); puts( "Task_2: exitting" );

View File

@@ -8,7 +8,7 @@
* *
* Output parameters: NONE * Output parameters: NONE
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -33,7 +33,7 @@ void *Task_3(
puts( "Task_3: returned from pthread_join" ); puts( "Task_3: returned from pthread_join" );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
if ( return_pointer == &Task2_id ) if ( return_pointer == &Task2_id )
puts( "Task_3: pthread_join returned correct pointer" ); puts( "Task_3: pthread_join returned correct pointer" );

View File

@@ -72,7 +72,7 @@ void *POSIX_Init(
puts( "Init: pthread_getschedparam - SUCCESSFUL" ); puts( "Init: pthread_getschedparam - SUCCESSFUL" );
status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam );
assert( !status ); rtems_test_assert( !status );
priority = schedparam.sched_priority; priority = schedparam.sched_priority;
sprintf( buffer, " - current priority = %d", priority ); sprintf( buffer, " - current priority = %d", priority );
@@ -88,10 +88,10 @@ void *POSIX_Init(
puts( "Init: pthread_setschedparam - SUCCESSFUL (sporadic server)" ); puts( "Init: pthread_setschedparam - SUCCESSFUL (sporadic server)" );
status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam ); status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam );
assert( !status ); rtems_test_assert( !status );
status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam );
assert( !status ); rtems_test_assert( !status );
priority = schedparam.sched_priority; priority = schedparam.sched_priority;
sprintf( buffer, " - new priority = %d", priority ); sprintf( buffer, " - new priority = %d", priority );
@@ -101,7 +101,7 @@ void *POSIX_Init(
for ( passes=0 ; passes <= 3 ; ) { for ( passes=0 ; passes <= 3 ; ) {
status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam );
assert( !status ); rtems_test_assert( !status );
if ( priority != schedparam.sched_priority ) { if ( priority != schedparam.sched_priority ) {
priority = schedparam.sched_priority; priority = schedparam.sched_priority;
@@ -116,7 +116,7 @@ void *POSIX_Init(
empty_line(); empty_line();
status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam );
assert( !status ); rtems_test_assert( !status );
schedparam.ss_replenish_period.tv_sec = 0; schedparam.ss_replenish_period.tv_sec = 0;
schedparam.ss_replenish_period.tv_nsec = 500000000; /* 1/2 second */ schedparam.ss_replenish_period.tv_nsec = 500000000; /* 1/2 second */
@@ -132,23 +132,23 @@ void *POSIX_Init(
puts( "Init: pthread_setschedparam - SUCCESSFUL (sporadic server)" ); puts( "Init: pthread_setschedparam - SUCCESSFUL (sporadic server)" );
status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam ); status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Initializing mutex attributes for priority ceiling" ); puts( "Init: Initializing mutex attributes for priority ceiling" );
status = pthread_mutexattr_init( &attr ); status = pthread_mutexattr_init( &attr );
assert( !status ); rtems_test_assert( !status );
status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT ); status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Creating a mutex" ); puts( "Init: Creating a mutex" );
status = pthread_mutex_init( &Mutex_id, &attr ); status = pthread_mutex_init( &Mutex_id, &attr );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam );
assert( !status ); rtems_test_assert( !status );
priority = schedparam.sched_priority; priority = schedparam.sched_priority;
sprintf( buffer, " - new priority = %d", priority ); sprintf( buffer, " - new priority = %d", priority );
@@ -162,11 +162,11 @@ void *POSIX_Init(
status = pthread_mutex_lock( &Mutex_id ); status = pthread_mutex_lock( &Mutex_id );
if ( status ) if ( status )
printf( "status = %d %s\n", status, strerror(status) ); printf( "status = %d %s\n", status, strerror(status) );
assert( !status ); rtems_test_assert( !status );
for ( ; ; ) { for ( ; ; ) {
status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam );
assert( !status ); rtems_test_assert( !status );
if ( schedparam.sched_priority == LOW_PRIORITY ) { if ( schedparam.sched_priority == LOW_PRIORITY ) {
puts( "ERROR - Init's priority lowered while holding mutex" ); puts( "ERROR - Init's priority lowered while holding mutex" );
@@ -182,7 +182,7 @@ void *POSIX_Init(
print_current_time( "Init: ", buffer ); print_current_time( "Init: ", buffer );
status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam );
assert( !status ); rtems_test_assert( !status );
priority = schedparam.sched_priority; priority = schedparam.sched_priority;
sprintf( buffer, " - new priority = %d", priority ); sprintf( buffer, " - new priority = %d", priority );
@@ -197,10 +197,10 @@ void *POSIX_Init(
status = pthread_mutex_unlock( &Mutex_id ); status = pthread_mutex_unlock( &Mutex_id );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam );
assert( !status ); rtems_test_assert( !status );
priority = schedparam.sched_priority; priority = schedparam.sched_priority;
sprintf( buffer, " - new priority = %d", priority ); sprintf( buffer, " - new priority = %d", priority );
@@ -208,14 +208,14 @@ void *POSIX_Init(
for ( ; ; ) { for ( ; ; ) {
status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam );
assert( !status ); rtems_test_assert( !status );
if ( schedparam.sched_priority == LOW_PRIORITY ) if ( schedparam.sched_priority == LOW_PRIORITY )
break; break;
} }
status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam ); status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam );
assert( !status ); rtems_test_assert( !status );
priority = schedparam.sched_priority; priority = schedparam.sched_priority;
sprintf( buffer, " - new priority = %d", priority ); sprintf( buffer, " - new priority = %d", priority );

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -29,61 +29,61 @@ void *POSIX_Init(
puts( "Init: pthread_condattr_init" ); puts( "Init: pthread_condattr_init" );
status = pthread_condattr_init( &attr ); status = pthread_condattr_init( &attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_condattr_init - EINVAL (attribute invalid)" ); puts( "Init: pthread_condattr_init - EINVAL (attribute invalid)" );
status = pthread_condattr_init( NULL ); status = pthread_condattr_init( NULL );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_condattr_destroy" ); puts( "Init: pthread_condattr_destroy" );
status = pthread_condattr_destroy( &attr ); status = pthread_condattr_destroy( &attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_condattr_destroy - EINVAL (attribute invalid)" ); puts( "Init: pthread_condattr_destroy - EINVAL (attribute invalid)" );
status = pthread_condattr_destroy( NULL ); status = pthread_condattr_destroy( NULL );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_condattr_init" ); puts( "Init: pthread_condattr_init" );
status = pthread_condattr_init( &attr ); status = pthread_condattr_init( &attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_condattr_setpshared - PTHREAD_PROCESS_SHARED" ); puts( "Init: pthread_condattr_setpshared - PTHREAD_PROCESS_SHARED" );
status = pthread_condattr_setpshared( &attr, PTHREAD_PROCESS_SHARED ); status = pthread_condattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_condattr_setpshared - PTHREAD_PROCESS_PRIVATE" ); puts( "Init: pthread_condattr_setpshared - PTHREAD_PROCESS_PRIVATE" );
status = pthread_condattr_setpshared( &attr, PTHREAD_PROCESS_PRIVATE ); status = pthread_condattr_setpshared( &attr, PTHREAD_PROCESS_PRIVATE );
assert( !status ); rtems_test_assert( !status );
status = pthread_condattr_setpshared( NULL, PTHREAD_PROCESS_PRIVATE ); status = pthread_condattr_setpshared( NULL, PTHREAD_PROCESS_PRIVATE );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_condattr_setpshared - EINVAL (attribute invalid)" ); puts( "Init: pthread_condattr_setpshared - EINVAL (attribute invalid)" );
status = pthread_condattr_setpshared( &attr, 0x7FFF ); status = pthread_condattr_setpshared( &attr, 0x7FFF );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_condattr_setpshared - EINVAL (pshared invalid)" ); puts( "Init: pthread_condattr_setpshared - EINVAL (pshared invalid)" );
status = pthread_condattr_getpshared( &attr, &pshared ); status = pthread_condattr_getpshared( &attr, &pshared );
assert( !status ); rtems_test_assert( !status );
printf( "Init: pthread_condattr_getpshared - %d\n", pshared ); printf( "Init: pthread_condattr_getpshared - %d\n", pshared );
status = pthread_condattr_getpshared( NULL, &pshared ); status = pthread_condattr_getpshared( NULL, &pshared );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_condattr_getpshared - EINVAL (attribute invalid)" ); puts( "Init: pthread_condattr_getpshared - EINVAL (attribute invalid)" );
puts( "Init: pthread_cond_init - NULL attr" ); puts( "Init: pthread_cond_init - NULL attr" );
status = pthread_cond_init( &cond, NULL ); status = pthread_cond_init( &cond, NULL );
assert( !status ); rtems_test_assert( !status );
/* error for attribute not initialized */ /* error for attribute not initialized */
@@ -91,39 +91,39 @@ void *POSIX_Init(
status = pthread_cond_init( &cond, &attr_error ); status = pthread_cond_init( &cond, &attr_error );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_cond_init - EINVAL (attr not initialized)" ); puts( "Init: pthread_cond_init - EINVAL (attr not initialized)" );
status = pthread_cond_init( &cond, NULL ); status = pthread_cond_init( &cond, NULL );
if ( status != ENOMEM ) if ( status != ENOMEM )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == ENOMEM ); rtems_test_assert( status == ENOMEM );
puts( "Init: pthread_cond_init - ENOMEM (too many conds)" ); puts( "Init: pthread_cond_init - ENOMEM (too many conds)" );
puts( "Init: pthread_cond_destroy" ); puts( "Init: pthread_cond_destroy" );
status = pthread_cond_destroy( &cond ); status = pthread_cond_destroy( &cond );
assert( !status ); rtems_test_assert( !status );
/* error for bad condition variable passed */ /* error for bad condition variable passed */
status = pthread_cond_destroy( NULL ); status = pthread_cond_destroy( NULL );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_cond_destroy - EINVAL (cond invalid)" ); puts( "Init: pthread_cond_destroy - EINVAL (cond invalid)" );
/* initiailize the attribute for the rest of the test */ /* initiailize the attribute for the rest of the test */
puts( "Init: pthread_cond_init - attr" ); puts( "Init: pthread_cond_init - attr" );
status = pthread_cond_init( &Cond1_id, &attr ); status = pthread_cond_init( &Cond1_id, &attr );
assert( !status ); rtems_test_assert( !status );
/* signal task1 with a condition variable */ /* signal task1 with a condition variable */
empty_line(); empty_line();
status = pthread_create( &Task_id, NULL, Task_1, NULL ); status = pthread_create( &Task_id, NULL, Task_1, NULL );
assert( !status ); rtems_test_assert( !status );
/* switch to task1 to allow it to wait for a condition variable */ /* switch to task1 to allow it to wait for a condition variable */
@@ -133,17 +133,17 @@ void *POSIX_Init(
status = pthread_cond_destroy( &Cond1_id ); status = pthread_cond_destroy( &Cond1_id );
if ( status != EBUSY ) if ( status != EBUSY )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EBUSY ); rtems_test_assert( status == EBUSY );
puts( "Init: pthread_cond_destroy - EBUSY (task1 waiting)" ); puts( "Init: pthread_cond_destroy - EBUSY (task1 waiting)" );
puts( "Init: pthread_cond_signal" ); puts( "Init: pthread_cond_signal" );
status = pthread_cond_signal( &Cond1_id ); status = pthread_cond_signal( &Cond1_id );
assert( !status ); rtems_test_assert( !status );
empty_line(); empty_line();
status = pthread_create( &Task2_id, NULL, Task_2, NULL ); status = pthread_create( &Task2_id, NULL, Task_2, NULL );
assert( !status ); rtems_test_assert( !status );
/* switch to task1 and task2 to allow them to wait for broadcast signal */ /* switch to task1 and task2 to allow them to wait for broadcast signal */
@@ -154,7 +154,7 @@ void *POSIX_Init(
puts( "Init: pthread_cond_broadcast" ); puts( "Init: pthread_cond_broadcast" );
status = pthread_cond_broadcast( &Cond1_id ); status = pthread_cond_broadcast( &Cond1_id );
assert( !status ); rtems_test_assert( !status );
puts( "Init: sleep - switch to Task_1" ); puts( "Init: sleep - switch to Task_1" );
sleep( 0 ); sleep( 0 );
@@ -162,12 +162,12 @@ void *POSIX_Init(
/* timedwait case - timeout */ /* timedwait case - timeout */
status = pthread_mutex_lock( &Mutex_id ); status = pthread_mutex_lock( &Mutex_id );
assert( !status ); rtems_test_assert( !status );
/* set timeout to 3 seconds */ /* set timeout to 3 seconds */
status = clock_gettime( CLOCK_REALTIME, &timeout ); status = clock_gettime( CLOCK_REALTIME, &timeout );
assert( !status ); rtems_test_assert( !status );
timeout.tv_sec += 3; timeout.tv_sec += 3;
timeout.tv_nsec = 0; timeout.tv_nsec = 0;
@@ -175,11 +175,11 @@ void *POSIX_Init(
status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout ); status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
if ( status != ETIMEDOUT ) if ( status != ETIMEDOUT )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == ETIMEDOUT ); rtems_test_assert( status == ETIMEDOUT );
puts( "Init: pthread_cond_timedwait - ETIMEDOUT - (mutex not acquired)" ); puts( "Init: pthread_cond_timedwait - ETIMEDOUT - (mutex not acquired)" );
status = pthread_mutex_unlock( &Mutex_id ); status = pthread_mutex_unlock( &Mutex_id );
assert( !status ); rtems_test_assert( !status );
/* remaining error messages */ /* remaining error messages */
@@ -190,78 +190,78 @@ void *POSIX_Init(
status = pthread_cond_signal( NULL ); status = pthread_cond_signal( NULL );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_cond_signal - EINVAL (cond invalid)" ); puts( "Init: pthread_cond_signal - EINVAL (cond invalid)" );
status = pthread_cond_broadcast( NULL ); status = pthread_cond_broadcast( NULL );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_cond_broadcast - EINVAL (cond invalid)" ); puts( "Init: pthread_cond_broadcast - EINVAL (cond invalid)" );
/* acquire mutex so errors will occur */ /* acquire mutex so errors will occur */
status = pthread_mutex_lock( &Mutex_id ); status = pthread_mutex_lock( &Mutex_id );
assert( !status ); rtems_test_assert( !status );
status = pthread_cond_wait( NULL, &Mutex_id ); status = pthread_cond_wait( NULL, &Mutex_id );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_cond_wait - EINVAL (cond invalid)" ); puts( "Init: pthread_cond_wait - EINVAL (cond invalid)" );
status = pthread_cond_timedwait( NULL, &Mutex_id, &timeout ); status = pthread_cond_timedwait( NULL, &Mutex_id, &timeout );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_cond_timedwait - EINVAL (cond invalid)" ); puts( "Init: pthread_cond_timedwait - EINVAL (cond invalid)" );
status = pthread_cond_wait( &Cond1_id, NULL ); status = pthread_cond_wait( &Cond1_id, NULL );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_cond_wait - EINVAL (mutex invalid)" ); puts( "Init: pthread_cond_wait - EINVAL (mutex invalid)" );
status = pthread_cond_timedwait( &Cond1_id, NULL, &timeout ); status = pthread_cond_timedwait( &Cond1_id, NULL, &timeout );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_cond_timedwait - EINVAL (mutex invalid)" ); puts( "Init: pthread_cond_timedwait - EINVAL (mutex invalid)" );
status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, NULL ); status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, NULL );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Init: pthread_cond_timedwait - EINVAL (abstime NULL)" ); puts( "Init: pthread_cond_timedwait - EINVAL (abstime NULL)" );
status = clock_gettime( CLOCK_REALTIME, &timeout ); status = clock_gettime( CLOCK_REALTIME, &timeout );
assert( !status ); rtems_test_assert( !status );
timeout.tv_sec -= 1; timeout.tv_sec -= 1;
status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout ); status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
if ( status != ETIMEDOUT ) if ( status != ETIMEDOUT )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == ETIMEDOUT ); rtems_test_assert( status == ETIMEDOUT );
puts( "Init: pthread_cond_timedwait - ETIMEDOUT (abstime->tv_sec < current time)" ); puts( "Init: pthread_cond_timedwait - ETIMEDOUT (abstime->tv_sec < current time)" );
status = pthread_mutex_unlock( &Mutex_id ); status = pthread_mutex_unlock( &Mutex_id );
assert( !status ); rtems_test_assert( !status );
status = pthread_mutex_lock( &Mutex_id ); status = pthread_mutex_lock( &Mutex_id );
assert( !status ); rtems_test_assert( !status );
/* ensure we do not catch a 0 nanosecond boundary */ /* ensure we do not catch a 0 nanosecond boundary */
do { do {
status = clock_gettime( CLOCK_REALTIME, &timeout ); status = clock_gettime( CLOCK_REALTIME, &timeout );
assert( !status ); rtems_test_assert( !status );
timeout.tv_nsec -= 1; timeout.tv_nsec -= 1;
} while ( timeout.tv_nsec < 0); } while ( timeout.tv_nsec < 0);
status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout ); status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
if ( status != ETIMEDOUT ) if ( status != ETIMEDOUT )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == ETIMEDOUT ); rtems_test_assert( status == ETIMEDOUT );
puts( "Init: pthread_cond_timedwait - ETIMEDOUT (abstime->tv_nsec < current time)" ); puts( "Init: pthread_cond_timedwait - ETIMEDOUT (abstime->tv_nsec < current time)" );
status = pthread_mutex_unlock( &Mutex_id ); status = pthread_mutex_unlock( &Mutex_id );
assert( !status ); rtems_test_assert( !status );
/* wait and timedwait without mutex */ /* wait and timedwait without mutex */
@@ -270,26 +270,26 @@ void *POSIX_Init(
* status = pthread_cond_wait( &Cond1_id, &Mutex_id ); * status = pthread_cond_wait( &Cond1_id, &Mutex_id );
* if ( status != EINVAL ) * if ( status != EINVAL )
* printf( "status = %d\n", status ); * printf( "status = %d\n", status );
* assert( status == EINVAL ); * rtems_test_assert( status == EINVAL );
*/ */
puts( "Init: pthread_cond_wait - EINVAL (mutex not locked before call)" ); puts( "Init: pthread_cond_wait - EINVAL (mutex not locked before call)" );
/* XXX - this case is commented out in the code pending review /* XXX - this case is commented out in the code pending review
* *
* status = clock_gettime( CLOCK_REALTIME, &timeout ); * status = clock_gettime( CLOCK_REALTIME, &timeout );
* assert( !status ); * rtems_test_assert( !status );
* timeout.tv_sec += 1; * timeout.tv_sec += 1;
* status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout ); * status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
* if ( status != EINVAL ) * if ( status != EINVAL )
* printf( "status = %d\n", status ); * printf( "status = %d\n", status );
* assert( status == EINVAL ); * rtems_test_assert( status == EINVAL );
*/ */
puts( "Init: pthread_cond_timedwait - EINVAL (mutex not locked before call)"); puts( "Init: pthread_cond_timedwait - EINVAL (mutex not locked before call)");
empty_line(); empty_line();
status = pthread_create( &Task3_id, NULL, Task_3, NULL ); status = pthread_create( &Task3_id, NULL, Task_3, NULL );
assert( !status ); rtems_test_assert( !status );
/* switch to task3 to allow it to wait for broadcast signal */ /* switch to task3 to allow it to wait for broadcast signal */
@@ -299,7 +299,7 @@ void *POSIX_Init(
/* destroy the mutex so Task3 can not acguire at the end of Wait_support */ /* destroy the mutex so Task3 can not acguire at the end of Wait_support */
status = pthread_mutex_destroy( &Mutex_id ); status = pthread_mutex_destroy( &Mutex_id );
assert( !status ); rtems_test_assert( !status );
/* signal a condition variable to task3 */ /* signal a condition variable to task3 */

View File

@@ -7,7 +7,7 @@
* *
* Output parameters: NONE * Output parameters: NONE
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -31,31 +31,31 @@ void *Task_1(
printf( "Task_1: ID is 0x%08" PRIxpthread_t "\n", Task_id ); printf( "Task_1: ID is 0x%08" PRIxpthread_t "\n", Task_id );
status = pthread_mutex_init( &Mutex_id, NULL ); status = pthread_mutex_init( &Mutex_id, NULL );
assert( !status ); rtems_test_assert( !status );
status = pthread_mutex_lock( &Mutex_id ); status = pthread_mutex_lock( &Mutex_id );
assert( !status ); rtems_test_assert( !status );
puts( "Task_1: pthread_cond_wait" ); puts( "Task_1: pthread_cond_wait" );
status = pthread_cond_wait( &Cond1_id, &Mutex_id ); status = pthread_cond_wait( &Cond1_id, &Mutex_id );
assert( !status ); rtems_test_assert( !status );
puts( "Task_1: back from pthread_cond_wait release mutex" ); puts( "Task_1: back from pthread_cond_wait release mutex" );
status = pthread_mutex_unlock( &Mutex_id ); status = pthread_mutex_unlock( &Mutex_id );
assert( !status ); rtems_test_assert( !status );
/* wait for a condition variable broadcast from Init */ /* wait for a condition variable broadcast from Init */
status = pthread_mutex_lock( &Mutex_id ); status = pthread_mutex_lock( &Mutex_id );
assert( !status ); rtems_test_assert( !status );
puts( "Task_1: pthread_cond_wait" ); puts( "Task_1: pthread_cond_wait" );
status = pthread_cond_wait( &Cond1_id, &Mutex_id ); status = pthread_cond_wait( &Cond1_id, &Mutex_id );
assert( !status ); rtems_test_assert( !status );
puts( "Task_1: back from pthread_cond_wait release mutex" ); puts( "Task_1: back from pthread_cond_wait release mutex" );
status = pthread_mutex_unlock( &Mutex_id ); status = pthread_mutex_unlock( &Mutex_id );
assert( !status ); rtems_test_assert( !status );
puts( "Task_1: task exit" ); puts( "Task_1: task exit" );
pthread_exit( NULL ); pthread_exit( NULL );

View File

@@ -7,7 +7,7 @@
* *
* Output parameters: NONE * Output parameters: NONE
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -29,15 +29,15 @@ void *Task_2(
printf( "Task_2: ID is 0x%08" PRIxpthread_t "\n", Task_id ); printf( "Task_2: ID is 0x%08" PRIxpthread_t "\n", Task_id );
status = pthread_mutex_lock( &Mutex_id ); status = pthread_mutex_lock( &Mutex_id );
assert( !status ); rtems_test_assert( !status );
puts( "Task_2: pthread_cond_wait" ); puts( "Task_2: pthread_cond_wait" );
status = pthread_cond_wait( &Cond1_id, &Mutex_id ); status = pthread_cond_wait( &Cond1_id, &Mutex_id );
assert( !status ); rtems_test_assert( !status );
puts( "Task_2: back from pthread_cond_wait release mutex" ); puts( "Task_2: back from pthread_cond_wait release mutex" );
status = pthread_mutex_unlock( &Mutex_id ); status = pthread_mutex_unlock( &Mutex_id );
assert( !status ); rtems_test_assert( !status );
puts( "Task_2: task exit" ); puts( "Task_2: task exit" );
pthread_exit( NULL ); pthread_exit( NULL );

View File

@@ -7,7 +7,7 @@
* *
* Output parameters: NONE * Output parameters: NONE
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -29,13 +29,13 @@ void *Task_3(
printf( "Task_3: ID is 0x%08" PRIxpthread_t "\n", Task_id ); printf( "Task_3: ID is 0x%08" PRIxpthread_t "\n", Task_id );
status = pthread_mutex_lock( &Mutex_id ); status = pthread_mutex_lock( &Mutex_id );
assert( !status ); rtems_test_assert( !status );
puts( "Task_3: pthread_cond_wait" ); puts( "Task_3: pthread_cond_wait" );
status = pthread_cond_wait( &Cond1_id, &Mutex_id ); status = pthread_cond_wait( &Cond1_id, &Mutex_id );
if ( status != EINVAL ) if ( status != EINVAL )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "Task_3: pthread_cond_wait - EINVAL (mutex not locked after signal)"); puts( "Task_3: pthread_cond_wait - EINVAL (mutex not locked after signal)");
puts( "Task_3: task exit" ); puts( "Task_3: task exit" );

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 1989-2008. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -52,7 +52,7 @@ void *POSIX_Init(
priority_1 priority_1
); );
status = pthread_setschedparam( Init_id, SCHED_FIFO, &param ); status = pthread_setschedparam( Init_id, SCHED_FIFO, &param );
assert( !status ); rtems_test_assert( !status );
param.sched_priority = priority_2; param.sched_priority = priority_2;
@@ -61,7 +61,7 @@ void *POSIX_Init(
priority_2 priority_2
); );
status = pthread_setschedparam( Init_id, SCHED_RR, &param ); status = pthread_setschedparam( Init_id, SCHED_RR, &param );
assert( !status ); rtems_test_assert( !status );
param.sched_priority = priority_3; param.sched_priority = priority_3;
@@ -70,59 +70,59 @@ void *POSIX_Init(
priority_3 priority_3
); );
status = pthread_setschedparam( Init_id, SCHED_OTHER, &param ); status = pthread_setschedparam( Init_id, SCHED_OTHER, &param );
assert( !status ); rtems_test_assert( !status );
/* create a thread as SCHED_FIFO */ /* create a thread as SCHED_FIFO */
printf( printf(
"Init: create a thread of SCHED_FIFO with priority %d\n", priority_4 ); "Init: create a thread of SCHED_FIFO with priority %d\n", priority_4 );
status = pthread_attr_init( &attr ); status = pthread_attr_init( &attr );
assert( !status ); rtems_test_assert( !status );
attr.schedpolicy = SCHED_FIFO; attr.schedpolicy = SCHED_FIFO;
attr.schedparam.sched_priority = priority_4; attr.schedparam.sched_priority = priority_4;
status = pthread_create( &Task_id, &attr, Task_1, NULL ); status = pthread_create( &Task_id, &attr, Task_1, NULL );
assert( !status ); rtems_test_assert( !status );
puts( "Init: join with the other thread" ); puts( "Init: join with the other thread" );
status = pthread_join( Task_id, NULL ); status = pthread_join( Task_id, NULL );
assert( !status ); rtems_test_assert( !status );
/* create a thread as SCHED_RR */ /* create a thread as SCHED_RR */
printf( "Init: create a thread of SCHED_RR with priority %d\n", priority_4 ); printf( "Init: create a thread of SCHED_RR with priority %d\n", priority_4 );
status = pthread_attr_init( &attr ); status = pthread_attr_init( &attr );
assert( !status ); rtems_test_assert( !status );
status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
assert( !status ); rtems_test_assert( !status );
attr.schedpolicy = SCHED_RR; attr.schedpolicy = SCHED_RR;
attr.schedparam.sched_priority = priority_4; attr.schedparam.sched_priority = priority_4;
status = pthread_create( &Task_id, &attr, Task_1, NULL ); status = pthread_create( &Task_id, &attr, Task_1, NULL );
assert( !status ); rtems_test_assert( !status );
puts( "Init: join with the other thread" ); puts( "Init: join with the other thread" );
status = pthread_join( Task_id, NULL ); status = pthread_join( Task_id, NULL );
assert( !status ); rtems_test_assert( !status );
/* create a thread as SCHED_OTHER */ /* create a thread as SCHED_OTHER */
printf( printf(
"Init: create a thread of SCHED_OTHER with priority %d\n", priority_4 ); "Init: create a thread of SCHED_OTHER with priority %d\n", priority_4 );
status = pthread_attr_init( &attr ); status = pthread_attr_init( &attr );
assert( !status ); rtems_test_assert( !status );
attr.schedpolicy = SCHED_OTHER; attr.schedpolicy = SCHED_OTHER;
attr.schedparam.sched_priority = priority_4; attr.schedparam.sched_priority = priority_4;
status = pthread_create( &Task_id, &attr, Task_1, NULL ); status = pthread_create( &Task_id, &attr, Task_1, NULL );
assert( !status ); rtems_test_assert( !status );
puts( "Init: join with the other thread" ); puts( "Init: join with the other thread" );
status = pthread_join( Task_id, NULL ); status = pthread_join( Task_id, NULL );
assert( !status ); rtems_test_assert( !status );
puts( "*** END OF POSIX TEST 11 ***" ); puts( "*** END OF POSIX TEST 11 ***" );
rtems_test_exit( 0 ); rtems_test_exit( 0 );

View File

@@ -50,10 +50,10 @@ void *Task_1(
struct timespec delay; struct timespec delay;
status = clock_gettime( CLOCK_REALTIME, &start ); status = clock_gettime( CLOCK_REALTIME, &start );
assert( !status ); rtems_test_assert( !status );
status = sched_rr_get_interval( getpid(), &delay ); status = sched_rr_get_interval( getpid(), &delay );
assert( !status ); rtems_test_assert( !status );
/* double the rr interval for confidence */ /* double the rr interval for confidence */
@@ -69,7 +69,7 @@ void *Task_1(
for ( ; ; ) { for ( ; ; ) {
status = clock_gettime( CLOCK_REALTIME, &current ); status = clock_gettime( CLOCK_REALTIME, &current );
assert( !status ); rtems_test_assert( !status );
diff_timespec( &start, &current, &difference ); diff_timespec( &start, &current, &difference );

View File

@@ -62,25 +62,25 @@ void *POSIX_Init(
puts( "Init: pthread_attr_init - SUCCESSFUL" ); puts( "Init: pthread_attr_init - SUCCESSFUL" );
status = pthread_attr_init( &attr ); status = pthread_attr_init( &attr );
assert( !status ); rtems_test_assert( !status );
status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
assert( !status ); rtems_test_assert( !status );
attr.schedpolicy = -1; attr.schedpolicy = -1;
puts( "Init: pthread_create - EINVAL (invalid scheduling policy)" ); puts( "Init: pthread_create - EINVAL (invalid scheduling policy)" );
status = pthread_create( &Task_id, &attr, Task_1, NULL ); status = pthread_create( &Task_id, &attr, Task_1, NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* replenish period < budget error */ /* replenish period < budget error */
puts( "Init: pthread_attr_init - SUCCESSFUL" ); puts( "Init: pthread_attr_init - SUCCESSFUL" );
status = pthread_attr_init( &attr ); status = pthread_attr_init( &attr );
assert( !status ); rtems_test_assert( !status );
puts( "Init: set scheduling parameter attributes for sporadic server" ); puts( "Init: set scheduling parameter attributes for sporadic server" );
status = pthread_attr_setschedpolicy( &attr, SCHED_SPORADIC ); status = pthread_attr_setschedpolicy( &attr, SCHED_SPORADIC );
assert( !status ); rtems_test_assert( !status );
schedparam.ss_replenish_period.tv_sec = 1; schedparam.ss_replenish_period.tv_sec = 1;
schedparam.ss_replenish_period.tv_nsec = 0; schedparam.ss_replenish_period.tv_nsec = 0;
@@ -91,14 +91,14 @@ void *POSIX_Init(
schedparam.ss_low_priority = 100; schedparam.ss_low_priority = 100;
status = pthread_attr_setschedparam( &attr, &schedparam ); status = pthread_attr_setschedparam( &attr, &schedparam );
assert( !status ); rtems_test_assert( !status );
status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_create - EINVAL (replenish < budget)" ); puts( "Init: pthread_create - EINVAL (replenish < budget)" );
status = pthread_create( &Task_id, &attr, Task_1, NULL ); status = pthread_create( &Task_id, &attr, Task_1, NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* invalid ss_low_priority error */ /* invalid ss_low_priority error */
@@ -111,11 +111,11 @@ void *POSIX_Init(
schedparam.ss_low_priority = -1; schedparam.ss_low_priority = -1;
status = pthread_attr_setschedparam( &attr, &schedparam ); status = pthread_attr_setschedparam( &attr, &schedparam );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_create - EINVAL (invalid ss_low_priority)" ); puts( "Init: pthread_create - EINVAL (invalid ss_low_priority)" );
status = pthread_create( &Task_id, &attr, Task_1, NULL ); status = pthread_create( &Task_id, &attr, Task_1, NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* create a thread as a sporadic server */ /* create a thread as a sporadic server */
@@ -128,14 +128,14 @@ void *POSIX_Init(
schedparam.ss_low_priority = sched_get_priority_max( SCHED_FIFO ) - 6; schedparam.ss_low_priority = sched_get_priority_max( SCHED_FIFO ) - 6;
status = pthread_attr_setschedparam( &attr, &schedparam ); status = pthread_attr_setschedparam( &attr, &schedparam );
assert( !status ); rtems_test_assert( !status );
puts( "Init: pthread_create - SUCCESSFUL" ); puts( "Init: pthread_create - SUCCESSFUL" );
status = pthread_create( &Task_id, &attr, Task_1, NULL ); status = pthread_create( &Task_id, &attr, Task_1, NULL );
assert( !status ); rtems_test_assert( !status );
status = pthread_join( Task_id, NULL ); status = pthread_join( Task_id, NULL );
assert( status ); rtems_test_assert( status );
/* switch to Task_1 */ /* switch to Task_1 */

View File

@@ -70,7 +70,7 @@ void *POSIX_Init(
/* install a signal handler for SIGALRM and unblock it */ /* install a signal handler for SIGALRM and unblock it */
sc = sigemptyset( &act.sa_mask ); sc = sigemptyset( &act.sa_mask );
assert( !sc ); rtems_test_assert( !sc );
act.sa_handler = Signal_handler; act.sa_handler = Signal_handler;
act.sa_flags = 0; act.sa_flags = 0;
@@ -78,21 +78,21 @@ void *POSIX_Init(
sigaction( SIGALRM, &act, NULL ); sigaction( SIGALRM, &act, NULL );
sc = sigemptyset( &mask ); sc = sigemptyset( &mask );
assert( !sc ); rtems_test_assert( !sc );
sc = sigaddset( &mask, SIGALRM ); sc = sigaddset( &mask, SIGALRM );
assert( !sc ); rtems_test_assert( !sc );
puts( "Init: Unblock SIGALRM" ); puts( "Init: Unblock SIGALRM" );
sc = sigprocmask( SIG_UNBLOCK, &mask, NULL ); sc = sigprocmask( SIG_UNBLOCK, &mask, NULL );
assert( !sc ); rtems_test_assert( !sc );
/* schedule the alarm */ /* schedule the alarm */
puts( "Init: Firing alarm in 1 second" ); puts( "Init: Firing alarm in 1 second" );
remaining = alarm( 1 ); remaining = alarm( 1 );
printf( "Init: %d seconds left on previous alarm\n", sc ); printf( "Init: %d seconds left on previous alarm\n", sc );
assert( !sc ); rtems_test_assert( !sc );
puts( "Init: Wait for alarm" ); puts( "Init: Wait for alarm" );
sleep( 2 ); sleep( 2 );
@@ -100,7 +100,7 @@ void *POSIX_Init(
puts( "Init: Cancel alarm" ); puts( "Init: Cancel alarm" );
remaining = alarm( 0 ); remaining = alarm( 0 );
printf( "Init: %d seconds left on previous alarm\n", remaining ); printf( "Init: %d seconds left on previous alarm\n", remaining );
assert( remaining == 0 ); rtems_test_assert( remaining == 0 );
puts( "*** END OF POSIX ALARM TEST 01***" ); puts( "*** END OF POSIX ALARM TEST 01***" );
rtems_test_exit( 0 ); rtems_test_exit( 0 );

View File

@@ -11,7 +11,6 @@
* $Id$ * $Id$
*/ */
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
@@ -34,7 +33,7 @@ void *BarrierThread(void *arg)
printf( "pthread_barrier_wait( &Barrier ) for thread 0x%08" PRIxpthread_t "\n", id ); printf( "pthread_barrier_wait( &Barrier ) for thread 0x%08" PRIxpthread_t "\n", id );
status = pthread_barrier_wait( &Barrier ); status = pthread_barrier_wait( &Barrier );
printf( "pthread_barrier_wait - 0x%08" PRIxpthread_t " released\n", id ); printf( "pthread_barrier_wait - 0x%08" PRIxpthread_t " released\n", id );
assert( (status == 0) || (status == PTHREAD_BARRIER_SERIAL_THREAD) ); rtems_test_assert( (status == 0) || (status == PTHREAD_BARRIER_SERIAL_THREAD) );
return NULL; return NULL;
} }
@@ -66,155 +65,155 @@ int main(
/*************** NULL POINTER CHECKS *****************/ /*************** NULL POINTER CHECKS *****************/
puts( "pthread_barrierattr_init( NULL ) -- EINVAL" ); puts( "pthread_barrierattr_init( NULL ) -- EINVAL" );
status = pthread_barrierattr_init( NULL ); status = pthread_barrierattr_init( NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_barrierattr_setpshared( NULL, private ) -- EINVAL" ); puts( "pthread_barrierattr_setpshared( NULL, private ) -- EINVAL" );
status = pthread_barrierattr_setpshared( NULL, PTHREAD_PROCESS_PRIVATE ); status = pthread_barrierattr_setpshared( NULL, PTHREAD_PROCESS_PRIVATE );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_barrierattr_setpshared( NULL, shared ) -- EINVAL" ); puts( "pthread_barrierattr_setpshared( NULL, shared ) -- EINVAL" );
status = pthread_barrierattr_setpshared( NULL, PTHREAD_PROCESS_SHARED ); status = pthread_barrierattr_setpshared( NULL, PTHREAD_PROCESS_SHARED );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_barrierattr_getpshared( NULL, &p ) -- EINVAL" ); puts( "pthread_barrierattr_getpshared( NULL, &p ) -- EINVAL" );
status = pthread_barrierattr_getpshared( NULL, &p ); status = pthread_barrierattr_getpshared( NULL, &p );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_barrierattr_destroy( NULL ) -- EINVAL" ); puts( "pthread_barrierattr_destroy( NULL ) -- EINVAL" );
status = pthread_barrierattr_destroy( NULL ); status = pthread_barrierattr_destroy( NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/*************** NOT INITIALIZED CHECKS *****************/ /*************** NOT INITIALIZED CHECKS *****************/
/* cheat visibility */ /* cheat visibility */
attr.is_initialized = 0; attr.is_initialized = 0;
puts( "pthread_barrierattr_setpshared( &attr, shared ) -- EINVAL" ); puts( "pthread_barrierattr_setpshared( &attr, shared ) -- EINVAL" );
status = pthread_barrierattr_setpshared( &attr, PTHREAD_PROCESS_SHARED ); status = pthread_barrierattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_barrierattr_getpshared( &attr, NULL ) -- EINVAL" ); puts( "pthread_barrierattr_getpshared( &attr, NULL ) -- EINVAL" );
status = pthread_barrierattr_getpshared( &attr, NULL ); status = pthread_barrierattr_getpshared( &attr, NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_barrierattr_destroy( &attr ) -- EINVAL" ); puts( "pthread_barrierattr_destroy( &attr ) -- EINVAL" );
status = pthread_barrierattr_destroy( &attr ); status = pthread_barrierattr_destroy( &attr );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/*************** ACTUALLY WORK THIS TIME *****************/ /*************** ACTUALLY WORK THIS TIME *****************/
puts( "pthread_barrierattr_init( &attr ) -- OK" ); puts( "pthread_barrierattr_init( &attr ) -- OK" );
status = pthread_barrierattr_init( &attr ); status = pthread_barrierattr_init( &attr );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_barrierattr_setpshared( &attr, private ) -- OK" ); puts( "pthread_barrierattr_setpshared( &attr, private ) -- OK" );
status = pthread_barrierattr_setpshared( &attr, PTHREAD_PROCESS_PRIVATE ); status = pthread_barrierattr_setpshared( &attr, PTHREAD_PROCESS_PRIVATE );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_barrierattr_getpshared( &attr, &p ) -- OK" ); puts( "pthread_barrierattr_getpshared( &attr, &p ) -- OK" );
status = pthread_barrierattr_getpshared( &attr, &p ); status = pthread_barrierattr_getpshared( &attr, &p );
assert( status == 0 ); rtems_test_assert( status == 0 );
assert( p == PTHREAD_PROCESS_PRIVATE ); rtems_test_assert( p == PTHREAD_PROCESS_PRIVATE );
puts( "pthread_barrierattr_setpshared( &attr, shared ) -- OK" ); puts( "pthread_barrierattr_setpshared( &attr, shared ) -- OK" );
status = pthread_barrierattr_setpshared( &attr, PTHREAD_PROCESS_SHARED ); status = pthread_barrierattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_barrierattr_getpshared( &attr, &p ) -- OK" ); puts( "pthread_barrierattr_getpshared( &attr, &p ) -- OK" );
status = pthread_barrierattr_getpshared( &attr, &p ); status = pthread_barrierattr_getpshared( &attr, &p );
assert( status == 0 ); rtems_test_assert( status == 0 );
assert( p == PTHREAD_PROCESS_SHARED ); rtems_test_assert( p == PTHREAD_PROCESS_SHARED );
/*************** BAD PSHARED CHECK *****************/ /*************** BAD PSHARED CHECK *****************/
puts( "pthread_barrierattr_setpshared( &attr, private ) -- EINVAL" ); puts( "pthread_barrierattr_setpshared( &attr, private ) -- EINVAL" );
status = pthread_barrierattr_setpshared( &attr, ~PTHREAD_PROCESS_PRIVATE ); status = pthread_barrierattr_setpshared( &attr, ~PTHREAD_PROCESS_PRIVATE );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/*************** DESTROY/REUSE CHECK *****************/ /*************** DESTROY/REUSE CHECK *****************/
puts( "pthread_barrierattr_destroy( &attr ) -- OK" ); puts( "pthread_barrierattr_destroy( &attr ) -- OK" );
status = pthread_barrierattr_destroy( &attr ); status = pthread_barrierattr_destroy( &attr );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_barrierattr_getpshared( &attr, &p ) destroyed -- EINVAL" ); puts( "pthread_barrierattr_getpshared( &attr, &p ) destroyed -- EINVAL" );
status = pthread_barrierattr_getpshared( &attr, &p ); status = pthread_barrierattr_getpshared( &attr, &p );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/*************** pthread_barrier_init ERROR CHECKs *********/ /*************** pthread_barrier_init ERROR CHECKs *********/
/* NULL barrier argument */ /* NULL barrier argument */
puts( "pthread_barrier_init( NULL, NULL, 2 ) -- EINVAL" ); puts( "pthread_barrier_init( NULL, NULL, 2 ) -- EINVAL" );
status = pthread_barrier_init( NULL, NULL, 2 ); status = pthread_barrier_init( NULL, NULL, 2 );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* uninitialized attr argument */ /* uninitialized attr argument */
puts( "pthread_barrier_init( &barrier, &attr, 2 ) -- EINVAL" ); puts( "pthread_barrier_init( &barrier, &attr, 2 ) -- EINVAL" );
status = pthread_barrier_init( &barrier, &attr, 2 ); status = pthread_barrier_init( &barrier, &attr, 2 );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* zero count argument */ /* zero count argument */
puts( "pthread_barrierattr_init( &attr ) -- OK" ); puts( "pthread_barrierattr_init( &attr ) -- OK" );
status = pthread_barrierattr_init( &attr ); status = pthread_barrierattr_init( &attr );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_barrier_init( &barrier, &attr, 0 ) -- EINVAL" ); puts( "pthread_barrier_init( &barrier, &attr, 0 ) -- EINVAL" );
status = pthread_barrier_init( &barrier, &attr, 0 ); status = pthread_barrier_init( &barrier, &attr, 0 );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* allocating too many */ /* allocating too many */
puts( "pthread_barrier_init( &barrier, NULL, 1 ) -- OK" ); puts( "pthread_barrier_init( &barrier, NULL, 1 ) -- OK" );
status = pthread_barrier_init( &barrier, NULL, 1 ); status = pthread_barrier_init( &barrier, NULL, 1 );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_barrier_init( &barrier, NULL, 1 ) -- EAGAIN" ); puts( "pthread_barrier_init( &barrier, NULL, 1 ) -- EAGAIN" );
status = pthread_barrier_init( &barrier, NULL, 1 ); status = pthread_barrier_init( &barrier, NULL, 1 );
assert( status == EAGAIN ); rtems_test_assert( status == EAGAIN );
/* clean up */ /* clean up */
puts( "pthread_barrier_destroy( &barrier ) -- OK" ); puts( "pthread_barrier_destroy( &barrier ) -- OK" );
status = pthread_barrier_destroy( &barrier ); status = pthread_barrier_destroy( &barrier );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_barrierattr_destroy( &attr ) -- OK" ); puts( "pthread_barrierattr_destroy( &attr ) -- OK" );
status = pthread_barrierattr_destroy( &attr ); status = pthread_barrierattr_destroy( &attr );
assert( status == 0 ); rtems_test_assert( status == 0 );
/*************** pthread_barrier_destroy ERROR CHECKs *********/ /*************** pthread_barrier_destroy ERROR CHECKs *********/
/* NULL barrier argument */ /* NULL barrier argument */
puts( "pthread_barrier_destroy( NULL ) -- EINVAL" ); puts( "pthread_barrier_destroy( NULL ) -- EINVAL" );
status = pthread_barrier_destroy( NULL ); status = pthread_barrier_destroy( NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_barrier_destroy( &bad_barrier ) -- EINVAL" ); puts( "pthread_barrier_destroy( &bad_barrier ) -- EINVAL" );
status = pthread_barrier_destroy( &bad_barrier ); status = pthread_barrier_destroy( &bad_barrier );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/*************** pthread_barrier_wait ERROR CHECKs *********/ /*************** pthread_barrier_wait ERROR CHECKs *********/
/* NULL barrier argument */ /* NULL barrier argument */
puts( "pthread_barrier_wait( NULL ) -- EINVAL" ); puts( "pthread_barrier_wait( NULL ) -- EINVAL" );
status = pthread_barrier_wait( NULL ); status = pthread_barrier_wait( NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_barrier_wait( &bad_barrier ) -- EINVAL" ); puts( "pthread_barrier_wait( &bad_barrier ) -- EINVAL" );
status = pthread_barrier_wait( &bad_barrier ); status = pthread_barrier_wait( &bad_barrier );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/*************** ACTUALLY CREATE ONE CHECK *****************/ /*************** ACTUALLY CREATE ONE CHECK *****************/
puts( "pthread_barrierattr_init( &attr ) -- OK" ); puts( "pthread_barrierattr_init( &attr ) -- OK" );
status = pthread_barrierattr_init( &attr ); status = pthread_barrierattr_init( &attr );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_barrier_init( &barrier, &attr, 2 ) -- OK" ); puts( "pthread_barrier_init( &barrier, &attr, 2 ) -- OK" );
status = pthread_barrier_init( &barrier, &attr, 2 ); status = pthread_barrier_init( &barrier, &attr, 2 );
assert( status == 0 ); rtems_test_assert( status == 0 );
assert( barrier != 0 ); rtems_test_assert( barrier != 0 );
puts( "pthread_barrier_destroy( &barrier ) -- OK" ); puts( "pthread_barrier_destroy( &barrier ) -- OK" );
status = pthread_barrier_destroy( &barrier ); status = pthread_barrier_destroy( &barrier );
assert( status == 0 ); rtems_test_assert( status == 0 );
/*************** CREATE THREADS AND LET THEM RELEASE *****************/ /*************** CREATE THREADS AND LET THEM RELEASE *****************/
puts( "pthread_barrier_init( &Barrier, &attr, NUMBER_THREADS ) -- OK" ); puts( "pthread_barrier_init( &Barrier, &attr, NUMBER_THREADS ) -- OK" );
status = pthread_barrier_init( &Barrier, &attr, NUMBER_THREADS ); status = pthread_barrier_init( &Barrier, &attr, NUMBER_THREADS );
assert( status == 0 ); rtems_test_assert( status == 0 );
assert( barrier != 0 ); rtems_test_assert( barrier != 0 );
for (i=0 ; i<NUMBER_THREADS ; i++ ) { for (i=0 ; i<NUMBER_THREADS ; i++ ) {
@@ -222,13 +221,13 @@ int main(
if (i == NUMBER_THREADS - 1) { if (i == NUMBER_THREADS - 1) {
puts( "pthread_barrier_destroy( &Barrier ) -- EBUSY" ); puts( "pthread_barrier_destroy( &Barrier ) -- EBUSY" );
status = pthread_barrier_destroy( &Barrier ); status = pthread_barrier_destroy( &Barrier );
assert( status == EBUSY ); rtems_test_assert( status == EBUSY );
} }
/* create a thread to block on the barrier */ /* create a thread to block on the barrier */
printf( "Init: pthread_create - thread %d OK\n", i+1 ); printf( "Init: pthread_create - thread %d OK\n", i+1 );
status = pthread_create(&ThreadIds[i], NULL, BarrierThread, &ThreadIds[i]); status = pthread_create(&ThreadIds[i], NULL, BarrierThread, &ThreadIds[i]);
assert( !status ); rtems_test_assert( !status );
sleep(1); sleep(1);
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -63,7 +63,7 @@ void doit(
TSR_status = 0; TSR_status = 0;
status = rtems_timer_fire_after( timer_id, 10, TSR, NULL ); status = rtems_timer_fire_after( timer_id, 10, TSR, NULL );
assert( !status ); rtems_test_assert( !status );
start = rtems_clock_get_ticks_since_boot(); start = rtems_clock_get_ticks_since_boot();
do { do {
@@ -94,7 +94,7 @@ void *POSIX_Init(
rtems_build_name( 'T', 'M', '1', ' ' ), rtems_build_name( 'T', 'M', '1', ' ' ),
&timer_id &timer_id
); );
assert( !status ); rtems_test_assert( !status );
doit( Cancel_duringISR_TSR, "pthread_cancel" ); doit( Cancel_duringISR_TSR, "pthread_cancel" );
doit( SetState_duringISR_TSR, "pthread_setcancelstate" ); doit( SetState_duringISR_TSR, "pthread_setcancelstate" );

View File

@@ -15,7 +15,12 @@
* implementation of this appears to seek to the ((off/DIRENT_SIZE) + 1) * implementation of this appears to seek to the ((off/DIRENT_SIZE) + 1)
* record where DIRENT_SIZE seems to be 12 bytes. * record where DIRENT_SIZE seems to be 12 bytes.
* *
* 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$ * $Id$
*/ */
@@ -24,7 +29,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <rtems/libio.h> #include <rtems/libio.h>
@@ -35,10 +39,10 @@ void touch( char *file )
{ {
int fd; int fd;
assert( file ); rtems_test_assert( file );
fd = open( file, O_RDWR|O_CREAT, 0777 ); fd = open( file, O_RDWR|O_CREAT, 0777 );
assert( fd != -1 ); rtems_test_assert( fd != -1 );
close( fd ); close( fd );
} }
@@ -47,7 +51,7 @@ int fileexists( char *file )
int status; int status;
struct stat statbuf; struct stat statbuf;
assert( file ); rtems_test_assert( file );
status = stat( file, &statbuf ); status = stat( file, &statbuf );
@@ -86,19 +90,19 @@ int main(
printf( "\n\n*** CHROOT01 TEST ***\n" ); printf( "\n\n*** CHROOT01 TEST ***\n" );
status = mkdir( "/one", 0777); status = mkdir( "/one", 0777);
assert( status == 0 ); rtems_test_assert( status == 0 );
status = mkdir( "/one/one", 0777); status = mkdir( "/one/one", 0777);
assert( status == 0 ); rtems_test_assert( status == 0 );
status = mkdir( "/one/two", 0777); status = mkdir( "/one/two", 0777);
assert( status == 0 ); rtems_test_assert( status == 0 );
touch( "/one/one.test" ); touch( "/one/one.test" );
touch( "/one/two/two.test" ); touch( "/one/two/two.test" );
status = chroot( "/one" ); status = chroot( "/one" );
assert( status == 0 ); rtems_test_assert( status == 0 );
status = fileexists( "/one/one.test" ); status = fileexists( "/one/one.test" );
printf( "%s on /one/one.test\n", (!status) ? "SUCCESS" : "FAILURE" ); printf( "%s on /one/one.test\n", (!status) ? "SUCCESS" : "FAILURE" );

View File

@@ -210,7 +210,7 @@ rtems_task Init(
delay_request.tv_sec = 1; delay_request.tv_sec = 1;
delay_request.tv_nsec = 35000000; delay_request.tv_nsec = 35000000;
sc = nanosleep( &delay_request, NULL ); sc = nanosleep( &delay_request, NULL );
assert( !sc ); rtems_test_assert( !sc );
/* print the current real time again */ /* print the current real time again */
sc = clock_gettime( CLOCK_REALTIME, &tv ); sc = clock_gettime( CLOCK_REALTIME, &tv );

View File

@@ -31,7 +31,6 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <assert.h>
#include <rtems.h> #include <rtems.h>
#include <rtems/libio.h> #include <rtems/libio.h>
@@ -100,7 +99,7 @@ void stat_a_file(
int status; int status;
struct stat statbuf; struct stat statbuf;
assert( file ); rtems_test_assert( file );
printf( "stat( %s ) returned ", file ); printf( "stat( %s ) returned ", file );
fflush( stdout ); fflush( stdout );
@@ -169,7 +168,7 @@ int main(
puts( "stat of /dev/console" ); puts( "stat of /dev/console" );
status = stat( "/dev/console", &buf ); status = stat( "/dev/console", &buf );
assert( !status ); rtems_test_assert( !status );
dump_statbuf( &buf ); dump_statbuf( &buf );
@@ -180,47 +179,47 @@ int main(
puts( "" ); puts( "" );
puts( "mkdir /dev/tty" ); puts( "mkdir /dev/tty" );
status = mkdir( "/dev/tty", S_IRWXU ); status = mkdir( "/dev/tty", S_IRWXU );
assert( !status ); rtems_test_assert( !status );
puts( "" ); puts( "" );
puts( "mkdir /usr" ); puts( "mkdir /usr" );
status = mkdir( "/usr", S_IRWXU ); status = mkdir( "/usr", S_IRWXU );
assert( !status ); rtems_test_assert( !status );
puts( "mkdir /etc" ); puts( "mkdir /etc" );
status = mkdir( "/etc", S_IRWXU ); status = mkdir( "/etc", S_IRWXU );
assert( !status ); rtems_test_assert( !status );
puts( "mkdir /tmp" ); puts( "mkdir /tmp" );
status = mkdir( "/tmp", S_IRWXU ); status = mkdir( "/tmp", S_IRWXU );
assert( !status ); rtems_test_assert( !status );
/* this tests the ".." path in path name evaluation */ /* this tests the ".." path in path name evaluation */
puts( "mkdir /tmp/.." ); puts( "mkdir /tmp/.." );
status = mkdir( "/tmp/..", S_IRWXU ); status = mkdir( "/tmp/..", S_IRWXU );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EEXIST ); rtems_test_assert( errno == EEXIST );
/* now check out trailing separators */ /* now check out trailing separators */
puts( "mkdir /tmp/" ); puts( "mkdir /tmp/" );
status = mkdir( "/tmp/", S_IRWXU ); status = mkdir( "/tmp/", S_IRWXU );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EEXIST ); rtems_test_assert( errno == EEXIST );
/* try to make a directory under a non-existent subdirectory */ /* try to make a directory under a non-existent subdirectory */
puts( "mkdir /j/j1" ); puts( "mkdir /j/j1" );
status = mkdir( "/j/j1", S_IRWXU ); status = mkdir( "/j/j1", S_IRWXU );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == ENOENT ); rtems_test_assert( errno == ENOENT );
/* this tests the ability to make a directory in the current one */ /* this tests the ability to make a directory in the current one */
puts( "mkdir tmp" ); puts( "mkdir tmp" );
status = mkdir( "tmp", S_IRWXU ); status = mkdir( "tmp", S_IRWXU );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EEXIST ); rtems_test_assert( errno == EEXIST );
/* test rtems_filesystem_evaluate_path by sending NULL path */ /* test rtems_filesystem_evaluate_path by sending NULL path */
status = chdir( NULL ); status = chdir( NULL );
assert( status == -1 ); rtems_test_assert( status == -1 );
/* /*
* Now switch gears and exercise rmdir(). * Now switch gears and exercise rmdir().
@@ -229,37 +228,37 @@ int main(
puts( "" ); puts( "" );
puts( "rmdir /usr" ); puts( "rmdir /usr" );
status = rmdir( "/usr" ); status = rmdir( "/usr" );
assert( !status ); rtems_test_assert( !status );
puts( "rmdir /dev" ); puts( "rmdir /dev" );
status = rmdir( "/dev" ); status = rmdir( "/dev" );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == ENOTEMPTY); rtems_test_assert( errno == ENOTEMPTY);
puts( "rmdir /fred" ); puts( "rmdir /fred" );
status = rmdir ("/fred"); status = rmdir ("/fred");
assert (status == -1); rtems_test_assert (status == -1);
assert( errno == ENOENT ); rtems_test_assert( errno == ENOENT );
puts( "mknod /dev/test_console" ); puts( "mknod /dev/test_console" );
status = mknod( "/dev/test_console", S_IFCHR, 0LL ); status = mknod( "/dev/test_console", S_IFCHR, 0LL );
assert( !status ); rtems_test_assert( !status );
puts( "mknod /dev/tty/S3" ); puts( "mknod /dev/tty/S3" );
status = mknod( "/dev/tty/S3", S_IFCHR, 0xFF00000080LL ); status = mknod( "/dev/tty/S3", S_IFCHR, 0xFF00000080LL );
assert( !status ); rtems_test_assert( !status );
puts ("mknod /etc/passwd"); puts ("mknod /etc/passwd");
status = mknod( "/etc/passwd", (S_IFREG | S_IRWXU), 0LL ); status = mknod( "/etc/passwd", (S_IFREG | S_IRWXU), 0LL );
assert( !status ); rtems_test_assert( !status );
puts( "mkdir /tmp/my_dir"); puts( "mkdir /tmp/my_dir");
status = mkdir( "/tmp/my_dir", S_IRWXU ); status = mkdir( "/tmp/my_dir", S_IRWXU );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts("mkfifo /c/my_dir" ); puts("mkfifo /c/my_dir" );
status = mkfifo( "/c/my_dir", S_IRWXU ); status = mkfifo( "/c/my_dir", S_IRWXU );
assert( status == -1 ); rtems_test_assert( status == -1 );
/* /*
* Try to make a directory under a file -- ERROR * Try to make a directory under a file -- ERROR
@@ -267,8 +266,8 @@ int main(
puts( "mkdir /etc/passwd/j" ); puts( "mkdir /etc/passwd/j" );
status = mkdir( "/etc/passwd/j", S_IRWXU ); status = mkdir( "/etc/passwd/j", S_IRWXU );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == ENOTDIR ); rtems_test_assert( errno == ENOTDIR );
/* /*
* Simple open failure case on non-existent file * Simple open failure case on non-existent file
@@ -276,8 +275,8 @@ int main(
puts( "open /tmp/joel - should fail with ENOENT" ); puts( "open /tmp/joel - should fail with ENOENT" );
fd = open( "/tmp/joel", O_RDONLY ); fd = open( "/tmp/joel", O_RDONLY );
assert( fd == -1 ); rtems_test_assert( fd == -1 );
assert( errno == ENOENT ); rtems_test_assert( errno == ENOENT );
/* /*
* Simple open case where the file is created. * Simple open case where the file is created.
@@ -285,24 +284,24 @@ int main(
puts( "open /tmp/j" ); puts( "open /tmp/j" );
fd = open( "/tmp/j", O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO ); fd = open( "/tmp/j", O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO );
assert( fd != -1 ); rtems_test_assert( fd != -1 );
printf( "open returned file descriptor %d\n", fd ); printf( "open returned file descriptor %d\n", fd );
puts( "close /tmp/j" ); puts( "close /tmp/j" );
status = close( fd ); status = close( fd );
assert( !status ); rtems_test_assert( !status );
puts( "close /tmp/j again" ); puts( "close /tmp/j again" );
status = close( fd ); status = close( fd );
assert( status == -1 ); rtems_test_assert( status == -1 );
puts( "unlink /tmp/j" ); puts( "unlink /tmp/j" );
status = unlink( "/tmp/j" ); status = unlink( "/tmp/j" );
assert( !status ); rtems_test_assert( !status );
puts( "unlink /tmp" ); puts( "unlink /tmp" );
status = unlink( "/tmp" ); status = unlink( "/tmp" );
assert( status ); rtems_test_assert( status );
/* /*
* Simple open failure. Trying to create an existing file. * Simple open failure. Trying to create an existing file.
@@ -310,22 +309,22 @@ int main(
puts("create and close /tmp/tom"); puts("create and close /tmp/tom");
fd = open( "/tmp/tom", O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO ); fd = open( "/tmp/tom", O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO );
assert( fd != -1 ); rtems_test_assert( fd != -1 );
status = close( fd ); status = close( fd );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts("Attempt to recreate /tmp/tom"); puts("Attempt to recreate /tmp/tom");
fd = open( "/tmp/tom", O_CREAT | O_EXCL, S_IRWXU|S_IRWXG|S_IRWXO ); fd = open( "/tmp/tom", O_CREAT | O_EXCL, S_IRWXU|S_IRWXG|S_IRWXO );
assert( fd == -1 ); rtems_test_assert( fd == -1 );
assert( errno == EEXIST ); rtems_test_assert( errno == EEXIST );
puts("create /tmp/john"); puts("create /tmp/john");
fd = open( "/tmp/john", O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO ); fd = open( "/tmp/john", O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO );
assert( fd != -1 ); rtems_test_assert( fd != -1 );
puts("tcdrain /tmp/john" ); puts("tcdrain /tmp/john" );
status = tcdrain( fd ); status = tcdrain( fd );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* /*
* Test simple write to a file at offset 0 * Test simple write to a file at offset 0
@@ -341,10 +340,10 @@ int main(
*/ */
status = unlink( "/tmp/joel" ); status = unlink( "/tmp/joel" );
assert( !status ); rtems_test_assert( !status );
status = mknod( "/tmp/joel", (S_IFREG | S_IRWXU), 0LL ); status = mknod( "/tmp/joel", (S_IFREG | S_IRWXU), 0LL );
assert( !status ); rtems_test_assert( !status );
test_write( "/tmp/joel", 10, "the first write!!!\n" ); test_write( "/tmp/joel", 10, "the first write!!!\n" );
test_cat( "/tmp/joel", 0, 0 ); test_cat( "/tmp/joel", 0, 0 );
@@ -357,17 +356,17 @@ int main(
puts("unlink /tmp/joel"); puts("unlink /tmp/joel");
status = unlink( "/tmp/joel" ); status = unlink( "/tmp/joel" );
assert( !status ); rtems_test_assert( !status );
/* Test a failure path */ /* Test a failure path */
puts( "unlink /tmp/joel" ); puts( "unlink /tmp/joel" );
status = unlink( "/tmp/joel" ); status = unlink( "/tmp/joel" );
assert( status == -1 ); rtems_test_assert( status == -1 );
puts( "mknod /tmp/joel"); puts( "mknod /tmp/joel");
status = mknod( "/tmp/joel", (S_IFREG | S_IRWXU), 0LL ); status = mknod( "/tmp/joel", (S_IFREG | S_IRWXU), 0LL );
assert( !status ); rtems_test_assert( !status );
test_write( "/tmp/joel", 514, "the first write!!!\n" ); test_write( "/tmp/joel", 514, "the first write!!!\n" );
test_write( "/tmp/joel", 1, test_write_buffer ); test_write( "/tmp/joel", 1, test_write_buffer );
@@ -410,19 +409,19 @@ int main(
puts( "fopen of /tmp/j" ); puts( "fopen of /tmp/j" );
file = fopen( "/tmp/j", "w+" ); file = fopen( "/tmp/j", "w+" );
assert( file ); rtems_test_assert( file );
puts( "fprintf to /tmp/j" ); puts( "fprintf to /tmp/j" );
for (i=1 ; i<=5 ; i++) { for (i=1 ; i<=5 ; i++) {
status = fprintf( file, "This is call %d to fprintf\n", i ); status = fprintf( file, "This is call %d to fprintf\n", i );
assert( status ); rtems_test_assert( status );
printf( "(%d) %d characters written to the file\n", i, status ); printf( "(%d) %d characters written to the file\n", i, status );
} }
fflush( file ); fflush( file );
status = stat( "/tmp/j", &buf ); status = stat( "/tmp/j", &buf );
assert( !status ); rtems_test_assert( !status );
dump_statbuf( &buf ); dump_statbuf( &buf );
atime2 = buf.st_atime; atime2 = buf.st_atime;
mtime2 = buf.st_mtime; mtime2 = buf.st_mtime;
@@ -438,14 +437,14 @@ int main(
* Verify only atime changed for a read. * Verify only atime changed for a read.
*/ */
status = stat( "/tmp/j", &buf ); status = stat( "/tmp/j", &buf );
assert( !status ); rtems_test_assert( !status );
dump_statbuf( &buf ); dump_statbuf( &buf );
atime1 = buf.st_atime; atime1 = buf.st_atime;
mtime1 = buf.st_mtime; mtime1 = buf.st_mtime;
ctime1 = buf.st_ctime; ctime1 = buf.st_ctime;
assert( atime1 != atime2); rtems_test_assert( atime1 != atime2);
assert( mtime1 == mtime2); rtems_test_assert( mtime1 == mtime2);
assert( ctime1 == ctime2); rtems_test_assert( ctime1 == ctime2);
IMFS_dump(); IMFS_dump();
@@ -458,41 +457,41 @@ int main(
status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() ); status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
puts( "truncate /tmp/j to length of 40" ); puts( "truncate /tmp/j to length of 40" );
status = truncate( "/tmp/j", 40 ); status = truncate( "/tmp/j", 40 );
assert( !status ); rtems_test_assert( !status );
/* /*
* Verify truncate changed only atime. * Verify truncate changed only atime.
*/ */
status = stat( "/tmp/j", &buf ); status = stat( "/tmp/j", &buf );
assert( !status ); rtems_test_assert( !status );
dump_statbuf( &buf ); dump_statbuf( &buf );
atime2 = buf.st_atime; atime2 = buf.st_atime;
mtime2 = buf.st_mtime; mtime2 = buf.st_mtime;
ctime2 = buf.st_ctime; ctime2 = buf.st_ctime;
assert( atime1 != atime2); rtems_test_assert( atime1 != atime2);
assert( mtime1 == mtime2); rtems_test_assert( mtime1 == mtime2);
assert( ctime1 == ctime2); rtems_test_assert( ctime1 == ctime2);
IMFS_dump(); IMFS_dump();
/* try to truncate the console and see what happens */ /* try to truncate the console and see what happens */
status = truncate( "/dev/console", 40 ); status = truncate( "/dev/console", 40 );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "truncate /tmp/j to length of 0" ); puts( "truncate /tmp/j to length of 0" );
status = truncate( "/tmp/j", 0 ); status = truncate( "/tmp/j", 0 );
assert( !status ); rtems_test_assert( !status );
puts( "truncate /tmp to length of 0 should fail with EISDIR\n"); puts( "truncate /tmp to length of 0 should fail with EISDIR\n");
status = truncate( "/tmp", 0 ); status = truncate( "/tmp", 0 );
assert( status == -1 ); rtems_test_assert( status == -1 );
printf( "%d: %s\n", errno, strerror( errno ) ); printf( "%d: %s\n", errno, strerror( errno ) );
assert( errno == EISDIR ); rtems_test_assert( errno == EISDIR );
IMFS_dump(); IMFS_dump();
status = truncate( "/tmp/fred", 10 ); status = truncate( "/tmp/fred", 10 );
assert( status == -1); rtems_test_assert( status == -1);
rtems_status = rtems_io_register_name( "/dev/console", 0, 0 ); rtems_status = rtems_io_register_name( "/dev/console", 0, 0 );

View File

@@ -2,6 +2,14 @@
* A test support function which performs a crude version of * A test support function which performs a crude version of
* "cat" so you can look at specific parts of a file. * "cat" so you can look at specific parts of a file.
* *
* 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$ * $Id$
*/ */
@@ -15,8 +23,6 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <assert.h>
#include <pmacros.h> #include <pmacros.h>
/* /*
@@ -41,7 +47,7 @@ void test_cat(
off_t offset = (off_t)offset_arg; off_t offset = (off_t)offset_arg;
my_length = (length) ? length : sizeof( test_cat_buffer ); my_length = (length) ? length : sizeof( test_cat_buffer );
assert( my_length <= sizeof( test_cat_buffer ) ); rtems_test_assert( my_length <= sizeof( test_cat_buffer ) );
fd = open( file, O_RDONLY ); fd = open( file, O_RDONLY );
if ( fd == -1 ) { if ( fd == -1 ) {
@@ -51,7 +57,7 @@ void test_cat(
for ( ;; ) { for ( ;; ) {
status = lseek( fd, offset, SEEK_SET ); status = lseek( fd, offset, SEEK_SET );
assert( status != -1 ); rtems_test_assert( status != -1 );
status = read( fd, test_cat_buffer, sizeof(test_cat_buffer) ); status = read( fd, test_cat_buffer, sizeof(test_cat_buffer) );
if ( status <= 0 ) { if ( status <= 0 ) {
@@ -79,5 +85,5 @@ void test_cat(
} }
status = close( fd ); status = close( fd );
assert( !status ); rtems_test_assert( !status );
} }

View File

@@ -6,6 +6,13 @@
* The defined behavior is a seek() followed by a write() extends the file * The defined behavior is a seek() followed by a write() extends the file
* and zero fills the new length part. * and zero fills the new length part.
* *
* 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$ * $Id$
*/ */
@@ -19,8 +26,6 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <assert.h>
#include <pmacros.h> #include <pmacros.h>
/* /*
@@ -43,7 +48,7 @@ void test_extend(
} }
status = lseek( fd, offset - 1, SEEK_SET ); status = lseek( fd, offset - 1, SEEK_SET );
assert( status != -1 ); rtems_test_assert( status != -1 );
status = write( fd, &c, 1 ); status = write( fd, &c, 1 );
if ( status == -1 ) { if ( status == -1 ) {
@@ -58,5 +63,5 @@ void test_extend(
} }
status = close( fd ); status = close( fd );
assert( !status ); rtems_test_assert( !status );
} }

View File

@@ -2,6 +2,13 @@
* A test support function which performs a write() and * A test support function which performs a write() and
* handles implied open(), lseek(), write(), and close() operations. * handles implied open(), lseek(), write(), and close() operations.
* *
* 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$ * $Id$
*/ */
@@ -14,8 +21,6 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include <pmacros.h> #include <pmacros.h>
/* /*
@@ -42,7 +47,7 @@ void test_write(
} }
status = lseek( fd, offset, SEEK_SET ); status = lseek( fd, offset, SEEK_SET );
assert( status != -1 ); rtems_test_assert( status != -1 );
status = write( fd, buffer, length ); status = write( fd, buffer, length );
if ( status == -1 ) { if ( status == -1 ) {
@@ -57,5 +62,5 @@ void test_write(
} }
status = close( fd ); status = close( fd );
assert( !status ); rtems_test_assert( !status );
} }

View File

@@ -26,48 +26,48 @@ void *POSIX_Init(
/* test getitimer stub */ /* test getitimer stub */
puts( "getitimer -- bad which - EINVAL " ); puts( "getitimer -- bad which - EINVAL " );
status = getitimer( 1234, &itimer ); status = getitimer( 1234, &itimer );
assert( status == -1 && errno == EINVAL ); rtems_test_assert( status == -1 && errno == EINVAL );
puts( "getitimer -- NULL pointer - EFAULT " ); puts( "getitimer -- NULL pointer - EFAULT " );
status = getitimer( ITIMER_REAL, NULL ); status = getitimer( ITIMER_REAL, NULL );
assert( status == -1 && errno == EFAULT ); rtems_test_assert( status == -1 && errno == EFAULT );
puts( "getitimer -- ITIMER_REAL - ENOSYS " ); puts( "getitimer -- ITIMER_REAL - ENOSYS " );
status = getitimer( ITIMER_REAL, &itimer ); status = getitimer( ITIMER_REAL, &itimer );
assert( status == -1 && errno == ENOSYS ); rtems_test_assert( status == -1 && errno == ENOSYS );
puts( "getitimer -- ITIMER_VIRTUAL - ENOSYS " ); puts( "getitimer -- ITIMER_VIRTUAL - ENOSYS " );
status = getitimer( ITIMER_VIRTUAL, &itimer ); status = getitimer( ITIMER_VIRTUAL, &itimer );
assert( status == -1 && errno == ENOSYS ); rtems_test_assert( status == -1 && errno == ENOSYS );
puts( "getitimer -- ITIMER_PROF - ENOSYS " ); puts( "getitimer -- ITIMER_PROF - ENOSYS " );
status = getitimer( ITIMER_PROF, &itimer ); status = getitimer( ITIMER_PROF, &itimer );
assert( status == -1 && errno == ENOSYS ); rtems_test_assert( status == -1 && errno == ENOSYS );
/* test setitimer stub */ /* test setitimer stub */
puts( "setitimer -- bad which - EINVAL " ); puts( "setitimer -- bad which - EINVAL " );
status = setitimer( 1234, &itimer, &otimer ); status = setitimer( 1234, &itimer, &otimer );
assert( status == -1 && errno == EINVAL ); rtems_test_assert( status == -1 && errno == EINVAL );
puts( "setitimer -- NULL value pointer - EFAULT " ); puts( "setitimer -- NULL value pointer - EFAULT " );
status = setitimer( ITIMER_REAL, NULL, &otimer ); status = setitimer( ITIMER_REAL, NULL, &otimer );
assert( status == -1 && errno == EFAULT ); rtems_test_assert( status == -1 && errno == EFAULT );
puts( "setitimer -- NULL value pointer - EFAULT " ); puts( "setitimer -- NULL value pointer - EFAULT " );
status = setitimer( ITIMER_REAL, &itimer, NULL ); status = setitimer( ITIMER_REAL, &itimer, NULL );
assert( status == -1 && errno == EFAULT ); rtems_test_assert( status == -1 && errno == EFAULT );
puts( "setitimer -- ITIMER_REAL - ENOSYS " ); puts( "setitimer -- ITIMER_REAL - ENOSYS " );
status = setitimer( ITIMER_REAL, &itimer, &otimer ); status = setitimer( ITIMER_REAL, &itimer, &otimer );
assert( status == -1 && errno == ENOSYS ); rtems_test_assert( status == -1 && errno == ENOSYS );
puts( "setitimer -- ITIMER_VIRTUAL - ENOSYS " ); puts( "setitimer -- ITIMER_VIRTUAL - ENOSYS " );
status = setitimer( ITIMER_VIRTUAL, &itimer, &otimer ); status = setitimer( ITIMER_VIRTUAL, &itimer, &otimer );
assert( status == -1 && errno == ENOSYS ); rtems_test_assert( status == -1 && errno == ENOSYS );
puts( "setitimer -- ITIMER_PROF - ENOSYS " ); puts( "setitimer -- ITIMER_PROF - ENOSYS " );
status = setitimer( ITIMER_PROF, &itimer, &otimer ); status = setitimer( ITIMER_PROF, &itimer, &otimer );
assert( status == -1 && errno == ENOSYS ); rtems_test_assert( status == -1 && errno == ENOSYS );
puts( "*** END OF POSIX TEST ITIMER ***" ); puts( "*** END OF POSIX TEST ITIMER ***" );
rtems_test_exit(0); rtems_test_exit(0);

View File

@@ -8,7 +8,7 @@
* *
* Output parameters: NONE * Output parameters: NONE
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -34,14 +34,14 @@ void *Task_1(
status = pthread_setspecific( Key_id[0], (void *)&Data_array[ 1 ] ); status = pthread_setspecific( Key_id[0], (void *)&Data_array[ 1 ] );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
key_data = pthread_getspecific( Key_id[0] ); key_data = pthread_getspecific( Key_id[0] );
printf( "Task_1: Got the key value of %ld\n", printf( "Task_1: Got the key value of %ld\n",
(unsigned long) ((uint32_t *)key_data - Data_array) ); (unsigned long) ((uint32_t *)key_data - Data_array) );
if ( status ) if ( status )
printf( "status = %d\n", status ); printf( "status = %d\n", status );
assert( !status ); rtems_test_assert( !status );
puts( "Task_1: exitting" ); puts( "Task_1: exitting" );
pthread_exit( NULL ); pthread_exit( NULL );

View File

@@ -30,13 +30,13 @@ void *POSIX_Init(
puts( "Init - rtems_workspace_get_information - OK" ); puts( "Init - rtems_workspace_get_information - OK" );
sb = rtems_workspace_get_information( &start ); sb = rtems_workspace_get_information( &start );
assert( sb ); rtems_test_assert( sb );
#if 0 #if 0
printf( "Init - workspace free = %d\n", start.Free.largest ); printf( "Init - workspace free = %d\n", start.Free.largest );
printf( "Init - workspace free blocks = %d\n", start.Free.number ); printf( "Init - workspace free blocks = %d\n", start.Free.number );
#endif #endif
assert( start.Free.number == 1 ); rtems_test_assert( start.Free.number == 1 );
to_alloc = start.Free.largest; to_alloc = start.Free.largest;
/* find the largest we can actually allocate */ /* find the largest we can actually allocate */
@@ -57,15 +57,15 @@ void *POSIX_Init(
* Verify heap is still in same shape if we couldn't allocate a task * Verify heap is still in same shape if we couldn't allocate a task
*/ */
sb = rtems_workspace_get_information( &info ); sb = rtems_workspace_get_information( &info );
assert( sb ); rtems_test_assert( sb );
assert( info.Free.largest == start.Free.largest ); rtems_test_assert( info.Free.largest == start.Free.largest );
assert( info.Free.number == start.Free.number ); rtems_test_assert( info.Free.number == start.Free.number );
puts( "Init - pthread_key_create - ENOMEM" ); puts( "Init - pthread_key_create - ENOMEM" );
while (1) { while (1) {
sb = rtems_workspace_allocate( to_alloc, &alloced ); sb = rtems_workspace_allocate( to_alloc, &alloced );
assert( sb ); rtems_test_assert( sb );
sc = pthread_key_create( &key, NULL ); sc = pthread_key_create( &key, NULL );
@@ -88,9 +88,9 @@ void *POSIX_Init(
printf( "Init - workspace free/blocks = %d/%d\n", printf( "Init - workspace free/blocks = %d/%d\n",
info.Free.largest, info.Free.number ); info.Free.largest, info.Free.number );
#endif #endif
assert( sb ); rtems_test_assert( sb );
assert( info.Free.largest == start.Free.largest ); rtems_test_assert( info.Free.largest == start.Free.largest );
assert( info.Free.number == start.Free.number ); rtems_test_assert( info.Free.number == start.Free.number );
to_alloc -= 8; to_alloc -= 8;
if ( to_alloc == 0 ) if ( to_alloc == 0 )
@@ -105,7 +105,7 @@ void *POSIX_Init(
*/ */
puts( "Init - pthread_key_delete - OK" ); puts( "Init - pthread_key_delete - OK" );
sc = pthread_key_delete( key ); sc = pthread_key_delete( key );
assert( sc == 0 ); rtems_test_assert( sc == 0 );
puts( "Init - verify workspace has same memory" ); puts( "Init - verify workspace has same memory" );
sb = rtems_workspace_get_information( &info ); sb = rtems_workspace_get_information( &info );
@@ -113,9 +113,9 @@ void *POSIX_Init(
printf( "Init - workspace free/blocks = %d/%d\n", printf( "Init - workspace free/blocks = %d/%d\n",
info.Free.largest, info.Free.number ); info.Free.largest, info.Free.number );
#endif #endif
assert( sb ); rtems_test_assert( sb );
assert( info.Free.largest == start.Free.largest ); rtems_test_assert( info.Free.largest == start.Free.largest );
assert( info.Free.number == start.Free.number ); rtems_test_assert( info.Free.number == start.Free.number );
puts( "*** END OF TEST KEY 02 ***" ); puts( "*** END OF TEST KEY 02 ***" );
rtems_test_exit(0); rtems_test_exit(0);

View File

@@ -30,7 +30,7 @@ void *Test_Thread(
puts( "Test_Thread - pthread_setspecific - OK" ); puts( "Test_Thread - pthread_setspecific - OK" );
sc = pthread_setspecific( Key, key_value ); sc = pthread_setspecific( Key, key_value );
assert( !sc ); rtems_test_assert( !sc );
puts( "Test_Thread - pthread_exit to run key destructors - OK" ); puts( "Test_Thread - pthread_exit to run key destructors - OK" );
return NULL; return NULL;
@@ -51,21 +51,21 @@ void *POSIX_Init(
*/ */
puts( "Init - pthread_key_create with NULL destructor - OK" ); puts( "Init - pthread_key_create with NULL destructor - OK" );
sc = pthread_key_create( &Key, NULL ); sc = pthread_key_create( &Key, NULL );
assert( !sc ); rtems_test_assert( !sc );
puts( "Init - pthread_create - OK" ); puts( "Init - pthread_create - OK" );
sc = pthread_create( &thread, NULL, Test_Thread, &sc ); sc = pthread_create( &thread, NULL, Test_Thread, &sc );
assert( !sc ); rtems_test_assert( !sc );
puts( "Init - sleep - let thread run - OK" ); puts( "Init - sleep - let thread run - OK" );
delay_request.tv_sec = 0; delay_request.tv_sec = 0;
delay_request.tv_nsec = 5 * 100000000; delay_request.tv_nsec = 5 * 100000000;
sc = nanosleep( &delay_request, NULL ); sc = nanosleep( &delay_request, NULL );
assert( !sc ); rtems_test_assert( !sc );
puts( "Init - pthread_key_delete - OK" ); puts( "Init - pthread_key_delete - OK" );
sc = pthread_key_delete( Key ); sc = pthread_key_delete( Key );
assert( sc == 0 ); rtems_test_assert( sc == 0 );
/* /*
* Key with non-NULL destructor * Key with non-NULL destructor
@@ -73,22 +73,22 @@ void *POSIX_Init(
destructor_ran = false; destructor_ran = false;
puts( "Init - pthread_key_create with non-NULL destructor - OK" ); puts( "Init - pthread_key_create with non-NULL destructor - OK" );
sc = pthread_key_create( &Key, destructor ); sc = pthread_key_create( &Key, destructor );
assert( !sc ); rtems_test_assert( !sc );
puts( "Init - pthread_create - OK" ); puts( "Init - pthread_create - OK" );
sc = pthread_create( &thread, NULL, Test_Thread, NULL ); sc = pthread_create( &thread, NULL, Test_Thread, NULL );
assert( !sc ); rtems_test_assert( !sc );
puts( "Init - sleep - let thread run - OK" ); puts( "Init - sleep - let thread run - OK" );
sc = nanosleep( &delay_request, NULL ); sc = nanosleep( &delay_request, NULL );
assert( !sc ); rtems_test_assert( !sc );
puts( "Init - verify destructor did NOT ran" ); puts( "Init - verify destructor did NOT ran" );
assert( destructor_ran == false ); rtems_test_assert( destructor_ran == false );
puts( "Init - pthread_key_delete - OK" ); puts( "Init - pthread_key_delete - OK" );
sc = pthread_key_delete( Key ); sc = pthread_key_delete( Key );
assert( sc == 0 ); rtems_test_assert( sc == 0 );
puts( "*** END OF TEST KEY 03 ***" ); puts( "*** END OF TEST KEY 03 ***" );
rtems_test_exit(0); rtems_test_exit(0);

View File

@@ -15,17 +15,22 @@
* implementation of this appears to seek to the ((off/DIRENT_SIZE) + 1) * implementation of this appears to seek to the ((off/DIRENT_SIZE) + 1)
* record where DIRENT_SIZE seems to be 12 bytes. * record where DIRENT_SIZE seems to be 12 bytes.
* *
* 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$ * $Id$
*/ */
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <dirent.h> #include <dirent.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <rtems.h> #include <rtems.h>
@@ -127,23 +132,23 @@ int main(
printf("create /b/my_file\n"); printf("create /b/my_file\n");
fd = open ("/b/my_file", O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); fd = open ("/b/my_file", O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert( fd != 0 ); rtems_test_assert( fd != 0 );
close (fd); close (fd);
printf("Verify /b/my_file\n"); printf("Verify /b/my_file\n");
fd = open("/b/my_file", S_IRWXU|S_IRWXG|S_IRWXO); fd = open("/b/my_file", S_IRWXU|S_IRWXG|S_IRWXO);
assert( fd != 0 ); rtems_test_assert( fd != 0 );
close( fd ); close( fd );
printf("create c/y/my_mount_point/my_dir/d\n"); printf("create c/y/my_mount_point/my_dir/d\n");
fd = open ("c/y/my_mount_point/my_dir/d", O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); fd = open ("c/y/my_mount_point/my_dir/d", O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert( fd != 0 ); rtems_test_assert( fd != 0 );
close (fd); close (fd);
printf("Verify c/y/my_mount_point/my_dir/d\n"); printf("Verify c/y/my_mount_point/my_dir/d\n");
fd = open("c/y/my_mount_point/my_dir/d", S_IRWXU|S_IRWXG|S_IRWXO); fd = open("c/y/my_mount_point/my_dir/d", S_IRWXU|S_IRWXG|S_IRWXO);
assert( fd != 0 ); rtems_test_assert( fd != 0 );
close( fd ); close( fd );
/* /*
@@ -157,7 +162,7 @@ int main(
RTEMS_FILESYSTEM_READ_WRITE, RTEMS_FILESYSTEM_READ_WRITE,
NULL, NULL,
mount_point_string ); mount_point_string );
assert( status == 0 ); rtems_test_assert( status == 0 );
if( mt_entry == NULL ){ if( mt_entry == NULL ){
printf(" NULL mount table entry was returned\n"); printf(" NULL mount table entry was returned\n");
} }
@@ -218,8 +223,8 @@ int main(
RTEMS_FILESYSTEM_READ_WRITE, RTEMS_FILESYSTEM_READ_WRITE,
NULL, NULL,
mount_point_string ); mount_point_string );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
/* /*
* Verify mount with option of -62 fails with EINVAL * Verify mount with option of -62 fails with EINVAL
@@ -232,8 +237,8 @@ int main(
-62, -62,
NULL, NULL,
"/c/y/my_mount_point" ); "/c/y/my_mount_point" );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
/* /*
* Mount a Read Only File system. * Mount a Read Only File system.
@@ -246,7 +251,7 @@ int main(
RTEMS_FILESYSTEM_READ_ONLY, RTEMS_FILESYSTEM_READ_ONLY,
NULL, NULL,
"/c/y/my_mount_point" ); "/c/y/my_mount_point" );
assert( status == 0 ); rtems_test_assert( status == 0 );
if( mt_entry == NULL ){ if( mt_entry == NULL ){
printf(" NULL mount table entry was returned\n"); printf(" NULL mount table entry was returned\n");
} }
@@ -260,11 +265,11 @@ int main(
printf("create c/y/my_mount_point/../../y/my_mount_point/new_dir\n"); printf("create c/y/my_mount_point/../../y/my_mount_point/new_dir\n");
status = mkdir("c/y/my_mount_point/../../y/my_mount_point/new_dir",S_IRWXU ); status = mkdir("c/y/my_mount_point/../../y/my_mount_point/new_dir",S_IRWXU );
assert( status == 0 ); rtems_test_assert( status == 0 );
status = stat("c/y/my_mount_point/../../y/my_mount_point/new_dir",&statbuf ); status = stat("c/y/my_mount_point/../../y/my_mount_point/new_dir",&statbuf );
assert( status == 0 ); rtems_test_assert( status == 0 );
status = stat("c/y/my_mount_point/new_dir/..", &statbuf ); status = stat("c/y/my_mount_point/new_dir/..", &statbuf );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* /*
* Attempt to mount a second file system at a used mount point. * Attempt to mount a second file system at a used mount point.
@@ -277,8 +282,8 @@ int main(
RTEMS_FILESYSTEM_READ_ONLY, RTEMS_FILESYSTEM_READ_ONLY,
NULL, NULL,
"/c/y/my_mount_point" ); "/c/y/my_mount_point" );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EBUSY); rtems_test_assert( errno == EBUSY);
/* /*
* Attempt to mount at a file. * Attempt to mount at a file.
@@ -291,8 +296,8 @@ int main(
RTEMS_FILESYSTEM_READ_ONLY, RTEMS_FILESYSTEM_READ_ONLY,
NULL, NULL,
"/b/my_file" ); "/b/my_file" );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == ENOTDIR ); rtems_test_assert( errno == ENOTDIR );
/* /*
@@ -301,15 +306,15 @@ int main(
printf("Create and chdir to /c/y/my_mount_point/mydir\n"); printf("Create and chdir to /c/y/my_mount_point/mydir\n");
status = mkdir( "/c/y/my_mount_point/mydir", 0777); status = mkdir( "/c/y/my_mount_point/mydir", 0777);
assert( status == 0 ); rtems_test_assert( status == 0 );
status = chdir( "/c/y/my_mount_point/mydir" ); status = chdir( "/c/y/my_mount_point/mydir" );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("unmount of /c/y/my_mount_point should fail with EBUSY\n"); printf("unmount of /c/y/my_mount_point should fail with EBUSY\n");
status = unmount( "/c/y/my_mount_point" ); status = unmount( "/c/y/my_mount_point" );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EBUSY ); rtems_test_assert( errno == EBUSY );
/* /*
* Chdir to root and verify we can unmount the file system now. * Chdir to root and verify we can unmount the file system now.
@@ -317,11 +322,11 @@ int main(
printf("chdir to / and verify we can unmount /c/y/my_mount_point\n"); printf("chdir to / and verify we can unmount /c/y/my_mount_point\n");
status = chdir( "/" ); status = chdir( "/" );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("unmount /c/y/my_mount_point \n"); printf("unmount /c/y/my_mount_point \n");
status = unmount( "/c/y/my_mount_point" ); status = unmount( "/c/y/my_mount_point" );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* /*
* Attempt to unmount a directory that does not exist. * Attempt to unmount a directory that does not exist.
@@ -329,8 +334,8 @@ int main(
printf("unmount /b/mount_point should fail with EINVAL\n"); printf("unmount /b/mount_point should fail with EINVAL\n");
status = unmount( "/b/mount_point" ); status = unmount( "/b/mount_point" );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == ENOENT ); rtems_test_assert( errno == ENOENT );
/* /*
* Remount the filesystem. * Remount the filesystem.
@@ -343,7 +348,7 @@ int main(
RTEMS_FILESYSTEM_READ_ONLY, RTEMS_FILESYSTEM_READ_ONLY,
NULL, NULL,
"/c/y/my_mount_point" ); "/c/y/my_mount_point" );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* /*
* Create a file and directory then open the directory. * Create a file and directory then open the directory.
@@ -352,24 +357,24 @@ int main(
printf("Create and open /c/y/my_mount_point/my_file\n"); printf("Create and open /c/y/my_mount_point/my_file\n");
fd = open( "/c/y/my_mount_point/my_file", O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); fd = open( "/c/y/my_mount_point/my_file", O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert( fd != -1 ); rtems_test_assert( fd != -1 );
status = close( fd ); status = close( fd );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("\nmkdir /c/y/my_mount_point/my_dir\n"); printf("\nmkdir /c/y/my_mount_point/my_dir\n");
status = mkdir( "/c/y/my_mount_point/my_dir", 0x1c0 ); status = mkdir( "/c/y/my_mount_point/my_dir", 0x1c0 );
printf("Open /c/y/my_mount_point/my_dir\n"); printf("Open /c/y/my_mount_point/my_dir\n");
directory = opendir( "/c/y/my_mount_point/my_dir" ); directory = opendir( "/c/y/my_mount_point/my_dir" );
assert( directory ); rtems_test_assert( directory );
printf("Unmount /c/y/my_mount_point should fail with EBUSY\n"); printf("Unmount /c/y/my_mount_point should fail with EBUSY\n");
status = unmount( "/c/y/my_mount_point" ); status = unmount( "/c/y/my_mount_point" );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EBUSY ); rtems_test_assert( errno == EBUSY );
printf("Close /c/y/my_mount_point/my_dir\n"); printf("Close /c/y/my_mount_point/my_dir\n");
status = closedir( directory ); status = closedir( directory );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* /*
* Attempt to unmount a directory that is not a mount point. * Attempt to unmount a directory that is not a mount point.
@@ -377,8 +382,8 @@ int main(
printf("Unmount /c/y/my_mount_point/my_dir should fail with EACCES\n"); printf("Unmount /c/y/my_mount_point/my_dir should fail with EACCES\n");
status = unmount( "/c/y/my_mount_point/my_dir" ); status = unmount( "/c/y/my_mount_point/my_dir" );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EACCES ); rtems_test_assert( errno == EACCES );
/* /*
* Verify a file system can not be unmounted with a mounted file system * Verify a file system can not be unmounted with a mounted file system
@@ -392,12 +397,12 @@ int main(
RTEMS_FILESYSTEM_READ_WRITE, RTEMS_FILESYSTEM_READ_WRITE,
NULL, NULL,
"/c/y/my_mount_point/my_dir"); "/c/y/my_mount_point/my_dir");
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("unmount /c/y/my_mount_point should fail with EBUSY\n"); printf("unmount /c/y/my_mount_point should fail with EBUSY\n");
status = unmount( "/c/y/my_mount_point" ); status = unmount( "/c/y/my_mount_point" );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EBUSY ); rtems_test_assert( errno == EBUSY );
/* /*
* Verify you cannot create a hard link across mounted file systems. * Verify you cannot create a hard link across mounted file systems.
@@ -405,11 +410,11 @@ int main(
printf("Verify a hard link across filesystems fails with EXDEV\n"); printf("Verify a hard link across filesystems fails with EXDEV\n");
status = mkdir( "/c/y/my_mount_point/my_dir2", S_IRWXU ); status = mkdir( "/c/y/my_mount_point/my_dir2", S_IRWXU );
assert( status == 0 ); rtems_test_assert( status == 0 );
status = link( "/c/y/my_mount_point/my_dir2", "/c/y/my_mount_point/my_dir/my_link" ); status = link( "/c/y/my_mount_point/my_dir2", "/c/y/my_mount_point/my_dir/my_link" );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EXDEV ); rtems_test_assert( errno == EXDEV );
/* /*
* Create a symbolic link across mountpoints. * Create a symbolic link across mountpoints.
@@ -417,13 +422,13 @@ int main(
printf("Verify a symbolic link across file systems works\n"); printf("Verify a symbolic link across file systems works\n");
status = symlink( "/c/y/my_mount_point/my_dir2", "/c/y/my_mount_point/my_dir/my_link" ); status = symlink( "/c/y/my_mount_point/my_dir2", "/c/y/my_mount_point/my_dir/my_link" );
assert( status == 0 ); rtems_test_assert( status == 0 );
status = stat( "/c/y/my_mount_point/my_dir/my_link", &statbuf ); status = stat( "/c/y/my_mount_point/my_dir/my_link", &statbuf );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("unmount /c/y/my_mount_point/my_dir\n"); printf("unmount /c/y/my_mount_point/my_dir\n");
status = unmount( "/c/y/my_mount_point/my_dir" ); status = unmount( "/c/y/my_mount_point/my_dir" );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* /*
* Verify symblic link no longer works. * Verify symblic link no longer works.
@@ -431,11 +436,11 @@ int main(
printf("Verify the symbolic link now fails\n"); printf("Verify the symbolic link now fails\n");
status = stat( "/c/y/my_mount_point/my_dir/my_link", &statbuf ); status = stat( "/c/y/my_mount_point/my_dir/my_link", &statbuf );
assert( status != 0 ); rtems_test_assert( status != 0 );
printf("unmount /c/y/my_mount_point\n"); printf("unmount /c/y/my_mount_point\n");
status = unmount( "/c/y/my_mount_point" ); status = unmount( "/c/y/my_mount_point" );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf( "\n\n*** END OF MOUNT/UNMOUNT TEST ***\n" ); printf( "\n\n*** END OF MOUNT/UNMOUNT TEST ***\n" );
rtems_test_exit(0); rtems_test_exit(0);

View File

@@ -130,7 +130,7 @@ void open_test_queues(void)
else else
Test_q[que].mq = mq_open( tq->name, tq->oflag, 0x777, &attr ); Test_q[que].mq = mq_open( tq->name, tq->oflag, 0x777, &attr );
assert( Test_q[que].mq != (-1) ); rtems_test_assert( Test_q[que].mq != (-1) );
} }
status = mq_close( Test_q[NUMBER_OF_TEST_QUEUES].mq ); status = mq_close( Test_q[NUMBER_OF_TEST_QUEUES].mq );
@@ -223,7 +223,7 @@ void validate_mq_open_error_codes(void)
puts( "Init: mq_open - Create an Existing mq (EEXIST)" ); puts( "Init: mq_open - Create an Existing mq (EEXIST)" );
open_mq[0] = mq_open( open_mq[0] = mq_open(
Build_Queue_Name(0), O_CREAT | O_RDWR | O_NONBLOCK, 0x777, NULL ); Build_Queue_Name(0), O_CREAT | O_RDWR | O_NONBLOCK, 0x777, NULL );
assert( open_mq[0] != (-1) ); rtems_test_assert( open_mq[0] != (-1) );
n_mq2 = mq_open( n_mq2 = mq_open(
Build_Queue_Name(0), O_CREAT | O_EXCL | O_RDONLY, 0x777, NULL); Build_Queue_Name(0), O_CREAT | O_EXCL | O_RDONLY, 0x777, NULL);
@@ -245,8 +245,8 @@ void validate_mq_open_error_codes(void)
for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES; i++) { for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES; i++) {
open_mq[i] = mq_open( open_mq[i] = mq_open(
Build_Queue_Name(i), O_CREAT | O_RDWR | O_NONBLOCK, 0x777, NULL ); Build_Queue_Name(i), O_CREAT | O_RDWR | O_NONBLOCK, 0x777, NULL );
assert( open_mq[i] != (-1) ); rtems_test_assert( open_mq[i] != (-1) );
assert( open_mq[i] ); rtems_test_assert( open_mq[i] );
/*XXX - Isn't there a more general check */ /*XXX - Isn't there a more general check */
/* JRS printf( "mq_open 0x%x %s\n", open_mq[i], Build_Queue_Name(i) ); */ /* JRS printf( "mq_open 0x%x %s\n", open_mq[i], Build_Queue_Name(i) ); */
} }
@@ -494,7 +494,7 @@ void Read_msg_from_que(
sprintf( err_msg, "%s msg %s size failure", Test_q[ que ].name, ptr->msg ); sprintf( err_msg, "%s msg %s size failure", Test_q[ que ].name, ptr->msg );
fatal_int_service_status( status, ptr->size, err_msg ); fatal_int_service_status( status, ptr->size, err_msg );
assert( !strcmp( message, ptr->msg ) ); rtems_test_assert( !strcmp( message, ptr->msg ) );
strcpy( message, "No Message" ); strcpy( message, "No Message" );
sprintf( err_msg,"%s msg %s size failure", Test_q[ que ].name, ptr->msg ); sprintf( err_msg,"%s msg %s size failure", Test_q[ que ].name, ptr->msg );
@@ -683,7 +683,7 @@ void verify_open_functionality(void)
puts( "Init: mq_open - Open an existing mq ( same id )" ); puts( "Init: mq_open - Open an existing mq ( same id )" );
n_mq = mq_open( RD_NAME, 0 ); n_mq = mq_open( RD_NAME, 0 );
fatal_posix_service_status( fatal_posix_service_status(
assert( n_mq == Test_q[RD_QUEUE].mq ); rtems_test_assert( n_mq == Test_q[RD_QUEUE].mq );
#endif #endif
} }
@@ -704,8 +704,8 @@ void verify_unlink_functionality(void)
fatal_posix_service_status( status, 0, "mq_unlink locked message queue"); fatal_posix_service_status( status, 0, "mq_unlink locked message queue");
n_mq = mq_open( DEFAULT_NAME, DEFAULT_ATTR, 0x777, NULL ); n_mq = mq_open( DEFAULT_NAME, DEFAULT_ATTR, 0x777, NULL );
assert( n_mq != (-1) ); rtems_test_assert( n_mq != (-1) );
assert( n_mq != Test_q[ DEFAULT_RW ].mq ); rtems_test_assert( n_mq != Test_q[ DEFAULT_RW ].mq );
status = mq_unlink( DEFAULT_NAME ); status = mq_unlink( DEFAULT_NAME );
@@ -888,10 +888,10 @@ void wait_for_signal(
timeout.tv_nsec = 0; timeout.tv_nsec = 0;
status = sigemptyset( waitset ); status = sigemptyset( waitset );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( waitset, SIGUSR1 ); status = sigaddset( waitset, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
printf( "waiting on any signal for %d seconds.\n", sec ); printf( "waiting on any signal for %d seconds.\n", sec );
signo = sigtimedwait( waitset, &siginfo, &timeout ); signo = sigtimedwait( waitset, &siginfo, &timeout );
@@ -1007,7 +1007,7 @@ void verify_with_threads(void)
Start_Test( "multi-thread Task 4 Receive Test" ); Start_Test( "multi-thread Task 4 Receive Test" );
status = pthread_create( &id, NULL, Task_4, NULL ); status = pthread_create( &id, NULL, Task_4, NULL );
assert( !status ); rtems_test_assert( !status );
puts( "Init: mq_receive - Empty queue changes to non-blocking (EAGAIN)" ); puts( "Init: mq_receive - Empty queue changes to non-blocking (EAGAIN)" );
status = mq_receive( Test_q[BLOCKING].mq, message, 100, &priority ); status = mq_receive( Test_q[BLOCKING].mq, message, 100, &priority );
fatal_int_service_status( status, -1, "mq_receive error return status"); fatal_int_service_status( status, -1, "mq_receive error return status");
@@ -1022,7 +1022,7 @@ void verify_with_threads(void)
Start_Test( "multi-thread Task 1 Test" ); Start_Test( "multi-thread Task 1 Test" );
status = pthread_create( &id, NULL, Task_1, NULL ); status = pthread_create( &id, NULL, Task_1, NULL );
assert( !status ); rtems_test_assert( !status );
Read_msg_from_que( BLOCKING, 0 ); /* Block until init writes */ Read_msg_from_que( BLOCKING, 0 ); /* Block until init writes */
print_current_time( "Init: ", "" ); print_current_time( "Init: ", "" );
@@ -1036,7 +1036,7 @@ void verify_with_threads(void)
Start_Test( "multi-thread Task 4 Send Test" ); Start_Test( "multi-thread Task 4 Send Test" );
fill_message_queues( "Init:" ); fill_message_queues( "Init:" );
status = pthread_create( &id, NULL, Task_4, NULL ); status = pthread_create( &id, NULL, Task_4, NULL );
assert( !status ); rtems_test_assert( !status );
puts( "Init: mq_send - Full queue changes to non-blocking (EAGAIN)" ); puts( "Init: mq_send - Full queue changes to non-blocking (EAGAIN)" );
status = mq_send(Test_q[BLOCKING].mq, message, 0, 0 ); status = mq_send(Test_q[BLOCKING].mq, message, 0, 0 );
fatal_posix_service_status( status, -1, "mq_send error return status"); fatal_posix_service_status( status, -1, "mq_send error return status");
@@ -1051,7 +1051,7 @@ void verify_with_threads(void)
Start_Test( "multi-thread Task 2 Test" ); Start_Test( "multi-thread Task 2 Test" );
fill_message_queues( "Init:" ); fill_message_queues( "Init:" );
status = pthread_create( &id, NULL, Task_2, NULL ); status = pthread_create( &id, NULL, Task_2, NULL );
assert( !status ); rtems_test_assert( !status );
Show_send_msg_to_que( "Init:", BLOCKING, Priority_Order[0] ); Show_send_msg_to_que( "Init:", BLOCKING, Priority_Order[0] );
print_current_time( "Init: ", "" ); print_current_time( "Init: ", "" );
verify_queues_full( "Init:" ); verify_queues_full( "Init:" );
@@ -1065,7 +1065,7 @@ void verify_with_threads(void)
Start_Test( "multi-thread Task 3 Test" ); Start_Test( "multi-thread Task 3 Test" );
fill_message_queues( "Init:" ); fill_message_queues( "Init:" );
status = pthread_create( &id, NULL, Task_3, NULL ); status = pthread_create( &id, NULL, Task_3, NULL );
assert( !status ); rtems_test_assert( !status );
puts( "Init: mq_send - Block while thread deletes queue (EBADF)" ); puts( "Init: mq_send - Block while thread deletes queue (EBADF)" );
ptr = &Predefined_Msgs[0]; ptr = &Predefined_Msgs[0];
status = mq_send( Test_q[BLOCKING].mq, ptr->msg, ptr->size , ptr->priority ); status = mq_send( Test_q[BLOCKING].mq, ptr->msg, ptr->size , ptr->priority );
@@ -1271,7 +1271,7 @@ void *Task_1 (
/* switch to Init */ /* switch to Init */
assert( 0 ); rtems_test_assert( 0 );
return NULL; /* just so the compiler thinks we returned something */ return NULL; /* just so the compiler thinks we returned something */
} }

View File

@@ -55,14 +55,14 @@ void *POSIX_Init(
if ( Queue == (-1) ) { if ( Queue == (-1) ) {
perror( "mq_open failed" ); perror( "mq_open failed" );
} }
assert( Queue != (-1) ); rtems_test_assert( Queue != (-1) );
puts( "Init - send to message queue" ); puts( "Init - send to message queue" );
status = mq_send( Queue, (const char *)&status, sizeof(int), 1 ); status = mq_send( Queue, (const char *)&status, sizeof(int), 1 );
if ( status == (-1) ) { if ( status == (-1) ) {
perror( "mq_status failed" ); perror( "mq_status failed" );
} }
assert( status != (-1) ); rtems_test_assert( status != (-1) );
/* /*
* Now create the timer we will send to a full queue from. * Now create the timer we will send to a full queue from.

View File

@@ -43,29 +43,29 @@ void *POSIX_Init(
Queue = mq_open( "Queue", O_CREAT | O_RDWR, 0x777, &attr ); Queue = mq_open( "Queue", O_CREAT | O_RDWR, 0x777, &attr );
if ( Queue == (-1) ) if ( Queue == (-1) )
perror( "mq_open failed" ); perror( "mq_open failed" );
assert( Queue != (-1) ); rtems_test_assert( Queue != (-1) );
puts( "Init - Open message queue instance 2 - FAIL - ENFILE " ); puts( "Init - Open message queue instance 2 - FAIL - ENFILE " );
second_Queue = mq_open( "Queue2", O_CREAT | O_RDWR, 0x777, &attr ); second_Queue = mq_open( "Queue2", O_CREAT | O_RDWR, 0x777, &attr );
if ( second_Queue != (-1) ) if ( second_Queue != (-1) )
puts( "mq_open did not failed" ); puts( "mq_open did not failed" );
assert( second_Queue == (-1) ); rtems_test_assert( second_Queue == (-1) );
assert( errno == ENFILE ); rtems_test_assert( errno == ENFILE );
puts( "Init - Unlink message queue instance 1" ); puts( "Init - Unlink message queue instance 1" );
sc = mq_unlink( "Queue" ); sc = mq_unlink( "Queue" );
if ( sc != 0 ) if ( sc != 0 )
perror( "mq_unlink failed" ); perror( "mq_unlink failed" );
assert( sc == 0 ); rtems_test_assert( sc == 0 );
puts( "Init - Close message queue instance 1" ); puts( "Init - Close message queue instance 1" );
sc = mq_close( Queue ); sc = mq_close( Queue );
if ( sc != 0 ) if ( sc != 0 )
perror( "mq_close failed" ); perror( "mq_close failed" );
assert( sc == 0 ); rtems_test_assert( sc == 0 );
sb = rtems_workspace_get_information( &start ); sb = rtems_workspace_get_information( &start );
assert( start.Free.number == 1 ); rtems_test_assert( start.Free.number == 1 );
to_alloc = start.Free.largest; to_alloc = start.Free.largest;
/* find the largest we can actually allocate */ /* find the largest we can actually allocate */
@@ -91,7 +91,7 @@ void *POSIX_Init(
name = Get_Longest_Name(); name = Get_Longest_Name();
while ( attr.mq_msgsize > 0 ) { while ( attr.mq_msgsize > 0 ) {
sb = rtems_workspace_allocate( to_alloc, &alloced ); sb = rtems_workspace_allocate( to_alloc, &alloced );
assert( sb ); rtems_test_assert( sb );
second_Queue = mq_open(name,O_CREAT | O_RDWR, 0x777, &attr ); second_Queue = mq_open(name,O_CREAT | O_RDWR, 0x777, &attr );
@@ -114,13 +114,13 @@ void *POSIX_Init(
sc = mq_unlink( name ); sc = mq_unlink( name );
if ( sc != 0 ) if ( sc != 0 )
perror( "mq_unlink failed" ); perror( "mq_unlink failed" );
assert( sc == 0 ); rtems_test_assert( sc == 0 );
puts( "Init - Close message queue" ); puts( "Init - Close message queue" );
sc = mq_close( second_Queue ); sc = mq_close( second_Queue );
if ( sc != 0 ) if ( sc != 0 )
perror( "mq_close failed" ); perror( "mq_close failed" );
assert( sc == 0 ); rtems_test_assert( sc == 0 );
puts( "*** END OF POSIX MESSAGE QUEUE TEST 4 ***" ); puts( "*** END OF POSIX MESSAGE QUEUE TEST 4 ***" );
rtems_test_exit( 0 ); rtems_test_exit( 0 );

View File

@@ -15,7 +15,12 @@
* implementation of this appears to seek to the ((off/DIRENT_SIZE) + 1) * implementation of this appears to seek to the ((off/DIRENT_SIZE) + 1)
* record where DIRENT_SIZE seems to be 12 bytes. * record where DIRENT_SIZE seems to be 12 bytes.
* *
* 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$ * $Id$
*/ */
@@ -25,11 +30,9 @@
#include <fcntl.h> #include <fcntl.h>
#include <dirent.h> #include <dirent.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <rtems/imfs.h> #include <rtems/imfs.h>
#include <assert.h>
DIR *directory; DIR *directory;
DIR *directory2; DIR *directory2;
@@ -71,7 +74,7 @@ void complete_printdir( char *path )
int status; int status;
the_dir = opendir( path ); the_dir = opendir( path );
assert( the_dir ); rtems_test_assert( the_dir );
printdir( the_dir ); printdir( the_dir );
status = closedir( the_dir ); status = closedir( the_dir );
} }
@@ -188,8 +191,8 @@ void test_across_mount(void)
*/ */
printf("Validate readdir across mount point\n"); printf("Validate readdir across mount point\n");
assert( mkdir( "/imfs", 0777 ) == 0 ); rtems_test_assert( mkdir( "/imfs", 0777 ) == 0 );
assert( mkdir( "/imfs/should_be_hidden", 0777 ) == 0 ); rtems_test_assert( mkdir( "/imfs/should_be_hidden", 0777 ) == 0 );
complete_printdir("/imfs" ); complete_printdir("/imfs" );
printf("Attempting to mount IMFS file system at /imfs \n"); printf("Attempting to mount IMFS file system at /imfs \n");
status = mount( status = mount(
@@ -198,16 +201,16 @@ void test_across_mount(void)
RTEMS_FILESYSTEM_READ_WRITE, RTEMS_FILESYSTEM_READ_WRITE,
NULL, NULL,
"/imfs" ); "/imfs" );
assert( status == 0 ); rtems_test_assert( status == 0 );
if( mt_entry == NULL ){ if( mt_entry == NULL ){
printf(" NULL mount table entry was returned\n"); printf(" NULL mount table entry was returned\n");
} }
printf( "create /imfs/testdir and /imfs/testdir/testsubdir\n"); printf( "create /imfs/testdir and /imfs/testdir/testsubdir\n");
status = mkdir( "/imfs/testdir", 0777 ); status = mkdir( "/imfs/testdir", 0777 );
assert( status == 0 ); rtems_test_assert( status == 0 );
status = mkdir( "/imfs/testdir/testsubdir", 0777 ); status = mkdir( "/imfs/testdir/testsubdir", 0777 );
assert( status == 0 ); rtems_test_assert( status == 0 );
complete_printdir("/imfs" ); complete_printdir("/imfs" );
complete_printdir("/imfs/" ); complete_printdir("/imfs/" );
@@ -273,7 +276,7 @@ int main(
printf("open /b/myfile\n"); printf("open /b/myfile\n");
fd = open ("/b/my_file", O_CREAT, S_IRWXU); fd = open ("/b/my_file", O_CREAT, S_IRWXU);
assert( fd != -1 ); rtems_test_assert( fd != -1 );
close (fd); close (fd);
printf("scandir a file status: "); printf("scandir a file status: ");
@@ -287,20 +290,20 @@ int main(
printf("Open /b/new_file\n"); printf("Open /b/new_file\n");
fd = open( "/b/new_file", O_CREAT, S_IRWXU ); fd = open( "/b/new_file", O_CREAT, S_IRWXU );
assert( fd != -1 ); rtems_test_assert( fd != -1 );
printf("fcntl F_SETFD should return 0\n"); printf("fcntl F_SETFD should return 0\n");
status = fcntl( fd, F_SETFD, 1 ); status = fcntl( fd, F_SETFD, 1 );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("fcntl F_SETFD should return 1\n"); printf("fcntl F_SETFD should return 1\n");
status = fcntl( fd, F_GETFD, 1 ); status = fcntl( fd, F_GETFD, 1 );
assert( status == 1 ); rtems_test_assert( status == 1 );
#if 0 #if 0
printf("fcntl F_DUPFD should return 0\n"); printf("fcntl F_DUPFD should return 0\n");
status = fcntl( fd, F_DUPFD, 0 ); status = fcntl( fd, F_DUPFD, 0 );
assert ( status == 0 ); rtems_test_assert ( status == 0 );
#else #else
printf("fcntl F_DUPFD should return 0 -- skip until implemented\n"); printf("fcntl F_DUPFD should return 0 -- skip until implemented\n");
#endif #endif
@@ -308,41 +311,41 @@ int main(
printf("fcntl F_GETFL returns current flags\n"); printf("fcntl F_GETFL returns current flags\n");
status = fcntl( fd, F_GETFL, 1 ); status = fcntl( fd, F_GETFL, 1 );
printf("fcntl F_GETFL returned 0x%x\n", status ); printf("fcntl F_GETFL returned 0x%x\n", status );
assert( status != -1 ); rtems_test_assert( status != -1 );
printf("fcntl F_SETFL to add O_APPEND and O_NONBLOCK\n"); printf("fcntl F_SETFL to add O_APPEND and O_NONBLOCK\n");
status = fcntl( fd, F_SETFL, O_APPEND|O_NONBLOCK ); status = fcntl( fd, F_SETFL, O_APPEND|O_NONBLOCK );
assert ( status != -1 ); rtems_test_assert ( status != -1 );
printf("fcntl F_GETFL return current flags to see changes\n"); printf("fcntl F_GETFL return current flags to see changes\n");
status = fcntl( fd, F_GETFL, 1 ); status = fcntl( fd, F_GETFL, 1 );
printf("fcntl F_GETFL returned 0x%x\n", status ); printf("fcntl F_GETFL returned 0x%x\n", status );
assert( status != -1 ); rtems_test_assert( status != -1 );
printf("fcntl F_GETLK should return -1\n"); printf("fcntl F_GETLK should return -1\n");
status = fcntl( fd, F_GETLK, 1 ); status = fcntl( fd, F_GETLK, 1 );
assert ( status == -1 ); rtems_test_assert ( status == -1 );
printf("fcntl F_SETLK should return -1\n"); printf("fcntl F_SETLK should return -1\n");
status = fcntl( fd, F_SETLK, 1 ); status = fcntl( fd, F_SETLK, 1 );
assert ( status == -1 ); rtems_test_assert ( status == -1 );
printf("fcntl F_SETLKW should return -1\n"); printf("fcntl F_SETLKW should return -1\n");
status = fcntl( fd, F_SETLKW, 1 ); status = fcntl( fd, F_SETLKW, 1 );
assert ( status == -1 ); rtems_test_assert ( status == -1 );
printf("fcntl F_SETOWN should return -1\n"); printf("fcntl F_SETOWN should return -1\n");
status = fcntl( fd, F_SETOWN, 1 ); status = fcntl( fd, F_SETOWN, 1 );
assert ( status == -1 ); rtems_test_assert ( status == -1 );
printf("fcntl F_GETOWN should return -1\n"); printf("fcntl F_GETOWN should return -1\n");
status = fcntl( fd, F_GETOWN, 1 ); status = fcntl( fd, F_GETOWN, 1 );
assert ( status == -1 ); rtems_test_assert ( status == -1 );
printf("fcntl invalid argument should return -1\n"); printf("fcntl invalid argument should return -1\n");
status = fcntl( fd, 0xb, 1 ); status = fcntl( fd, 0xb, 1 );
printf("Status %d\n",status); printf("Status %d\n",status);
assert( status == -1 ); rtems_test_assert( status == -1 );
printf("opendir and readdir /b/myfile\n"); printf("opendir and readdir /b/myfile\n");
directory_not = opendir ("/b/my_file"); directory_not = opendir ("/b/my_file");
@@ -354,7 +357,7 @@ int main(
printf("chdir to /b/myfile\n"); printf("chdir to /b/myfile\n");
status = chdir ("/b/my_file"); status = chdir ("/b/my_file");
assert (status == -1); rtems_test_assert (status == -1);
printf( "\nPerforming stat of directory /\n"); printf( "\nPerforming stat of directory /\n");
status = stat( "/", &s ); status = stat( "/", &s );
@@ -362,18 +365,18 @@ int main(
puts( "\nOpen and print directory /" ); puts( "\nOpen and print directory /" );
directory = opendir("/"); directory = opendir("/");
assert( directory ); rtems_test_assert( directory );
printdir(directory); printdir(directory);
printf("\nmkdir /d/my_dir\n"); printf("\nmkdir /d/my_dir\n");
status = mkdir( "/d/my_dir", 0x1c0 ); status = mkdir( "/d/my_dir", 0x1c0 );
printf("Open /d/my_dir\n"); printf("Open /d/my_dir\n");
directory_not = opendir( "/d/my_dir" ); directory_not = opendir( "/d/my_dir" );
assert( directory_not ); rtems_test_assert( directory_not );
printf( "remove /d/my_dir.\n" ); printf( "remove /d/my_dir.\n" );
status = rmdir( "/d/my_dir" ); status = rmdir( "/d/my_dir" );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf( "close /d/my_dir.\n" ); printf( "close /d/my_dir.\n" );
closedir( directory_not ); closedir( directory_not );
@@ -381,14 +384,14 @@ int main(
printf( "\nOpening directory /c\n" ); printf( "\nOpening directory /c\n" );
directory2 = opendir("/c"); directory2 = opendir("/c");
assert( directory2 ); rtems_test_assert( directory2 );
printdir(directory2); printdir(directory2);
status = closedir( directory2 ); status = closedir( directory2 );
printf( "\nOpening directory /c/y\n" ); printf( "\nOpening directory /c/y\n" );
directory3 = opendir("/c/y"); directory3 = opendir("/c/y");
assert( directory3 ); rtems_test_assert( directory3 );
printdir(directory3); printdir(directory3);
status = closedir( directory3 ); status = closedir( directory3 );

View File

@@ -1,7 +1,7 @@
/* /*
* This test exercises the POSIX RWLock manager. * This test exercises the POSIX RWLock manager.
* *
* COPYRIGHT (c) 1989-2006. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -11,7 +11,6 @@
* $Id$ * $Id$
*/ */
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
@@ -37,11 +36,11 @@ void *ReadLockThread(void *arg)
puts( "ReadThread - pthread_rwlock_rdlock(RWLock) blocking -- OK" ); puts( "ReadThread - pthread_rwlock_rdlock(RWLock) blocking -- OK" );
status = pthread_rwlock_rdlock(&RWLock); status = pthread_rwlock_rdlock(&RWLock);
assert( !status ); rtems_test_assert( !status );
puts( "ReadThread - pthread_rwlock_rdlock(RWLock) unblocked -- OK" ); puts( "ReadThread - pthread_rwlock_rdlock(RWLock) unblocked -- OK" );
status = pthread_rwlock_unlock(&RWLock); status = pthread_rwlock_unlock(&RWLock);
assert( !status ); rtems_test_assert( !status );
return NULL; return NULL;
} }
@@ -54,14 +53,14 @@ void *WriteLockThread(void *arg)
puts( "WriteThread - pthread_rwlock_wrlock(RWLock) blocking -- OK" ); puts( "WriteThread - pthread_rwlock_wrlock(RWLock) blocking -- OK" );
status = pthread_rwlock_wrlock(&RWLock); status = pthread_rwlock_wrlock(&RWLock);
assert( !status ); rtems_test_assert( !status );
puts( "WriteThread - pthread_rwlock_wrlock(RWLock) unblocked -- OK" ); puts( "WriteThread - pthread_rwlock_wrlock(RWLock) unblocked -- OK" );
sleep( 1 ); sleep( 1 );
puts( "WriteThread - pthread_rwlock_unlock(RWLock) -- OK" ); puts( "WriteThread - pthread_rwlock_unlock(RWLock) -- OK" );
status = pthread_rwlock_unlock(&RWLock); status = pthread_rwlock_unlock(&RWLock);
assert( !status ); rtems_test_assert( !status );
return NULL; return NULL;
} }
@@ -90,75 +89,75 @@ int main(
/*************** NULL POINTER CHECKS *****************/ /*************** NULL POINTER CHECKS *****************/
puts( "pthread_rwlockattr_init( NULL ) -- EINVAL" ); puts( "pthread_rwlockattr_init( NULL ) -- EINVAL" );
status = pthread_rwlockattr_init( NULL ); status = pthread_rwlockattr_init( NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlockattr_setpshared( NULL, private ) -- EINVAL" ); puts( "pthread_rwlockattr_setpshared( NULL, private ) -- EINVAL" );
status = pthread_rwlockattr_setpshared( NULL, PTHREAD_PROCESS_PRIVATE ); status = pthread_rwlockattr_setpshared( NULL, PTHREAD_PROCESS_PRIVATE );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlockattr_setpshared( NULL, shared ) -- EINVAL" ); puts( "pthread_rwlockattr_setpshared( NULL, shared ) -- EINVAL" );
status = pthread_rwlockattr_setpshared( NULL, PTHREAD_PROCESS_SHARED ); status = pthread_rwlockattr_setpshared( NULL, PTHREAD_PROCESS_SHARED );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlockattr_getpshared( NULL, &p ) -- EINVAL" ); puts( "pthread_rwlockattr_getpshared( NULL, &p ) -- EINVAL" );
status = pthread_rwlockattr_getpshared( NULL, &p ); status = pthread_rwlockattr_getpshared( NULL, &p );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlockattr_destroy( NULL ) -- EINVAL" ); puts( "pthread_rwlockattr_destroy( NULL ) -- EINVAL" );
status = pthread_rwlockattr_destroy( NULL ); status = pthread_rwlockattr_destroy( NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/*************** NOT INITIALIZED CHECKS *****************/ /*************** NOT INITIALIZED CHECKS *****************/
/* cheat visibility */ /* cheat visibility */
attr.is_initialized = 0; attr.is_initialized = 0;
puts( "pthread_rwlockattr_setpshared( &attr, shared ) -- EINVAL" ); puts( "pthread_rwlockattr_setpshared( &attr, shared ) -- EINVAL" );
status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_SHARED ); status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlockattr_getpshared( &attr, NULL ) -- EINVAL" ); puts( "pthread_rwlockattr_getpshared( &attr, NULL ) -- EINVAL" );
status = pthread_rwlockattr_getpshared( &attr, NULL ); status = pthread_rwlockattr_getpshared( &attr, NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlockattr_destroy( &attr ) -- EINVAL" ); puts( "pthread_rwlockattr_destroy( &attr ) -- EINVAL" );
status = pthread_rwlockattr_destroy( &attr ); status = pthread_rwlockattr_destroy( &attr );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/*************** BAD PSHARED CHECK *****************/ /*************** BAD PSHARED CHECK *****************/
puts( "pthread_rwlockattr_setpshared( &attr, private ) -- EINVAL" ); puts( "pthread_rwlockattr_setpshared( &attr, private ) -- EINVAL" );
status = pthread_rwlockattr_setpshared( &attr, ~PTHREAD_PROCESS_PRIVATE ); status = pthread_rwlockattr_setpshared( &attr, ~PTHREAD_PROCESS_PRIVATE );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/*************** ACTUALLY WORK THIS TIME *****************/ /*************** ACTUALLY WORK THIS TIME *****************/
puts( "pthread_rwlockattr_init( &attr ) -- OK" ); puts( "pthread_rwlockattr_init( &attr ) -- OK" );
status = pthread_rwlockattr_init( &attr ); status = pthread_rwlockattr_init( &attr );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_rwlockattr_setpshared( &attr, private ) -- OK" ); puts( "pthread_rwlockattr_setpshared( &attr, private ) -- OK" );
status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_PRIVATE ); status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_PRIVATE );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_rwlockattr_getpshared( &attr, &p ) -- OK" ); puts( "pthread_rwlockattr_getpshared( &attr, &p ) -- OK" );
status = pthread_rwlockattr_getpshared( &attr, &p ); status = pthread_rwlockattr_getpshared( &attr, &p );
assert( status == 0 ); rtems_test_assert( status == 0 );
assert( p == PTHREAD_PROCESS_PRIVATE ); rtems_test_assert( p == PTHREAD_PROCESS_PRIVATE );
puts( "pthread_rwlockattr_setpshared( &attr, shared ) -- OK" ); puts( "pthread_rwlockattr_setpshared( &attr, shared ) -- OK" );
status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_SHARED ); status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_rwlockattr_getpshared( &attr, &p ) -- OK" ); puts( "pthread_rwlockattr_getpshared( &attr, &p ) -- OK" );
status = pthread_rwlockattr_getpshared( &attr, &p ); status = pthread_rwlockattr_getpshared( &attr, &p );
assert( status == 0 ); rtems_test_assert( status == 0 );
assert( p == PTHREAD_PROCESS_SHARED ); rtems_test_assert( p == PTHREAD_PROCESS_SHARED );
/*************** DESTROY/REUSE CHECK *****************/ /*************** DESTROY/REUSE CHECK *****************/
puts( "pthread_rwlockattr_destroy( &attr ) -- OK" ); puts( "pthread_rwlockattr_destroy( &attr ) -- OK" );
status = pthread_rwlockattr_destroy( &attr ); status = pthread_rwlockattr_destroy( &attr );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_rwlockattr_getpshared( &attr, &p ) destroyed -- EINVAL" ); puts( "pthread_rwlockattr_getpshared( &attr, &p ) destroyed -- EINVAL" );
status = pthread_rwlockattr_getpshared( &attr, &p ); status = pthread_rwlockattr_getpshared( &attr, &p );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/*************** NULL ARGUMENT CHECKS *****************/ /*************** NULL ARGUMENT CHECKS *****************/
abstime.tv_sec = 0; abstime.tv_sec = 0;
@@ -166,87 +165,87 @@ int main(
puts( "pthread_rwlock_init(NULL, &attr) -- EINVAL" ); puts( "pthread_rwlock_init(NULL, &attr) -- EINVAL" );
status = pthread_rwlock_init(NULL, &attr); status = pthread_rwlock_init(NULL, &attr);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_destroy(NULL) -- EINVAL" ); puts( "pthread_rwlock_destroy(NULL) -- EINVAL" );
status = pthread_rwlock_destroy(NULL); status = pthread_rwlock_destroy(NULL);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_rdlock(NULL) -- EINVAL" ); puts( "pthread_rwlock_rdlock(NULL) -- EINVAL" );
status = pthread_rwlock_rdlock(NULL); status = pthread_rwlock_rdlock(NULL);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_timedrdlock( NULL, &abstime) -- EINVAL" ); puts( "pthread_rwlock_timedrdlock( NULL, &abstime) -- EINVAL" );
status = pthread_rwlock_timedrdlock( NULL, &abstime); status = pthread_rwlock_timedrdlock( NULL, &abstime);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_timedrdlock( &rwlock, NULL) -- EINVAL" ); puts( "pthread_rwlock_timedrdlock( &rwlock, NULL) -- EINVAL" );
status = pthread_rwlock_timedrdlock( &rwlock, NULL); status = pthread_rwlock_timedrdlock( &rwlock, NULL);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_tryrdlock(NULL) -- EINVAL" ); puts( "pthread_rwlock_tryrdlock(NULL) -- EINVAL" );
status = pthread_rwlock_tryrdlock(NULL); status = pthread_rwlock_tryrdlock(NULL);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_wrlock(NULL) -- EINVAL" ); puts( "pthread_rwlock_wrlock(NULL) -- EINVAL" );
status = pthread_rwlock_wrlock(NULL); status = pthread_rwlock_wrlock(NULL);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_timedwrlock( NULL, &abstime) -- EINVAL" ); puts( "pthread_rwlock_timedwrlock( NULL, &abstime) -- EINVAL" );
status = pthread_rwlock_timedwrlock( NULL, &abstime ); status = pthread_rwlock_timedwrlock( NULL, &abstime );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_timedwrlock( &rwlock, NULL) -- EINVAL" ); puts( "pthread_rwlock_timedwrlock( &rwlock, NULL) -- EINVAL" );
status = pthread_rwlock_timedwrlock( &rwlock, NULL); status = pthread_rwlock_timedwrlock( &rwlock, NULL);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_trywrlock(NULL) -- EINVAL" ); puts( "pthread_rwlock_trywrlock(NULL) -- EINVAL" );
status = pthread_rwlock_trywrlock(NULL); status = pthread_rwlock_trywrlock(NULL);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_unlock(NULL) -- EINVAL" ); puts( "pthread_rwlock_unlock(NULL) -- EINVAL" );
status = pthread_rwlock_unlock(NULL); status = pthread_rwlock_unlock(NULL);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/*************** BAD ID CHECK *****************/ /*************** BAD ID CHECK *****************/
rwlock = 1; rwlock = 1;
/* make a valid abstime */ /* make a valid abstime */
puts( "clock_gettime(CLOCK_REALTIME, &abstime) -- OK" ); puts( "clock_gettime(CLOCK_REALTIME, &abstime) -- OK" );
status = clock_gettime( CLOCK_REALTIME, &abstime ); status = clock_gettime( CLOCK_REALTIME, &abstime );
assert( !status ); rtems_test_assert( !status );
abstime.tv_sec += 5; abstime.tv_sec += 5;
puts( "pthread_rwlock_destroy(BadId) -- EINVAL" ); puts( "pthread_rwlock_destroy(BadId) -- EINVAL" );
status = pthread_rwlock_destroy(&rwlock); status = pthread_rwlock_destroy(&rwlock);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_rdlock(BadId) -- EINVAL" ); puts( "pthread_rwlock_rdlock(BadId) -- EINVAL" );
status = pthread_rwlock_rdlock(&rwlock); status = pthread_rwlock_rdlock(&rwlock);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_timedrdlock(BadId, &abstime) -- EINVAL" ); puts( "pthread_rwlock_timedrdlock(BadId, &abstime) -- EINVAL" );
status = pthread_rwlock_timedrdlock( &rwlock, &abstime); status = pthread_rwlock_timedrdlock( &rwlock, &abstime);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_tryrdlock(BadId) -- EINVAL" ); puts( "pthread_rwlock_tryrdlock(BadId) -- EINVAL" );
status = pthread_rwlock_tryrdlock(&rwlock); status = pthread_rwlock_tryrdlock(&rwlock);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_wrlock(BadId) -- EINVAL" ); puts( "pthread_rwlock_wrlock(BadId) -- EINVAL" );
status = pthread_rwlock_wrlock(&rwlock); status = pthread_rwlock_wrlock(&rwlock);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_timedwrlock(BadId, &abstime) -- EINVAL" ); puts( "pthread_rwlock_timedwrlock(BadId, &abstime) -- EINVAL" );
status = pthread_rwlock_timedwrlock( &rwlock, &abstime ); status = pthread_rwlock_timedwrlock( &rwlock, &abstime );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_trywrlock(BadId) -- EINVAL" ); puts( "pthread_rwlock_trywrlock(BadId) -- EINVAL" );
status = pthread_rwlock_trywrlock(&rwlock); status = pthread_rwlock_trywrlock(&rwlock);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_unlock(BadId) -- EINVAL" ); puts( "pthread_rwlock_unlock(BadId) -- EINVAL" );
status = pthread_rwlock_unlock(&rwlock); status = pthread_rwlock_unlock(&rwlock);
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/*************** BAD ABSTIME CHECK *****************/ /*************** BAD ABSTIME CHECK *****************/
@@ -263,66 +262,66 @@ int main(
/*************** ACTUALLY CREATE ONE CHECK *****************/ /*************** ACTUALLY CREATE ONE CHECK *****************/
puts( "pthread_rwlockattr_init( &attr ) -- OK" ); puts( "pthread_rwlockattr_init( &attr ) -- OK" );
status = pthread_rwlockattr_init( &attr ); status = pthread_rwlockattr_init( &attr );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_rwlock_init( &rwlock, &attr ) -- OK" ); puts( "pthread_rwlock_init( &rwlock, &attr ) -- OK" );
status = pthread_rwlock_init( &rwlock, &attr ); status = pthread_rwlock_init( &rwlock, &attr );
assert( status == 0 ); rtems_test_assert( status == 0 );
assert( rwlock != 0 ); rtems_test_assert( rwlock != 0 );
puts( "pthread_rwlock_init( &rwlock, &attr ) -- EAGAIN" ); puts( "pthread_rwlock_init( &rwlock, &attr ) -- EAGAIN" );
status = pthread_rwlock_init( &rwlock, &attr ); status = pthread_rwlock_init( &rwlock, &attr );
assert( status == EAGAIN ); rtems_test_assert( status == EAGAIN );
puts( "pthread_rwlock_destroy( &rwlock ) -- OK" ); puts( "pthread_rwlock_destroy( &rwlock ) -- OK" );
status = pthread_rwlock_destroy( &rwlock ); status = pthread_rwlock_destroy( &rwlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
/********* CREATE RWLOCK WITH DEFAULT ATTRIBUTES AND DESTROY IT *********/ /********* CREATE RWLOCK WITH DEFAULT ATTRIBUTES AND DESTROY IT *********/
puts( "pthread_rwlock_init( &rwlock, NULL ) -- OK" ); puts( "pthread_rwlock_init( &rwlock, NULL ) -- OK" );
status = pthread_rwlock_init( &rwlock, NULL ); status = pthread_rwlock_init( &rwlock, NULL );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_rwlock_destroy( &rwlock ) -- OK" ); puts( "pthread_rwlock_destroy( &rwlock ) -- OK" );
status = pthread_rwlock_destroy( &rwlock ); status = pthread_rwlock_destroy( &rwlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
/*************** CREATE THREADS AND LET THEM OBTAIN READLOCK ***************/ /*************** CREATE THREADS AND LET THEM OBTAIN READLOCK ***************/
puts( "pthread_rwlock_init( &RWLock, &attr ) -- OK" ); puts( "pthread_rwlock_init( &RWLock, &attr ) -- OK" );
status = pthread_rwlock_init( &RWLock, &attr ); status = pthread_rwlock_init( &RWLock, &attr );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_rwlock_tryrdlock(RWLock) -- OK" ); puts( "pthread_rwlock_tryrdlock(RWLock) -- OK" );
status = pthread_rwlock_tryrdlock(&RWLock); status = pthread_rwlock_tryrdlock(&RWLock);
assert( !status ); rtems_test_assert( !status );
for (i=0 ; i<NUMBER_THREADS ; i++ ) { for (i=0 ; i<NUMBER_THREADS ; i++ ) {
printf( "Init: pthread_create - thread %d OK\n", i+1 ); printf( "Init: pthread_create - thread %d OK\n", i+1 );
status = pthread_create(&ThreadIds[i], NULL, ReadLockThread, &ThreadIds[i]); status = pthread_create(&ThreadIds[i], NULL, ReadLockThread, &ThreadIds[i]);
assert( !status ); rtems_test_assert( !status );
sleep(1); sleep(1);
} }
puts( "pthread_rwlock_unlock(RWLock) -- OK" ); puts( "pthread_rwlock_unlock(RWLock) -- OK" );
status = pthread_rwlock_unlock(&RWLock); status = pthread_rwlock_unlock(&RWLock);
assert( !status ); rtems_test_assert( !status );
sleep(1); sleep(1);
/*************** CREATE THREADS AND LET THEM OBTAIN READLOCK ***************/ /*************** CREATE THREADS AND LET THEM OBTAIN READLOCK ***************/
puts( "pthread_rwlock_trywrlock(RWLock) -- OK" ); puts( "pthread_rwlock_trywrlock(RWLock) -- OK" );
status = pthread_rwlock_trywrlock(&RWLock); status = pthread_rwlock_trywrlock(&RWLock);
assert( !status ); rtems_test_assert( !status );
puts( "pthread_rwlock_tryrdlock(&RWLock) -- EBUSY" ); puts( "pthread_rwlock_tryrdlock(&RWLock) -- EBUSY" );
status = pthread_rwlock_tryrdlock(&RWLock); status = pthread_rwlock_tryrdlock(&RWLock);
assert( status == EBUSY ); rtems_test_assert( status == EBUSY );
for (i=0 ; i<NUMBER_THREADS ; i++ ) { for (i=0 ; i<NUMBER_THREADS ; i++ ) {
printf( "Init: pthread_create - thread %d OK\n", i+1 ); printf( "Init: pthread_create - thread %d OK\n", i+1 );
status = pthread_create(&ThreadIds[i], NULL, ReadLockThread, &ThreadIds[i]); status = pthread_create(&ThreadIds[i], NULL, ReadLockThread, &ThreadIds[i]);
assert( !status ); rtems_test_assert( !status );
sleep(1); sleep(1);
} }
@@ -330,101 +329,101 @@ int main(
/* Attempt delete while threads are blocked */ /* Attempt delete while threads are blocked */
puts( "pthread_rwlock_destroy( &RWLock ) -- EBUSY" ); puts( "pthread_rwlock_destroy( &RWLock ) -- EBUSY" );
status = pthread_rwlock_destroy( &RWLock ); status = pthread_rwlock_destroy( &RWLock );
assert( status == EBUSY ); rtems_test_assert( status == EBUSY );
/* now unlock it so the threads can continue */ /* now unlock it so the threads can continue */
puts( "pthread_rwlock_unlock(RWLock) -- OK" ); puts( "pthread_rwlock_unlock(RWLock) -- OK" );
status = pthread_rwlock_unlock(&RWLock); status = pthread_rwlock_unlock(&RWLock);
assert( !status ); rtems_test_assert( !status );
sleep(2); sleep(2);
/*************** CREATE THREADS AND LET THEM OBTAIN WRITE LOCK *************/ /*************** CREATE THREADS AND LET THEM OBTAIN WRITE LOCK *************/
puts( "pthread_rwlock_trywrlock(RWLock) -- OK" ); puts( "pthread_rwlock_trywrlock(RWLock) -- OK" );
status = pthread_rwlock_trywrlock(&RWLock); status = pthread_rwlock_trywrlock(&RWLock);
assert( !status ); rtems_test_assert( !status );
puts( "pthread_rwlock_trywrlock(&RWLock) -- EBUSY" ); puts( "pthread_rwlock_trywrlock(&RWLock) -- EBUSY" );
status = pthread_rwlock_trywrlock(&RWLock); status = pthread_rwlock_trywrlock(&RWLock);
assert( status == EBUSY ); rtems_test_assert( status == EBUSY );
for (i=0 ; i<NUMBER_THREADS ; i++ ) { for (i=0 ; i<NUMBER_THREADS ; i++ ) {
printf( "Init: pthread_create - thread %d OK\n", i+1 ); printf( "Init: pthread_create - thread %d OK\n", i+1 );
status = status =
pthread_create(&ThreadIds[i], NULL, WriteLockThread, &ThreadIds[i]); pthread_create(&ThreadIds[i], NULL, WriteLockThread, &ThreadIds[i]);
assert( !status ); rtems_test_assert( !status );
sleep(1); sleep(1);
} }
puts( "pthread_rwlock_unlock(RWLock) -- OK" ); puts( "pthread_rwlock_unlock(RWLock) -- OK" );
status = pthread_rwlock_unlock(&RWLock); status = pthread_rwlock_unlock(&RWLock);
assert( !status ); rtems_test_assert( !status );
sleep(2); sleep(2);
/*************** TIMEOUT ON RWLOCK ***************/ /*************** TIMEOUT ON RWLOCK ***************/
puts( "clock_gettime(CLOCK_REALTIME, &abstime) -- OK" ); puts( "clock_gettime(CLOCK_REALTIME, &abstime) -- OK" );
status = clock_gettime( CLOCK_REALTIME, &abstime ); status = clock_gettime( CLOCK_REALTIME, &abstime );
assert( !status ); rtems_test_assert( !status );
abstime.tv_sec += 1; abstime.tv_sec += 1;
puts( "pthread_rwlock_timedwrlock( &RWLock, &abstime) -- OK" ); puts( "pthread_rwlock_timedwrlock( &RWLock, &abstime) -- OK" );
status = pthread_rwlock_timedwrlock( &RWLock, &abstime ); status = pthread_rwlock_timedwrlock( &RWLock, &abstime );
assert( status == 0 ); rtems_test_assert( status == 0 );
abstime.tv_sec += 1; abstime.tv_sec += 1;
puts( "pthread_rwlock_timedrdlock( &RWLock, &abstime) -- ETIMEDOUT" ); puts( "pthread_rwlock_timedrdlock( &RWLock, &abstime) -- ETIMEDOUT" );
status = pthread_rwlock_timedrdlock( &RWLock, &abstime ); status = pthread_rwlock_timedrdlock( &RWLock, &abstime );
assert( status == ETIMEDOUT ); rtems_test_assert( status == ETIMEDOUT );
abstime.tv_sec -= 1; abstime.tv_sec -= 1;
puts( "pthread_rwlock_timedrdlock( &RWLock, &abstime) -- ETIMEDOUT" ); puts( "pthread_rwlock_timedrdlock( &RWLock, &abstime) -- ETIMEDOUT" );
status = pthread_rwlock_timedrdlock( &RWLock, &abstime ); status = pthread_rwlock_timedrdlock( &RWLock, &abstime );
assert( status == ETIMEDOUT ); rtems_test_assert( status == ETIMEDOUT );
abstime.tv_sec -= 1; abstime.tv_sec -= 1;
puts( "pthread_rwlock_timedwrlock( &RWLock, &abstime) -- ETIMEDOUT" ); puts( "pthread_rwlock_timedwrlock( &RWLock, &abstime) -- ETIMEDOUT" );
status = pthread_rwlock_timedwrlock( &RWLock, &abstime ); status = pthread_rwlock_timedwrlock( &RWLock, &abstime );
assert( status == ETIMEDOUT ); rtems_test_assert( status == ETIMEDOUT );
/*************** OBTAIN RWLOCK WITH ABSTIME IN PAST ***************/ /*************** OBTAIN RWLOCK WITH ABSTIME IN PAST ***************/
status = pthread_rwlock_unlock(&RWLock); status = pthread_rwlock_unlock(&RWLock);
assert( !status ); rtems_test_assert( !status );
abstime.tv_sec -= 1; abstime.tv_sec -= 1;
puts( "pthread_rwlock_timedrdlock( &RWLock, &abstime) -- in past -- OK" ); puts( "pthread_rwlock_timedrdlock( &RWLock, &abstime) -- in past -- OK" );
status = pthread_rwlock_timedrdlock( &RWLock, &abstime ); status = pthread_rwlock_timedrdlock( &RWLock, &abstime );
assert( status == 0 ); rtems_test_assert( status == 0 );
/*************** OBTAIN RWLOCK FOR WRITE WITH ABSTIME IN PAST ***************/ /*************** OBTAIN RWLOCK FOR WRITE WITH ABSTIME IN PAST ***************/
status = pthread_rwlock_unlock(&RWLock); status = pthread_rwlock_unlock(&RWLock);
assert( !status ); rtems_test_assert( !status );
abstime.tv_sec -= 1; abstime.tv_sec -= 1;
puts( "pthread_rwlock_timedwrlock( &RWLock, &abstime) -- in past -- OK" ); puts( "pthread_rwlock_timedwrlock( &RWLock, &abstime) -- in past -- OK" );
status = pthread_rwlock_timedwrlock( &RWLock, &abstime ); status = pthread_rwlock_timedwrlock( &RWLock, &abstime );
assert( status == 0 ); rtems_test_assert( status == 0 );
/*************** DESTROY RWLOCK ***************/ /*************** DESTROY RWLOCK ***************/
puts( "pthread_rwlock_destroy( &RWLock ) -- OK" ); puts( "pthread_rwlock_destroy( &RWLock ) -- OK" );
status = pthread_rwlock_destroy( &RWLock ); status = pthread_rwlock_destroy( &RWLock );
assert( status == 0 ); rtems_test_assert( status == 0 );
/*************** OBTAIN A LOCK AND THEN RELEASE IT TWICE ***************/ /*************** OBTAIN A LOCK AND THEN RELEASE IT TWICE ***************/
puts( "pthread_rwlock_init( &rwlock, NULL ) -- OK" ); puts( "pthread_rwlock_init( &rwlock, NULL ) -- OK" );
status = pthread_rwlock_init( &rwlock, NULL ); status = pthread_rwlock_init( &rwlock, NULL );
assert( status == 0 ); rtems_test_assert( status == 0 );
assert( rwlock != 0 ); rtems_test_assert( rwlock != 0 );
puts( "pthread_rwlock_unlock ( &rwlock ) -- OK" ); puts( "pthread_rwlock_unlock ( &rwlock ) -- OK" );
status = pthread_rwlock_unlock( &rwlock ); status = pthread_rwlock_unlock( &rwlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_rwlock_unlock ( &rwlock ) -- OK" ); puts( "pthread_rwlock_unlock ( &rwlock ) -- OK" );
status = pthread_rwlock_unlock( &rwlock ); status = pthread_rwlock_unlock( &rwlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
/*************** END OF TEST *****************/ /*************** END OF TEST *****************/
puts( "*** END OF POSIX RWLOCK TEST 01 ***" ); puts( "*** END OF POSIX RWLOCK TEST 01 ***" );

View File

@@ -178,7 +178,7 @@ void *POSIX_Init(
puts( "Init: sem_open - sem1 SUCCESSFUL" ); puts( "Init: sem_open - sem1 SUCCESSFUL" );
n_sem1 = sem_open( "sem1",O_CREAT, 0777, 1 ); n_sem1 = sem_open( "sem1",O_CREAT, 0777, 1 );
assert( n_sem1 != SEM_FAILED ); rtems_test_assert( n_sem1 != SEM_FAILED );
puts( "Init: sem_destroy - named sem1 - EINVAL" ); puts( "Init: sem_destroy - named sem1 - EINVAL" );
status = sem_destroy(n_sem1); status = sem_destroy(n_sem1);
@@ -218,7 +218,7 @@ void *POSIX_Init(
puts( "Init: sem_open - Open an existing sem ( same id )" ); puts( "Init: sem_open - Open an existing sem ( same id )" );
n_sem2 = sem_open("sem1", 0 ); n_sem2 = sem_open("sem1", 0 );
assert( n_sem2 == n_sem1 ); rtems_test_assert( n_sem2 == n_sem1 );
/* /*
* Unlink the semaphore, then verify an open of the same name produces a * Unlink the semaphore, then verify an open of the same name produces a
@@ -231,8 +231,8 @@ void *POSIX_Init(
puts( "Init: sem_open - Reopen sem1 SUCCESSFUL with a different id" ); puts( "Init: sem_open - Reopen sem1 SUCCESSFUL with a different id" );
n_sem2 = sem_open( "sem1", O_CREAT | O_EXCL, 0777, 1); n_sem2 = sem_open( "sem1", O_CREAT | O_EXCL, 0777, 1);
assert( n_sem2 != SEM_FAILED ); rtems_test_assert( n_sem2 != SEM_FAILED );
assert( n_sem2 != n_sem1 ); rtems_test_assert( n_sem2 != n_sem1 );
/* /*
* Validate we can call close on a semaphore opened with sem_open. * Validate we can call close on a semaphore opened with sem_open.
@@ -289,7 +289,7 @@ void *POSIX_Init(
status = sem_unlink("sem2"); status = sem_unlink("sem2");
fatal_posix_service_status( status, -1, "sem_unlink error return status"); fatal_posix_service_status( status, -1, "sem_unlink error return status");
fatal_posix_service_status( errno, ENOENT, "sem_unlink errno ENOENT"); fatal_posix_service_status( errno, ENOENT, "sem_unlink errno ENOENT");
assert( (status == -1) && (errno == ENOENT) ); rtems_test_assert( (status == -1) && (errno == ENOENT) );
/* Try adding in unlinking before closing... (can we still open?) */ /* Try adding in unlinking before closing... (can we still open?) */

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -124,23 +124,23 @@ void *POSIX_Init(
/* unblock Signal and see if it happened */ /* unblock Signal and see if it happened */
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGUSR1 ); status = sigaddset( &mask, SIGUSR1 );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGFPE ); status = sigaddset( &mask, SIGFPE );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGILL ); status = sigaddset( &mask, SIGILL );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGSEGV ); status = sigaddset( &mask, SIGSEGV );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Unblock SIGUSR1 SIGFPE SIGILL SIGSEGV" ); puts( "Init: Unblock SIGUSR1 SIGFPE SIGILL SIGSEGV" );
status = sigprocmask( SIG_UNBLOCK, &mask, NULL ); status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
assert( !status ); rtems_test_assert( !status );
/* install a signal handler for SIGUSR1 */ /* install a signal handler for SIGUSR1 */
Signal_occurred = 0; Signal_occurred = 0;

View File

@@ -7,7 +7,7 @@
* *
* Output parameters: NONE * Output parameters: NONE
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -30,7 +30,7 @@ void *Task_1(
seconds = sleep( 5 ); seconds = sleep( 5 );
printf( "Task_1: %d seconds left\n", seconds ); printf( "Task_1: %d seconds left\n", seconds );
assert( seconds ); rtems_test_assert( seconds );
/* switch to Init */ /* switch to Init */

View File

@@ -35,14 +35,14 @@ void Install_Signal_Handler(
sigset_t mask; sigset_t mask;
sc = sigemptyset( &mask ); sc = sigemptyset( &mask );
assert( !sc ); rtems_test_assert( !sc );
sc = sigaddset( &mask, SIGUSR1 ); sc = sigaddset( &mask, SIGUSR1 );
assert( !sc ); rtems_test_assert( !sc );
printf( "%s - Unblock SIGUSR1\n", task_name ); printf( "%s - Unblock SIGUSR1\n", task_name );
sc = pthread_sigmask( SIG_UNBLOCK, &mask, NULL ); sc = pthread_sigmask( SIG_UNBLOCK, &mask, NULL );
assert( !sc ); rtems_test_assert( !sc );
} }
/* /*
@@ -137,43 +137,43 @@ void *POSIX_Init(
puts( "Init - Raise my priority" ); puts( "Init - Raise my priority" );
sc = pthread_attr_init( &attr ); sc = pthread_attr_init( &attr );
assert( !sc ); rtems_test_assert( !sc );
param.sched_priority = 30; param.sched_priority = 30;
sc = pthread_setschedparam( pthread_self(), SCHED_RR, &param ); sc = pthread_setschedparam( pthread_self(), SCHED_RR, &param );
assert( !sc ); rtems_test_assert( !sc );
for ( i=0, test=Threads ; test->priority != -1 ; i++, test++ ) { for ( i=0, test=Threads ; test->priority != -1 ; i++, test++ ) {
printf( "Init - Create thread %d, priority=%d\n", i, test->priority ); printf( "Init - Create thread %d, priority=%d\n", i, test->priority );
sc = pthread_attr_init( &attr ); sc = pthread_attr_init( &attr );
assert( !sc ); rtems_test_assert( !sc );
sc = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); sc = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
assert( !sc ); rtems_test_assert( !sc );
sc = pthread_attr_setschedpolicy( &attr, SCHED_RR ); sc = pthread_attr_setschedpolicy( &attr, SCHED_RR );
assert( !sc ); rtems_test_assert( !sc );
param.sched_priority = test->priority; param.sched_priority = test->priority;
sc = pthread_attr_setschedparam( &attr, &param ); sc = pthread_attr_setschedparam( &attr, &param );
assert( !sc ); rtems_test_assert( !sc );
sc = pthread_create( &id, &attr, Test_Thread, test ); sc = pthread_create( &id, &attr, Test_Thread, test );
assert( !sc ); rtems_test_assert( !sc );
puts( "Init - sleep - let thread settle - OK" ); puts( "Init - sleep - let thread settle - OK" );
delay_request.tv_sec = 0; delay_request.tv_sec = 0;
delay_request.tv_nsec = 50000000; delay_request.tv_nsec = 50000000;
sc = nanosleep( &delay_request, NULL ); sc = nanosleep( &delay_request, NULL );
assert( !sc ); rtems_test_assert( !sc );
} }
puts( "Init - sending SIGUSR1" ); puts( "Init - sending SIGUSR1" );
sc = kill( getpid(), SIGUSR1 ); sc = kill( getpid(), SIGUSR1 );
assert( !sc ); rtems_test_assert( !sc );
/* we are just scheduling the signal, not delivering it */ /* we are just scheduling the signal, not delivering it */
assert( Signal_occurred == false ); rtems_test_assert( Signal_occurred == false );
puts( "*** END OF POSIX TEST SIGNAL 02 ***" ); puts( "*** END OF POSIX TEST SIGNAL 02 ***" );
rtems_test_exit(0); rtems_test_exit(0);

View File

@@ -94,35 +94,35 @@ void *Test_Thread(void *arg)
/* build unblocked mask */ /* build unblocked mask */
sc = sigemptyset( &mask ); sc = sigemptyset( &mask );
assert( !sc ); rtems_test_assert( !sc );
printf( "%s - Unblock %s\n", name, signal_name(SIGNAL_ONE) ); printf( "%s - Unblock %s\n", name, signal_name(SIGNAL_ONE) );
sc = sigaddset( &mask, SIGNAL_ONE ); sc = sigaddset( &mask, SIGNAL_ONE );
assert( !sc ); rtems_test_assert( !sc );
if ( !blocked ) { if ( !blocked ) {
printf( "%s - Unblock %s\n", name, signal_name(SIGNAL_TWO) ); printf( "%s - Unblock %s\n", name, signal_name(SIGNAL_TWO) );
sc = sigaddset( &mask, SIGNAL_TWO ); sc = sigaddset( &mask, SIGNAL_TWO );
assert( !sc ); rtems_test_assert( !sc );
} }
/* unblocked signals */ /* unblocked signals */
sc = pthread_sigmask( SIG_UNBLOCK, &mask, NULL ); sc = pthread_sigmask( SIG_UNBLOCK, &mask, NULL );
assert( !sc ); rtems_test_assert( !sc );
/* build wait mask */ /* build wait mask */
sc = sigemptyset( &wait_mask ); sc = sigemptyset( &wait_mask );
assert( !sc ); rtems_test_assert( !sc );
sc = sigaddset( &wait_mask, SIGNAL_ONE ); sc = sigaddset( &wait_mask, SIGNAL_ONE );
assert( !sc ); rtems_test_assert( !sc );
/* wait for a signal */ /* wait for a signal */
memset( &info, 0, sizeof(info) ); memset( &info, 0, sizeof(info) );
printf( "%s - Wait for %s unblocked\n", name, signal_name(SIGNAL_ONE) ); printf( "%s - Wait for %s unblocked\n", name, signal_name(SIGNAL_ONE) );
sigwaitinfo( &wait_mask, &info ); sigwaitinfo( &wait_mask, &info );
assert( !sc ); rtems_test_assert( !sc );
printf( "%s - siginfo.si_signo=%d\n", name, info.si_signo ); printf( "%s - siginfo.si_signo=%d\n", name, info.si_signo );
printf( "%s - siginfo.si_code=%d\n", name, info.si_code ); printf( "%s - siginfo.si_code=%d\n", name, info.si_code );
@@ -132,8 +132,8 @@ void *Test_Thread(void *arg)
* "implementation defined" */ * "implementation defined" */
printf( "%s - siginfo.si_value=0x%08" PRIxPTR "\n", name, (uintptr_t) info.si_value.sival_ptr ); printf( "%s - siginfo.si_value=0x%08" PRIxPTR "\n", name, (uintptr_t) info.si_value.sival_ptr );
assert( info.si_signo == SIGNAL_TWO ); rtems_test_assert( info.si_signo == SIGNAL_TWO );
assert( info.si_code == SI_USER ); rtems_test_assert( info.si_code == SI_USER );
printf( "%s - exiting\n", name ); printf( "%s - exiting\n", name );
return NULL; return NULL;
@@ -163,43 +163,43 @@ void *POSIX_Init(
/* create threads */ /* create threads */
sc = pthread_create( &id, NULL, Test_Thread, &falseArg ); sc = pthread_create( &id, NULL, Test_Thread, &falseArg );
assert( !sc ); rtems_test_assert( !sc );
sc = pthread_create( &id, NULL, Test_Thread, &trueArg ); sc = pthread_create( &id, NULL, Test_Thread, &trueArg );
assert( !sc ); rtems_test_assert( !sc );
puts( "Init - sleep - let threads settle - OK" ); puts( "Init - sleep - let threads settle - OK" );
delay_request.tv_sec = 0; delay_request.tv_sec = 0;
delay_request.tv_nsec = 5 * 100000000; delay_request.tv_nsec = 5 * 100000000;
sc = nanosleep( &delay_request, NULL ); sc = nanosleep( &delay_request, NULL );
assert( !sc ); rtems_test_assert( !sc );
puts( "Init - sleep - SignalBlocked thread settle - OK" ); puts( "Init - sleep - SignalBlocked thread settle - OK" );
sc = nanosleep( &delay_request, NULL ); sc = nanosleep( &delay_request, NULL );
assert( !sc ); rtems_test_assert( !sc );
printf( "Init - sending %s - deliver to one thread\n", printf( "Init - sending %s - deliver to one thread\n",
signal_name(SIGNAL_TWO)); signal_name(SIGNAL_TWO));
sc = SEND_SIGNAL( SIGNAL_TWO ); sc = SEND_SIGNAL( SIGNAL_TWO );
assert( !sc ); rtems_test_assert( !sc );
printf( "Init - sending %s - deliver to other thread\n", printf( "Init - sending %s - deliver to other thread\n",
signal_name(SIGNAL_TWO)); signal_name(SIGNAL_TWO));
sc = SEND_SIGNAL( SIGNAL_TWO ); sc = SEND_SIGNAL( SIGNAL_TWO );
assert( !sc ); rtems_test_assert( !sc );
#if defined(TO_PROCESS) #if defined(TO_PROCESS)
printf( "Init - sending %s - expect EAGAIN\n", signal_name(SIGNAL_TWO) ); printf( "Init - sending %s - expect EAGAIN\n", signal_name(SIGNAL_TWO) );
sc = SEND_SIGNAL( SIGNAL_TWO ); sc = SEND_SIGNAL( SIGNAL_TWO );
assert( sc == -1 ); rtems_test_assert( sc == -1 );
assert( errno == EAGAIN ); rtems_test_assert( errno == EAGAIN );
#endif #endif
puts( "Init - sleep - let thread report if it unblocked - OK" ); puts( "Init - sleep - let thread report if it unblocked - OK" );
usleep(500000); usleep(500000);
/* we are just sigwait'ing the signal, not delivering it */ /* we are just sigwait'ing the signal, not delivering it */
assert( Signal_occurred == true ); rtems_test_assert( Signal_occurred == true );
puts( "*** END OF POSIX TEST SIGNAL " TEST_NAME " ***" ); puts( "*** END OF POSIX TEST SIGNAL " TEST_NAME " ***" );
rtems_test_exit(0); rtems_test_exit(0);

View File

@@ -74,7 +74,7 @@ void *POSIX_Init(
true, /* is_global */ true, /* is_global */
false /* check_blocked */ false /* check_blocked */
); );
assert( bc ); rtems_test_assert( bc );
puts( "*** END OF POSIX TEST SIGNAL " TEST_NAME " ***" ); puts( "*** END OF POSIX TEST SIGNAL " TEST_NAME " ***" );
rtems_test_exit(0); rtems_test_exit(0);

View File

@@ -1,7 +1,7 @@
/* /*
* This test exercises the POSIX Spinlock manager. * This test exercises the POSIX Spinlock manager.
* *
* COPYRIGHT (c) 1989-2006. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -11,7 +11,6 @@
* $Id$ * $Id$
*/ */
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
@@ -34,7 +33,7 @@ rtems_task SpinlockThread(rtems_task_argument arg)
} }
puts( "pthread_spin_lock( &Spinlock ) from Thread -- OK" ); puts( "pthread_spin_lock( &Spinlock ) from Thread -- OK" );
status = pthread_spin_lock( &Spinlock ); status = pthread_spin_lock( &Spinlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "sleep to allow main thread to run" ); puts( "sleep to allow main thread to run" );
sleep( 1 ); sleep( 1 );
@@ -46,7 +45,7 @@ rtems_task SpinlockThread(rtems_task_argument arg)
puts( "pthread_spin_unlock( &Spinlock ) from Thread -- OK" ); puts( "pthread_spin_unlock( &Spinlock ) from Thread -- OK" );
status = pthread_spin_unlock( &Spinlock ); status = pthread_spin_unlock( &Spinlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
rtems_task_delete( RTEMS_SELF ); rtems_task_delete( RTEMS_SELF );
} }
@@ -73,96 +72,96 @@ int main(
puts( "pthread_spin_init( NULL, PTHREAD_PROCESS_PRIVATE ) -- EINVAL" ); puts( "pthread_spin_init( NULL, PTHREAD_PROCESS_PRIVATE ) -- EINVAL" );
status = pthread_spin_init( NULL, PTHREAD_PROCESS_PRIVATE ); status = pthread_spin_init( NULL, PTHREAD_PROCESS_PRIVATE );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_spin_init( NULL, PTHREAD_PROCESS_SHARED ) -- EINVAL" ); puts( "pthread_spin_init( NULL, PTHREAD_PROCESS_SHARED ) -- EINVAL" );
status = pthread_spin_init( NULL, PTHREAD_PROCESS_PRIVATE ); status = pthread_spin_init( NULL, PTHREAD_PROCESS_PRIVATE );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_spin_init( &spinlock, 0x1234 ) -- EINVAL" ); puts( "pthread_spin_init( &spinlock, 0x1234 ) -- EINVAL" );
status = pthread_spin_init( &spinlock, 0x1234 ); status = pthread_spin_init( &spinlock, 0x1234 );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_spin_init( &spinlock, PTHREAD_PROCESS_SHARED ) -- EINVAL" ); puts( "pthread_spin_init( &spinlock, PTHREAD_PROCESS_SHARED ) -- EINVAL" );
status = pthread_spin_init( &spinlock, PTHREAD_PROCESS_SHARED ); status = pthread_spin_init( &spinlock, PTHREAD_PROCESS_SHARED );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
/* This successfully creates one */ /* This successfully creates one */
puts( "pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ) -- OK" ); puts( "pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ) -- OK" );
status = pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ); status = pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ) -- EAGAIN" ); puts( "pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ) -- EAGAIN" );
status = pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ); status = pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE );
assert( status == EAGAIN ); rtems_test_assert( status == EAGAIN );
puts( "pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ) -- EAGAIN" ); puts( "pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ) -- EAGAIN" );
status = pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE ); status = pthread_spin_init( &spinlock, PTHREAD_PROCESS_PRIVATE );
assert( status == EAGAIN ); rtems_test_assert( status == EAGAIN );
puts( "pthread_spin_lock( NULL ) -- EINVAL" ); puts( "pthread_spin_lock( NULL ) -- EINVAL" );
status = pthread_spin_lock( NULL ); status = pthread_spin_lock( NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_spin_trylock( NULL ) -- EINVAL" ); puts( "pthread_spin_trylock( NULL ) -- EINVAL" );
status = pthread_spin_trylock( NULL ); status = pthread_spin_trylock( NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_spin_unlock( NULL ) -- EINVAL" ); puts( "pthread_spin_unlock( NULL ) -- EINVAL" );
status = pthread_spin_unlock( NULL ); status = pthread_spin_unlock( NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_spin_destroy( NULL ) -- EINVAL" ); puts( "pthread_spin_destroy( NULL ) -- EINVAL" );
status = pthread_spin_destroy( NULL ); status = pthread_spin_destroy( NULL );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
spinlock = 0; spinlock = 0;
puts( "pthread_spin_lock( &spinlock ) -- EINVAL" ); puts( "pthread_spin_lock( &spinlock ) -- EINVAL" );
status = pthread_spin_lock( &spinlock ); status = pthread_spin_lock( &spinlock );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_spin_trylock( &spinlock ) -- EINVAL" ); puts( "pthread_spin_trylock( &spinlock ) -- EINVAL" );
status = pthread_spin_trylock( &spinlock ); status = pthread_spin_trylock( &spinlock );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_spin_unlock( &spinlock ) -- EINVAL" ); puts( "pthread_spin_unlock( &spinlock ) -- EINVAL" );
status = pthread_spin_unlock( &spinlock ); status = pthread_spin_unlock( &spinlock );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_spin_destroy( &spinlock ) -- EINVAL" ); puts( "pthread_spin_destroy( &spinlock ) -- EINVAL" );
status = pthread_spin_destroy( &spinlock ); status = pthread_spin_destroy( &spinlock );
assert( status == EINVAL ); rtems_test_assert( status == EINVAL );
puts( "pthread_spin_unlock( &Spinlock ) -- already unlocked OK" ); puts( "pthread_spin_unlock( &Spinlock ) -- already unlocked OK" );
status = pthread_spin_unlock( &Spinlock ); status = pthread_spin_unlock( &Spinlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* Now some basic locking and unlocking with a deadlock verification */ /* Now some basic locking and unlocking with a deadlock verification */
puts( "pthread_spin_lock( &Spinlock ) -- OK" ); puts( "pthread_spin_lock( &Spinlock ) -- OK" );
status = pthread_spin_lock( &Spinlock ); status = pthread_spin_lock( &Spinlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_spin_lock( &Spinlock ) -- EDEADLK" ); puts( "pthread_spin_lock( &Spinlock ) -- EDEADLK" );
status = pthread_spin_lock( &Spinlock ); status = pthread_spin_lock( &Spinlock );
assert( status == EDEADLK ); rtems_test_assert( status == EDEADLK );
puts( "pthread_spin_trylock( &Spinlock ) -- EDEADLK" ); puts( "pthread_spin_trylock( &Spinlock ) -- EDEADLK" );
status = pthread_spin_trylock( &Spinlock ); status = pthread_spin_trylock( &Spinlock );
assert( status == EDEADLK ); rtems_test_assert( status == EDEADLK );
puts( "pthread_spin_unlock( &Spinlock ) -- OK" ); puts( "pthread_spin_unlock( &Spinlock ) -- OK" );
status = pthread_spin_unlock( &Spinlock ); status = pthread_spin_unlock( &Spinlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* Try lock/unlock pair */ /* Try lock/unlock pair */
puts( "pthread_spin_trylock( &Spinlock ) -- OK" ); puts( "pthread_spin_trylock( &Spinlock ) -- OK" );
status = pthread_spin_trylock( &Spinlock ); status = pthread_spin_trylock( &Spinlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_spin_unlock( &Spinlock ) -- OK" ); puts( "pthread_spin_unlock( &Spinlock ) -- OK" );
status = pthread_spin_unlock( &Spinlock ); status = pthread_spin_unlock( &Spinlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* Let another thread lock a spinlock and we contend with it */ /* Let another thread lock a spinlock and we contend with it */
@@ -177,10 +176,10 @@ int main(
RTEMS_DEFAULT_ATTRIBUTES, RTEMS_DEFAULT_ATTRIBUTES,
&taskid &taskid
); );
assert( rstatus == RTEMS_SUCCESSFUL ); rtems_test_assert( rstatus == RTEMS_SUCCESSFUL );
rstatus = rtems_task_start( taskid, SpinlockThread, 0 ); rstatus = rtems_task_start( taskid, SpinlockThread, 0 );
assert( rstatus == RTEMS_SUCCESSFUL ); rtems_test_assert( rstatus == RTEMS_SUCCESSFUL );
/* We should be preempted immediately. The thread is expected to: /* We should be preempted immediately. The thread is expected to:
* + verify we haven't set the main thread spinning flag * + verify we haven't set the main thread spinning flag
* + lock the spinlock * + lock the spinlock
@@ -190,7 +189,7 @@ int main(
mainThreadSpinning = 1; mainThreadSpinning = 1;
puts( "pthread_spin_lock( &Spinlock ) -- OK" ); puts( "pthread_spin_lock( &Spinlock ) -- OK" );
status = pthread_spin_lock( &Spinlock ); status = pthread_spin_lock( &Spinlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* The thread wakes up, unlocks spin lock, and deletes itself. /* The thread wakes up, unlocks spin lock, and deletes itself.
* So when we get back here, about a second has passed and we now * So when we get back here, about a second has passed and we now
@@ -200,16 +199,16 @@ int main(
/* spin lock should be locked when we return so destroying it gives busy */ /* spin lock should be locked when we return so destroying it gives busy */
puts( "pthread_spin_destroy( &Spinlock ) -- EBUSY" ); puts( "pthread_spin_destroy( &Spinlock ) -- EBUSY" );
status = pthread_spin_destroy( &Spinlock ); status = pthread_spin_destroy( &Spinlock );
assert( status == EBUSY ); rtems_test_assert( status == EBUSY );
/* Unlock it for a normal destroy */ /* Unlock it for a normal destroy */
puts( "pthread_spin_unlock( &Spinlock ) -- OK" ); puts( "pthread_spin_unlock( &Spinlock ) -- OK" );
status = pthread_spin_unlock( &Spinlock ); status = pthread_spin_unlock( &Spinlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_spin_destroy( &Spinlock ) -- OK" ); puts( "pthread_spin_destroy( &Spinlock ) -- OK" );
status = pthread_spin_destroy( &Spinlock ); status = pthread_spin_destroy( &Spinlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
/*************** END OF TEST *****************/ /*************** END OF TEST *****************/
puts( "*** END OF POSIX SPINLOCK TEST 01 ***" ); puts( "*** END OF POSIX SPINLOCK TEST 01 ***" );

View File

@@ -1,7 +1,7 @@
/* /*
* This test exercises the POSIX Spinlock manager. * This test exercises the POSIX Spinlock manager.
* *
* COPYRIGHT (c) 1989-2006. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -11,7 +11,6 @@
* $Id$ * $Id$
*/ */
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
@@ -28,11 +27,11 @@ rtems_task SpinlockThread(rtems_task_argument arg)
puts( "pthread_spin_trylock( &Spinlock ) -- EBUSY" ); puts( "pthread_spin_trylock( &Spinlock ) -- EBUSY" );
status = pthread_spin_trylock( &Spinlock ); status = pthread_spin_trylock( &Spinlock );
assert( status == EBUSY ); rtems_test_assert( status == EBUSY );
puts( "pthread_spin_unlock( &Spinlock ) -- EPERM" ); puts( "pthread_spin_unlock( &Spinlock ) -- EPERM" );
status = pthread_spin_unlock( &Spinlock ); status = pthread_spin_unlock( &Spinlock );
assert( status == EPERM ); rtems_test_assert( status == EPERM );
rtems_task_delete( RTEMS_SELF ); rtems_task_delete( RTEMS_SELF );
} }
@@ -59,12 +58,12 @@ int main(
/* This successfully creates one */ /* This successfully creates one */
puts( "pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ) -- OK" ); puts( "pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ) -- OK" );
status = pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE ); status = pthread_spin_init( &Spinlock, PTHREAD_PROCESS_PRIVATE );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* Lock it */ /* Lock it */
puts( "pthread_spin_lock( &Spinlock ) -- OK" ); puts( "pthread_spin_lock( &Spinlock ) -- OK" );
status = pthread_spin_lock( &Spinlock ); status = pthread_spin_lock( &Spinlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* Create a helper task */ /* Create a helper task */
rstatus = rtems_task_create( rstatus = rtems_task_create(
@@ -75,20 +74,20 @@ int main(
RTEMS_DEFAULT_ATTRIBUTES, RTEMS_DEFAULT_ATTRIBUTES,
&taskid &taskid
); );
assert( rstatus == RTEMS_SUCCESSFUL ); rtems_test_assert( rstatus == RTEMS_SUCCESSFUL );
rstatus = rtems_task_start( taskid, SpinlockThread, 0 ); rstatus = rtems_task_start( taskid, SpinlockThread, 0 );
assert( rstatus == RTEMS_SUCCESSFUL ); rtems_test_assert( rstatus == RTEMS_SUCCESSFUL );
sleep(1); sleep(1);
puts( "pthread_spin_unlock( &Spinlock ) -- OK" ); puts( "pthread_spin_unlock( &Spinlock ) -- OK" );
status = pthread_spin_unlock( &Spinlock ); status = pthread_spin_unlock( &Spinlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
puts( "pthread_spin_destroy( &Spinlock ) -- OK" ); puts( "pthread_spin_destroy( &Spinlock ) -- OK" );
status = pthread_spin_destroy( &Spinlock ); status = pthread_spin_destroy( &Spinlock );
assert( status == 0 ); rtems_test_assert( status == 0 );
/*************** END OF TEST *****************/ /*************** END OF TEST *****************/
puts( "*** END OF POSIX SPINLOCK TEST 02 ***" ); puts( "*** END OF POSIX SPINLOCK TEST 02 ***" );

View File

@@ -55,28 +55,28 @@ void *POSIX_Init(
puts( "Init - Allocate stack from heap" ); puts( "Init - Allocate stack from heap" );
Stack_Low = malloc(PTHREAD_MINIMUM_STACK_SIZE); Stack_Low = malloc(PTHREAD_MINIMUM_STACK_SIZE);
assert( Stack_Low ); rtems_test_assert( Stack_Low );
Stack_High = Stack_Low + PTHREAD_MINIMUM_STACK_SIZE; Stack_High = Stack_Low + PTHREAD_MINIMUM_STACK_SIZE;
puts( "Init - Initialize thread attribute for user provided stack" ); puts( "Init - Initialize thread attribute for user provided stack" );
sc = pthread_attr_init( &attr ); sc = pthread_attr_init( &attr );
assert( !sc ); rtems_test_assert( !sc );
sc = pthread_attr_setstackaddr( &attr, Stack_Low ); sc = pthread_attr_setstackaddr( &attr, Stack_Low );
assert( !sc ); rtems_test_assert( !sc );
sc = pthread_attr_setstacksize( &attr, PTHREAD_MINIMUM_STACK_SIZE ); sc = pthread_attr_setstacksize( &attr, PTHREAD_MINIMUM_STACK_SIZE );
assert( !sc ); rtems_test_assert( !sc );
/* create threads */ /* create threads */
sc = pthread_create( &id, &attr, Test_Thread, NULL ); sc = pthread_create( &id, &attr, Test_Thread, NULL );
assert( !sc ); rtems_test_assert( !sc );
puts( "Init - let other thread run" ); puts( "Init - let other thread run" );
delay_request.tv_sec = 0; delay_request.tv_sec = 0;
delay_request.tv_nsec = 5 * 100000000; delay_request.tv_nsec = 5 * 100000000;
sc = nanosleep( &delay_request, NULL ); sc = nanosleep( &delay_request, NULL );
assert( !sc ); rtems_test_assert( !sc );
puts( "*** END OF POSIX STACK ATTRIBUTE TEST 01 ***" ); puts( "*** END OF POSIX STACK ATTRIBUTE TEST 01 ***" );
rtems_test_exit(0); rtems_test_exit(0);

View File

@@ -13,7 +13,6 @@
*/ */
#include <tmacros.h> #include <tmacros.h>
#include <assert.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
@@ -180,7 +179,7 @@ void stat_a_file(
int minor2; int minor2;
assert( file ); rtems_test_assert( file );
printf( "stat( %s ) returned ", file ); printf( "stat( %s ) returned ", file );
fflush( stdout ); fflush( stdout );
@@ -273,7 +272,7 @@ void make_multiple_files(
while ( files[i] ) { while ( files[i] ) {
printf( "Making file %s\n", files[i] ); printf( "Making file %s\n", files[i] );
status = mknod( files[i], ( S_IFREG | S_IROTH|S_IWOTH ), 0LL ); status = mknod( files[i], ( S_IFREG | S_IROTH|S_IWOTH ), 0LL );
assert( !status ); rtems_test_assert( !status );
i++; i++;
} }
puts( "" ); puts( "" );
@@ -290,7 +289,7 @@ void make_multiple_bad_files(
while ( files[i] ) { while ( files[i] ) {
printf( "Making file %s ", files[i] ); printf( "Making file %s ", files[i] );
status = mknod( files[i], ( S_IFREG | S_IROTH|S_IWOTH ), 0LL ); status = mknod( files[i], ( S_IFREG | S_IROTH|S_IWOTH ), 0LL );
assert( status ); rtems_test_assert( status );
printf( ": %s\n", strerror( errno ) ); printf( ": %s\n", strerror( errno ) );
i++; i++;
} }
@@ -309,16 +308,16 @@ void make_multiple_links(
while ( new[i] && existing[i] ) { while ( new[i] && existing[i] ) {
printf( "Making file %s\n", new[i] ); printf( "Making file %s\n", new[i] );
status = link( existing[i], new[i] ); status = link( existing[i], new[i] );
assert( !status ); rtems_test_assert( !status );
i++; i++;
} }
puts( "" ); puts( "" );
status = link( "fred", "bob" ); status = link( "fred", "bob" );
assert( status == -1 ); rtems_test_assert( status == -1 );
status = link( existing[1], "doug/bob" ); status = link( existing[1], "doug/bob" );
assert( status == -1 ); rtems_test_assert( status == -1 );
} }
@@ -329,7 +328,7 @@ void make_too_many_links(void)
char name [20]; char name [20];
status = mkdir("/dummy", S_IRWXU ); status = mkdir("/dummy", S_IRWXU );
assert( status == 0 ); rtems_test_assert( status == 0 );
for (i=1; i<= LINK_MAX; i++) { for (i=1; i<= LINK_MAX; i++) {
@@ -337,9 +336,9 @@ void make_too_many_links(void)
printf( "Making file %s\n", name ); printf( "Making file %s\n", name );
status = link("/dummy" , name ); status = link("/dummy" , name );
if( i < LINK_MAX ) if( i < LINK_MAX )
assert( !status ); rtems_test_assert( !status );
else else
assert( status == -1 ); rtems_test_assert( status == -1 );
} }
} }
@@ -358,22 +357,22 @@ void make_a_symlink(
printf( "Making file %s\n", new ); printf( "Making file %s\n", new );
status = symlink( existing, new ); status = symlink( existing, new );
assert( !status ); rtems_test_assert( !status );
printf( "Verify with readlink\n"); printf( "Verify with readlink\n");
status = readlink( new, buf, 100 ); status = readlink( new, buf, 100 );
len = strlen( existing ); len = strlen( existing );
assert ( status == len ); rtems_test_assert ( status == len );
status = readlink( new, buf, 3 ); status = readlink( new, buf, 3 );
len = strlen( existing ); len = strlen( existing );
if (len < 3 ) if (len < 3 )
assert( status == len ); rtems_test_assert( status == len );
else else
assert( status == 3 ); rtems_test_assert( status == 3 );
status = strcmp( existing, buf ); status = strcmp( existing, buf );
assert( !status ); rtems_test_assert( !status );
} }
void make_multiple_symlinks(void) void make_multiple_symlinks(void)
@@ -394,7 +393,7 @@ void make_multiple_symlinks(void)
stat_a_file( SymLinks[4] ); stat_a_file( SymLinks[4] );
status = symlink( "//links", "bob/frank" ); status = symlink( "//links", "bob/frank" );
assert (status == -1); rtems_test_assert (status == -1);
} }
/* /*
@@ -407,9 +406,9 @@ void make_too_many_symlinks()
sprintf( name1, "SymLink%d", i ); sprintf( name1, "SymLink%d", i );
status = symlink( "/dummy", name1 ); status = symlink( "/dummy", name1 );
if( i < MAXSYMLINK ) if( i < MAXSYMLINK )
assert( !status ); rtems_test_assert( !status );
else else
assert( status == -1 ); rtems_test_assert( status == -1 );
} }
} }
*/ */
@@ -453,7 +452,7 @@ void make_multiple_directories(
while ( files[i] ) { while ( files[i] ) {
printf( "Making directory %s\n", files[i] ); printf( "Making directory %s\n", files[i] );
status = mkdir( files[i], S_IRWXU ); status = mkdir( files[i], S_IRWXU );
assert( !status ); rtems_test_assert( !status );
i++; i++;
} }
puts( "" ); puts( "" );
@@ -478,8 +477,8 @@ void Cause_faults(void)
#if 0 #if 0
printf("\n\nPass an invalid mode to chmod should fail with EPERM \n" ); printf("\n\nPass an invalid mode to chmod should fail with EPERM \n" );
status = chmod( Files[0], S_IFREG ); status = chmod( Files[0], S_IFREG );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EPERM ); rtems_test_assert( errno == EPERM );
#endif #endif
/* /*
@@ -487,12 +486,12 @@ void Cause_faults(void)
*/ */
status = chmod( Files[0], S_IXUSR ); status = chmod( Files[0], S_IXUSR );
assert( status != -1 ); rtems_test_assert( status != -1 );
printf("chdir to a file should fail with ENOTDIR\n"); printf("chdir to a file should fail with ENOTDIR\n");
status = chdir( Files[0] ); status = chdir( Files[0] );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == ENOTDIR ); rtems_test_assert( errno == ENOTDIR );
/* /*
* Change mode to read/write on a directory. * Change mode to read/write on a directory.
@@ -501,28 +500,28 @@ void Cause_faults(void)
printf("Verify RWX permission on %s via access\n", Directories[0]); printf("Verify RWX permission on %s via access\n", Directories[0]);
status = access( Directories[0], ( R_OK | W_OK | X_OK ) ); status = access( Directories[0], ( R_OK | W_OK | X_OK ) );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf( "chmod of %s to Read/Write\n", Directories[0] ); printf( "chmod of %s to Read/Write\n", Directories[0] );
status = chmod( Directories[0], (S_IXGRP | S_IXOTH) ); status = chmod( Directories[0], (S_IXGRP | S_IXOTH) );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf( "chmod fred should fail with ENOENT\n" ); printf( "chmod fred should fail with ENOENT\n" );
status = chmod( "fred", (S_IXGRP | S_IXOTH) ); status = chmod( "fred", (S_IXGRP | S_IXOTH) );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == ENOENT ); rtems_test_assert( errno == ENOENT );
strcpy(longer_name, Directories[0] ); strcpy(longer_name, Directories[0] );
strcat(longer_name, "/BADNAME" ); strcat(longer_name, "/BADNAME" );
printf( "Create under %s should fail with EACCES\n", Directories[0] ); printf( "Create under %s should fail with EACCES\n", Directories[0] );
status = mkdir( longer_name , S_IRWXU ); status = mkdir( longer_name , S_IRWXU );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EACCES ); rtems_test_assert( errno == EACCES );
printf("chdir to %s should fail with EACCES\n", Directories[4] ); printf("chdir to %s should fail with EACCES\n", Directories[4] );
status = chdir( Directories[4] ); status = chdir( Directories[4] );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EACCES ); rtems_test_assert( errno == EACCES );
/* /*
* Check stat with a NULL buffer. * Check stat with a NULL buffer.
@@ -530,8 +529,8 @@ void Cause_faults(void)
printf("Stat with a NULL buffer should fail with EFAULT\n"); printf("Stat with a NULL buffer should fail with EFAULT\n");
status = stat( Directories[0], NULL ); status = stat( Directories[0], NULL );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EFAULT ); rtems_test_assert( errno == EFAULT );
/* /*
* Set current to a directory with no owner permissions. * Set current to a directory with no owner permissions.
@@ -540,33 +539,33 @@ void Cause_faults(void)
printf( "\n\nchmod of %s to Read/Write\n", Directories[0] ); printf( "\n\nchmod of %s to Read/Write\n", Directories[0] );
status = chmod( Directories[0], (S_IXGRP | S_IXOTH) ); status = chmod( Directories[0], (S_IXGRP | S_IXOTH) );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("mkdir %s should fail with EACCESS\n", longer_name ); printf("mkdir %s should fail with EACCESS\n", longer_name );
status = mkdir( longer_name , S_IRWXU ); status = mkdir( longer_name , S_IRWXU );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EACCES ); rtems_test_assert( errno == EACCES );
printf("\n%s Should exist ( access )\n",Directories[0] ); printf("\n%s Should exist ( access )\n",Directories[0] );
status = access( Directories[0], F_OK ); status = access( Directories[0], F_OK );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("\n%s Should have read permission( access )\n",Directories[0] ); printf("\n%s Should have read permission( access )\n",Directories[0] );
status = access( Directories[0], R_OK ); status = access( Directories[0], R_OK );
assert( status != 0 ); rtems_test_assert( status != 0 );
printf("\n%s Should have write permission( access )\n",Directories[0] ); printf("\n%s Should have write permission( access )\n",Directories[0] );
status = access( Directories[0], W_OK ); status = access( Directories[0], W_OK );
assert( status != 0 ); rtems_test_assert( status != 0 );
printf("\n%s Should not have execute permission( access )\n",Directories[0] ); printf("\n%s Should not have execute permission( access )\n",Directories[0] );
status = access( Directories[0], X_OK ); status = access( Directories[0], X_OK );
assert( status != 0 ); rtems_test_assert( status != 0 );
printf("\nRestore %s to RWX\n",Directories[0] ); printf("\nRestore %s to RWX\n",Directories[0] );
status = chmod( Directories[0], S_IRWXU ); status = chmod( Directories[0], S_IRWXU );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("chdir to /my_mount_point \n"); printf("chdir to /my_mount_point \n");
status = chdir( "/my_mount_point" ); status = chdir( "/my_mount_point" );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* /*
* Remove one of the directories. * Remove one of the directories.
@@ -575,21 +574,21 @@ void Cause_faults(void)
printf( "Remove %s\n", Directories[5] ); printf( "Remove %s\n", Directories[5] );
status = rmdir( Directories[5] ); status = rmdir( Directories[5] );
assert( status == 0 ); rtems_test_assert( status == 0 );
stat_a_file( Directories[5] ); stat_a_file( Directories[5] );
status = access( Directories[5], F_OK ); status = access( Directories[5], F_OK );
assert( status != 0 ); rtems_test_assert( status != 0 );
stat_a_file( Links_to_Dirs[5] ); stat_a_file( Links_to_Dirs[5] );
status = readlink( Links_to_Dirs[5], longer_name, 3 ); status = readlink( Links_to_Dirs[5], longer_name, 3 );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
stat_a_file( Links_to_dirlinks[5] ); stat_a_file( Links_to_dirlinks[5] );
printf("Chdir to %s\n", Links_to_Dirs[5] ); printf("Chdir to %s\n", Links_to_Dirs[5] );
status = chdir( Links_to_Dirs[5] ); status = chdir( Links_to_Dirs[5] );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* /*
* Verify we cannot move up from a node with no parent node. * Verify we cannot move up from a node with no parent node.
@@ -597,8 +596,8 @@ void Cause_faults(void)
printf("Chdir to .. should fail with ENOENT\n" ); printf("Chdir to .. should fail with ENOENT\n" );
status = chdir( ".." ); status = chdir( ".." );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == ENOENT ); rtems_test_assert( errno == ENOENT );
/* /*
* Create a subdirectory under the dangling node. * Create a subdirectory under the dangling node.
@@ -606,16 +605,16 @@ void Cause_faults(void)
printf("mkdir ../t should fail with ENOENT\n" ); printf("mkdir ../t should fail with ENOENT\n" );
status = mkdir( "../t" , S_IRWXU ); status = mkdir( "../t" , S_IRWXU );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == ENOENT ); rtems_test_assert( errno == ENOENT );
printf("mkdir t\n"); printf("mkdir t\n");
status = mkdir( "t" , S_IRWXU ); status = mkdir( "t" , S_IRWXU );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("chdir to /my_mount_point\n"); printf("chdir to /my_mount_point\n");
status = chdir( "/my_mount_point" ); status = chdir( "/my_mount_point" );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* /*
* Check rmdir, rmnod, and unlink * Check rmdir, rmnod, and unlink
@@ -623,31 +622,31 @@ void Cause_faults(void)
printf("rmdir %s should fail with ENOTDIR\n", Links_to_Dirs[5] ); printf("rmdir %s should fail with ENOTDIR\n", Links_to_Dirs[5] );
status = rmdir( Links_to_Dirs[5] ); status = rmdir( Links_to_Dirs[5] );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == ENOTDIR ); rtems_test_assert( errno == ENOTDIR );
printf("unlink %s\n", Links_to_Dirs[5] ); printf("unlink %s\n", Links_to_Dirs[5] );
status = unlink( Links_to_Dirs[5] ); status = unlink( Links_to_Dirs[5] );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("unlink %s should fail with ENOTEMPTY\n", Links_to_dirlinks[5] ); printf("unlink %s should fail with ENOTEMPTY\n", Links_to_dirlinks[5] );
status = unlink( Links_to_dirlinks[5] ); status = unlink( Links_to_dirlinks[5] );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == ENOTEMPTY ); rtems_test_assert( errno == ENOTEMPTY );
strcpy( longer_name, Links_to_dirlinks[5] ); strcpy( longer_name, Links_to_dirlinks[5] );
strcat( longer_name, "/t"); strcat( longer_name, "/t");
printf("rmdir %s\n", longer_name ); printf("rmdir %s\n", longer_name );
status = rmdir( longer_name ); status = rmdir( longer_name );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("unlink %s\n", Links_to_Dirs[5]); printf("unlink %s\n", Links_to_Dirs[5]);
status = unlink( Links_to_dirlinks[5] ); status = unlink( Links_to_dirlinks[5] );
assert( status == 0 ); rtems_test_assert( status == 0 );
status = chdir( Directories[0] ); status = chdir( Directories[0] );
status = mkdir ( "my_mount_point", S_IRWXU ); status = mkdir ( "my_mount_point", S_IRWXU );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("Attempting to mount IMFS file system at /dir1/my_mount_point \n"); printf("Attempting to mount IMFS file system at /dir1/my_mount_point \n");
status = mount( status = mount(
@@ -656,16 +655,16 @@ void Cause_faults(void)
RTEMS_FILESYSTEM_READ_WRITE, RTEMS_FILESYSTEM_READ_WRITE,
NULL, NULL,
"/my_mount_point/dir1/my_mount_point" ); "/my_mount_point/dir1/my_mount_point" );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("rmdir /dir1/my_mount_point should fail with EBUSY\n"); printf("rmdir /dir1/my_mount_point should fail with EBUSY\n");
status = rmdir ("/my_mount_point/dir1/my_mount_point" ); status = rmdir ("/my_mount_point/dir1/my_mount_point" );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EBUSY ); rtems_test_assert( errno == EBUSY );
printf( "Unmount /my_mount_point/dir1/my_mount_point\n"); printf( "Unmount /my_mount_point/dir1/my_mount_point\n");
status = unmount( "/my_mount_point/dir1/my_mount_point" ); status = unmount( "/my_mount_point/dir1/my_mount_point" );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* /*
* Verify write permission is checked. * Verify write permission is checked.
@@ -673,30 +672,30 @@ void Cause_faults(void)
printf("chmod of %s to group and other execute\n", Files[0] ); printf("chmod of %s to group and other execute\n", Files[0] );
status = chmod (Files[0], (S_IXGRP | S_IXOTH) ); status = chmod (Files[0], (S_IXGRP | S_IXOTH) );
assert( status == 0 ); rtems_test_assert( status == 0 );
printf("Open %s for write should fail with EACCES\n", Files[0] ); printf("Open %s for write should fail with EACCES\n", Files[0] );
fd = open (Files[0], O_WRONLY); fd = open (Files[0], O_WRONLY);
assert( fd == -1 ); rtems_test_assert( fd == -1 );
assert( errno == EACCES ); rtems_test_assert( errno == EACCES );
printf("chmod of %s to User Execute and Read\n", Directories[3] ); printf("chmod of %s to User Execute and Read\n", Directories[3] );
status = chmod (Directories[3], (S_IXUSR | S_IRUSR) ); status = chmod (Directories[3], (S_IXUSR | S_IRUSR) );
assert( status == 0 ); rtems_test_assert( status == 0 );
strcpy(longer_name, Directories[3] ); strcpy(longer_name, Directories[3] );
strcat(longer_name, "/NewFile" ); strcat(longer_name, "/NewFile" );
printf("Mkdir of %s should fail with EACCES\n",longer_name ); printf("Mkdir of %s should fail with EACCES\n",longer_name );
status = mkdir( longer_name, S_IRWXU ); status = mkdir( longer_name, S_IRWXU );
assert( status != 0 ); rtems_test_assert( status != 0 );
assert( errno == EACCES ); rtems_test_assert( errno == EACCES );
printf("Making too many hard links.\n" ); printf("Making too many hard links.\n" );
make_too_many_links( ); make_too_many_links( );
printf( "pass fstat a null pointer should fail with EFAULT\n"); printf( "pass fstat a null pointer should fail with EFAULT\n");
status = fstat( fd, NULL ); status = fstat( fd, NULL );
assert( status == -1 ); rtems_test_assert( status == -1 );
assert( errno == EFAULT); rtems_test_assert( errno == EFAULT);
/* /*
* The current directory MUST be restored at the end of this test. * The current directory MUST be restored at the end of this test.
@@ -704,7 +703,7 @@ void Cause_faults(void)
printf("chdir to /my_mount_point \n"); printf("chdir to /my_mount_point \n");
status = chdir( "/my_mount_point" ); status = chdir( "/my_mount_point" );
assert( status == 0 ); rtems_test_assert( status == 0 );
} }
@@ -748,18 +747,18 @@ int main(
*/ */
status = mkdir("/my_mount_point", S_IRWXU ); status = mkdir("/my_mount_point", S_IRWXU );
assert( status == 0 ); rtems_test_assert( status == 0 );
status = mount( status = mount(
&mt_entry, &mt_entry,
&IMFS_ops, &IMFS_ops,
RTEMS_FILESYSTEM_READ_WRITE, RTEMS_FILESYSTEM_READ_WRITE,
NULL, NULL,
"my_mount_point" ); "my_mount_point" );
assert( status == 0 ); rtems_test_assert( status == 0 );
status = chdir( "/my_mount_point" ); status = chdir( "/my_mount_point" );
assert( status == 0 ); rtems_test_assert( status == 0 );
status = mkdir("dev", S_IRWXU ); status = mkdir("dev", S_IRWXU );
assert( status == 0 ); rtems_test_assert( status == 0 );
/* /*

View File

@@ -13,7 +13,6 @@
*/ */
#include <tmacros.h> #include <tmacros.h>
#include <assert.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
@@ -67,16 +66,16 @@ void check_a_tod(
print_time( "rtems_clock_set ", the_tod, "\n" ); print_time( "rtems_clock_set ", the_tod, "\n" );
status = rtems_clock_set( the_tod ); status = rtems_clock_set( the_tod );
assert( !status ); rtems_test_assert( !status );
do { do {
status = rtems_clock_get_tod( &new_tod ); status = rtems_clock_get_tod( &new_tod );
assert( !status ); rtems_test_assert( !status );
print_time( "rtems_clock_get_tod ", &new_tod, "\n" ); print_time( "rtems_clock_get_tod ", &new_tod, "\n" );
/* now do the posix time gets */ /* now do the posix time gets */
result = gettimeofday( &tv, 0 ); result = gettimeofday( &tv, 0 );
assert( result == 0 ); rtems_test_assert( result == 0 );
a_time_t = tv.tv_sec; /* ctime() takes a time_t */ a_time_t = tv.tv_sec; /* ctime() takes a time_t */
printf( "gettimeofday: %s", ctime( &a_time_t) ); printf( "gettimeofday: %s", ctime( &a_time_t) );
@@ -110,7 +109,7 @@ void test_adjtime(void)
print_time( "rtems_clock_set ", the_tod, "\n" ); print_time( "rtems_clock_set ", the_tod, "\n" );
status = rtems_clock_set( the_tod ); status = rtems_clock_set( the_tod );
assert( !status ); rtems_test_assert( !status );
delta.tv_sec = 0; delta.tv_sec = 0;
delta.tv_usec = 0; delta.tv_usec = 0;
@@ -119,56 +118,56 @@ void test_adjtime(void)
puts( "adjtime - NULL delta - EINVAL" ); puts( "adjtime - NULL delta - EINVAL" );
sc = adjtime( NULL, &olddelta ); sc = adjtime( NULL, &olddelta );
assert( sc == -1 ); rtems_test_assert( sc == -1 );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "adjtime - delta out of range - EINVAL" ); puts( "adjtime - delta out of range - EINVAL" );
delta.tv_usec = 1000000000; /* 100 seconds worth */ delta.tv_usec = 1000000000; /* 100 seconds worth */
sc = adjtime( &delta, &olddelta ); sc = adjtime( &delta, &olddelta );
assert( sc == -1 ); rtems_test_assert( sc == -1 );
assert( errno == EINVAL ); rtems_test_assert( errno == EINVAL );
puts( "adjtime - delta too small - do nothing" ); puts( "adjtime - delta too small - do nothing" );
delta.tv_sec = 0; delta.tv_sec = 0;
delta.tv_usec = 1; delta.tv_usec = 1;
sc = adjtime( &delta, &olddelta ); sc = adjtime( &delta, &olddelta );
assert( sc == 0 ); rtems_test_assert( sc == 0 );
puts( "adjtime - delta too small - do nothing, olddelta=NULL" ); puts( "adjtime - delta too small - do nothing, olddelta=NULL" );
sc = adjtime( &delta, NULL ); sc = adjtime( &delta, NULL );
assert( sc == 0 ); rtems_test_assert( sc == 0 );
puts( "adjtime - delta of one second forward" ); puts( "adjtime - delta of one second forward" );
delta.tv_sec = 1; delta.tv_sec = 1;
delta.tv_usec = 0; delta.tv_usec = 0;
sc = adjtime( &delta, &olddelta ); sc = adjtime( &delta, &olddelta );
assert( sc == 0 ); rtems_test_assert( sc == 0 );
puts( "adjtime - delta of almost two seconds forward" ); puts( "adjtime - delta of almost two seconds forward" );
delta.tv_sec = 1; delta.tv_sec = 1;
delta.tv_usec = 1000000 - 1; delta.tv_usec = 1000000 - 1;
sc = adjtime( &delta, &olddelta ); sc = adjtime( &delta, &olddelta );
assert( sc == 0 ); rtems_test_assert( sc == 0 );
/* /*
* spin until over 1/2 of the way to the * spin until over 1/2 of the way to the
*/ */
ticks = rtems_clock_get_ticks_per_second(); ticks = rtems_clock_get_ticks_per_second();
assert( ticks ); rtems_test_assert( ticks );
ticks /= 2; ticks /= 2;
do { do {
status = rtems_clock_get_tod( &tod ); status = rtems_clock_get_tod( &tod );
assert( !status ); rtems_test_assert( !status );
} while ( tod.ticks <= ticks ); } while ( tod.ticks <= ticks );
puts( "adjtime - delta of almost one second forward which bumps second" ); puts( "adjtime - delta of almost one second forward which bumps second" );
delta.tv_sec = 0; delta.tv_sec = 0;
delta.tv_usec = 1000000 - 1; delta.tv_usec = 1000000 - 1;
sc = adjtime( &delta, &olddelta ); sc = adjtime( &delta, &olddelta );
assert( sc == 0 ); rtems_test_assert( sc == 0 );
status = rtems_clock_get_tod( &tod ); status = rtems_clock_get_tod( &tod );
assert( !status ); rtems_test_assert( !status );
print_time( "rtems_clock_get_tod ", &tod, "\n" ); print_time( "rtems_clock_get_tod ", &tod, "\n" );
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -79,12 +79,12 @@ void *POSIX_Init(
/* unblock Signal and see if it happened */ /* unblock Signal and see if it happened */
status = sigemptyset( &mask ); status = sigemptyset( &mask );
assert( !status ); rtems_test_assert( !status );
status = sigaddset( &mask, SIGALRM ); status = sigaddset( &mask, SIGALRM );
assert( !status ); rtems_test_assert( !status );
puts( "Init: Unblock SIGALRM" ); puts( "Init: Unblock SIGALRM" );
status = sigprocmask( SIG_UNBLOCK, &mask, NULL ); status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
assert( !status ); rtems_test_assert( !status );
status = sleep(10); status = sleep(10);
/* stop ularm */ /* stop ularm */