forked from Imagelibrary/rtems
added cases to increase coverage of pthread_create. cases added tested
error paths as well as inherit scheduling attributes.
This commit is contained in:
@@ -84,10 +84,69 @@ void *POSIX_Init(
|
||||
status = pthread_attr_destroy( &destroyed_attr );
|
||||
assert( status == EINVAL );
|
||||
|
||||
/* check some errors in pthread_create */
|
||||
|
||||
puts( "Init: pthread_create - EINVAL (attr not initialized)" );
|
||||
status = pthread_create( &Task_id, &destroyed_attr, Task_1, NULL );
|
||||
assert( status == EINVAL );
|
||||
|
||||
/* junk stack address */
|
||||
status = pthread_attr_setstackaddr( &attr, (void *)&schedparam );
|
||||
assert( !status );
|
||||
|
||||
/* must go around pthread_attr_setstacksize to set a bad stack size */
|
||||
attr.stacksize = 0;
|
||||
|
||||
puts( "Init: pthread_create - EINVAL (stacksize too small)" );
|
||||
status = pthread_create( &Task_id, &attr, Task_1, NULL );
|
||||
assert( status == EINVAL );
|
||||
|
||||
status = pthread_attr_init( &attr );
|
||||
assert( !status );
|
||||
|
||||
/* must go around pthread_attr_set routines to set a bad value */
|
||||
attr.inheritsched = -1;
|
||||
|
||||
puts( "Init: pthread_create - EINVAL (invalid inherit scheduler)" );
|
||||
status = pthread_create( &Task_id, &attr, Task_1, NULL );
|
||||
assert( status == EINVAL );
|
||||
|
||||
/* check out the error case for system scope not supported */
|
||||
|
||||
status = pthread_attr_init( &attr );
|
||||
assert( !status );
|
||||
|
||||
/* must go around pthread_attr_set routines to set a bad value */
|
||||
attr.contentionscope = PTHREAD_SCOPE_SYSTEM;
|
||||
|
||||
puts( "Init: pthread_create - ENOSYS (unsupported system contention scope)" );
|
||||
status = pthread_create( &Task_id, &attr, Task_1, NULL );
|
||||
assert( status == ENOSYS );
|
||||
|
||||
status = pthread_attr_init( &attr );
|
||||
assert( !status );
|
||||
|
||||
/* now check out pthread_create for inherit scheduler */
|
||||
|
||||
status = pthread_attr_setinheritsched( &attr, PTHREAD_INHERIT_SCHED );
|
||||
assert( !status );
|
||||
|
||||
puts( "Init: pthread_create - SUCCESSFUL (inherit scheduler)" );
|
||||
status = pthread_create( &Task_id, &attr, Task_1, NULL );
|
||||
assert( !status );
|
||||
|
||||
status = pthread_join( Task_id, NULL );
|
||||
assert( !status );
|
||||
|
||||
/* switch to Task_1 */
|
||||
|
||||
/* exercise get and set scope */
|
||||
|
||||
empty_line();
|
||||
|
||||
status = pthread_attr_init( &attr );
|
||||
assert( !status );
|
||||
|
||||
puts( "Init: pthread_attr_setscope - EINVAL (NULL attr)" );
|
||||
status = pthread_attr_setscope( NULL, PTHREAD_SCOPE_PROCESS );
|
||||
assert( status == EINVAL );
|
||||
|
||||
@@ -22,6 +22,10 @@ void *POSIX_Init(
|
||||
void *argument
|
||||
);
|
||||
|
||||
void *Task_1(
|
||||
void *argument
|
||||
);
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_SPTEST
|
||||
@@ -42,5 +46,6 @@ void *POSIX_Init(
|
||||
#endif
|
||||
|
||||
TEST_EXTERN pthread_t Init_id;
|
||||
TEST_EXTERN pthread_t Task_id;
|
||||
|
||||
/* end of include file */
|
||||
|
||||
34
c/src/tests/psxtests/psx07/task.c
Normal file
34
c/src/tests/psxtests/psx07/task.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/* Task_1
|
||||
*
|
||||
* This routine serves as a test task. It verifies the basic task
|
||||
* switching capabilities of the executive.
|
||||
*
|
||||
* Input parameters:
|
||||
* argument - task argument
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
* All rights assigned to U.S. Government, 1994.
|
||||
*
|
||||
* This material may be reproduced by or for the U.S. Government pursuant
|
||||
* to the copyright license under the clause at DFARS 252.227-7013. This
|
||||
* notice must appear in all copies of this file and its derivatives.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
#include <time.h>
|
||||
#include <sched.h>
|
||||
|
||||
void *Task_1(
|
||||
void *argument
|
||||
)
|
||||
{
|
||||
puts( "Task_1: exitting" );
|
||||
pthread_exit( NULL );
|
||||
|
||||
return NULL; /* just so the compiler thinks we returned something */
|
||||
}
|
||||
@@ -84,10 +84,69 @@ void *POSIX_Init(
|
||||
status = pthread_attr_destroy( &destroyed_attr );
|
||||
assert( status == EINVAL );
|
||||
|
||||
/* check some errors in pthread_create */
|
||||
|
||||
puts( "Init: pthread_create - EINVAL (attr not initialized)" );
|
||||
status = pthread_create( &Task_id, &destroyed_attr, Task_1, NULL );
|
||||
assert( status == EINVAL );
|
||||
|
||||
/* junk stack address */
|
||||
status = pthread_attr_setstackaddr( &attr, (void *)&schedparam );
|
||||
assert( !status );
|
||||
|
||||
/* must go around pthread_attr_setstacksize to set a bad stack size */
|
||||
attr.stacksize = 0;
|
||||
|
||||
puts( "Init: pthread_create - EINVAL (stacksize too small)" );
|
||||
status = pthread_create( &Task_id, &attr, Task_1, NULL );
|
||||
assert( status == EINVAL );
|
||||
|
||||
status = pthread_attr_init( &attr );
|
||||
assert( !status );
|
||||
|
||||
/* must go around pthread_attr_set routines to set a bad value */
|
||||
attr.inheritsched = -1;
|
||||
|
||||
puts( "Init: pthread_create - EINVAL (invalid inherit scheduler)" );
|
||||
status = pthread_create( &Task_id, &attr, Task_1, NULL );
|
||||
assert( status == EINVAL );
|
||||
|
||||
/* check out the error case for system scope not supported */
|
||||
|
||||
status = pthread_attr_init( &attr );
|
||||
assert( !status );
|
||||
|
||||
/* must go around pthread_attr_set routines to set a bad value */
|
||||
attr.contentionscope = PTHREAD_SCOPE_SYSTEM;
|
||||
|
||||
puts( "Init: pthread_create - ENOSYS (unsupported system contention scope)" );
|
||||
status = pthread_create( &Task_id, &attr, Task_1, NULL );
|
||||
assert( status == ENOSYS );
|
||||
|
||||
status = pthread_attr_init( &attr );
|
||||
assert( !status );
|
||||
|
||||
/* now check out pthread_create for inherit scheduler */
|
||||
|
||||
status = pthread_attr_setinheritsched( &attr, PTHREAD_INHERIT_SCHED );
|
||||
assert( !status );
|
||||
|
||||
puts( "Init: pthread_create - SUCCESSFUL (inherit scheduler)" );
|
||||
status = pthread_create( &Task_id, &attr, Task_1, NULL );
|
||||
assert( !status );
|
||||
|
||||
status = pthread_join( Task_id, NULL );
|
||||
assert( !status );
|
||||
|
||||
/* switch to Task_1 */
|
||||
|
||||
/* exercise get and set scope */
|
||||
|
||||
empty_line();
|
||||
|
||||
status = pthread_attr_init( &attr );
|
||||
assert( !status );
|
||||
|
||||
puts( "Init: pthread_attr_setscope - EINVAL (NULL attr)" );
|
||||
status = pthread_attr_setscope( NULL, PTHREAD_SCOPE_PROCESS );
|
||||
assert( status == EINVAL );
|
||||
|
||||
@@ -22,6 +22,10 @@ void *POSIX_Init(
|
||||
void *argument
|
||||
);
|
||||
|
||||
void *Task_1(
|
||||
void *argument
|
||||
);
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_SPTEST
|
||||
@@ -42,5 +46,6 @@ void *POSIX_Init(
|
||||
#endif
|
||||
|
||||
TEST_EXTERN pthread_t Init_id;
|
||||
TEST_EXTERN pthread_t Task_id;
|
||||
|
||||
/* end of include file */
|
||||
|
||||
34
testsuites/psxtests/psx07/task.c
Normal file
34
testsuites/psxtests/psx07/task.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/* Task_1
|
||||
*
|
||||
* This routine serves as a test task. It verifies the basic task
|
||||
* switching capabilities of the executive.
|
||||
*
|
||||
* Input parameters:
|
||||
* argument - task argument
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
* All rights assigned to U.S. Government, 1994.
|
||||
*
|
||||
* This material may be reproduced by or for the U.S. Government pursuant
|
||||
* to the copyright license under the clause at DFARS 252.227-7013. This
|
||||
* notice must appear in all copies of this file and its derivatives.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
#include <time.h>
|
||||
#include <sched.h>
|
||||
|
||||
void *Task_1(
|
||||
void *argument
|
||||
)
|
||||
{
|
||||
puts( "Task_1: exitting" );
|
||||
pthread_exit( NULL );
|
||||
|
||||
return NULL; /* just so the compiler thinks we returned something */
|
||||
}
|
||||
Reference in New Issue
Block a user