summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
Diffstat (limited to 'c')
-rw-r--r--c/src/tests/psxtests/psx08/Makefile.in2
-rw-r--r--c/src/tests/psxtests/psx08/init.c44
-rw-r--r--c/src/tests/psxtests/psx08/psx08.scn20
-rw-r--r--c/src/tests/psxtests/psx08/system.h7
-rw-r--r--c/src/tests/psxtests/psx08/task1.c34
-rw-r--r--c/src/tests/psxtests/psx08/task2.c40
-rw-r--r--c/src/tests/psxtests/psx08/task3.c (renamed from c/src/tests/psxtests/psx08/task.c)44
7 files changed, 125 insertions, 66 deletions
diff --git a/c/src/tests/psxtests/psx08/Makefile.in b/c/src/tests/psxtests/psx08/Makefile.in
index 1b24852a5a..931cea2637 100644
--- a/c/src/tests/psxtests/psx08/Makefile.in
+++ b/c/src/tests/psxtests/psx08/Makefile.in
@@ -18,7 +18,7 @@ TEST = psx08
MANAGERS = all
# C source names, if any, go here -- minus the .c
-C_PIECES = init task task2
+C_PIECES=init task1 task2 task3
C_FILES = $(C_PIECES:%=%.c)
C_O_FILES = $(C_PIECES:%=${ARCH}/%.o)
diff --git a/c/src/tests/psxtests/psx08/init.c b/c/src/tests/psxtests/psx08/init.c
index f1ec5a6b09..638a595bcb 100644
--- a/c/src/tests/psxtests/psx08/init.c
+++ b/c/src/tests/psxtests/psx08/init.c
@@ -44,11 +44,7 @@ void *POSIX_Init(
/* create thread */
- puts( "Init: creating two tasks" );
- status = pthread_create( &Task_id, NULL, Task_1, NULL );
- assert( !status );
-
- status = pthread_create( &Task2_id, NULL, Task_2, NULL );
+ status = pthread_create( &Task1_id, NULL, Task_1, NULL );
assert( !status );
puts( "Init: pthread_join - ESRCH (invalid id)" );
@@ -56,27 +52,47 @@ void *POSIX_Init(
assert( status == ESRCH );
puts( "Init: pthread_join - SUCCESSFUL" );
- status = pthread_join( Task_id, &return_pointer );
- /* assert is below comment */
+ status = pthread_join( Task1_id, &return_pointer );
- /* switch to Task 1 */
+ puts( "Init: returned from pthread_join through return" );
+ if ( status )
+ printf( "status = %d\n", status );
+ assert( !status );
- puts( "Init: returned from pthread_join" );
+ if ( return_pointer == &Task1_id )
+ puts( "Init: pthread_join returned correct pointer" );
+ else
+ printf(
+ "Init: pthread_join returned incorrect pointer (%p != %p)\n",
+ return_pointer,
+ &Task1_id
+ );
+
+ puts( "Init: creating two pthreads" );
+ status = pthread_create( &Task2_id, NULL, Task_2, NULL );
+ assert( !status );
+
+ status = pthread_create( &Task3_id, NULL, Task_3, NULL );
+ assert( !status );
+
+ puts( "Init: pthread_join - SUCCESSFUL" );
+ status = pthread_join( Task2_id, &return_pointer );
+ /* assert is below comment */
+
+ puts( "Init: returned from pthread_join through pthread_exit" );
if ( status )
printf( "status = %d\n", status );
assert( !status );
- if ( return_pointer == &Task_id )
+ if ( return_pointer == &Task2_id )
puts( "Init: pthread_join returned correct pointer" );
else
printf(
"Init: pthread_join returned incorrect pointer (%p != %p)\n",
return_pointer,
- &Task_id
+ &Task2_id
);
puts( "Init: exitting" );
- pthread_exit( NULL );
-
- return NULL; /* just so the compiler thinks we returned something */
+ return NULL;
}
diff --git a/c/src/tests/psxtests/psx08/psx08.scn b/c/src/tests/psxtests/psx08/psx08.scn
index 34c1934f59..8629b610f2 100644
--- a/c/src/tests/psxtests/psx08/psx08.scn
+++ b/c/src/tests/psxtests/psx08/psx08.scn
@@ -2,17 +2,21 @@
Init's ID is 0x0c010001
Init: pthread_detach - ESRCH (invalid id)
Init: pthread_detach self
-Init: creating two tasks
Init: pthread_join - ESRCH (invalid id)
Init: pthread_join - SUCCESSFUL
-Task_1: sleep 1 second
-Task_2: join to Task_1
-Task_1: join to detached task (Init) -- EINVAL
-Task_1: join to self task (Init) -- EDEADLK
Task_1: exitting
-Init: returned from pthread_join
+Init: returned from pthread_join through return
+Init: pthread_join returned correct pointer
+Init: creating two pthreads
+Init: pthread_join - SUCCESSFUL
+Task_2: sleep 1 second
+Task_3: join to Task_2
+Task_2: join to detached task (Init) -- EINVAL
+Task_2: join to self task (Init) -- EDEADLK
+Task_2: exitting
+Init: returned from pthread_join through pthread_exit
Init: pthread_join returned correct pointer
Init: exitting
-Task_2: returned from pthread_join
-Task_2: pthread_join returned correct pointer
+Task_3: returned from pthread_join
+Task_3: pthread_join returned correct pointer
*** END OF POSIX TEST 8 ***
diff --git a/c/src/tests/psxtests/psx08/system.h b/c/src/tests/psxtests/psx08/system.h
index 18c0c49f35..46819ad59b 100644
--- a/c/src/tests/psxtests/psx08/system.h
+++ b/c/src/tests/psxtests/psx08/system.h
@@ -30,6 +30,10 @@ void *Task_2(
void *argument
);
+void *Task_3(
+ void *argument
+);
+
/* configuration information */
#define CONFIGURE_SPTEST
@@ -50,7 +54,8 @@ void *Task_2(
#endif
TEST_EXTERN pthread_t Init_id;
-TEST_EXTERN pthread_t Task_id;
+TEST_EXTERN pthread_t Task1_id;
TEST_EXTERN pthread_t Task2_id;
+TEST_EXTERN pthread_t Task3_id;
/* end of include file */
diff --git a/c/src/tests/psxtests/psx08/task1.c b/c/src/tests/psxtests/psx08/task1.c
new file mode 100644
index 0000000000..19e922f63c
--- /dev/null
+++ b/c/src/tests/psxtests/psx08/task1.c
@@ -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-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include "system.h"
+#include <errno.h>
+
+void *Task_1(
+ void *argument
+)
+{
+ int status;
+
+ puts( "Task_1: exitting" );
+
+ return( &Task1_id );
+}
diff --git a/c/src/tests/psxtests/psx08/task2.c b/c/src/tests/psxtests/psx08/task2.c
index 028df4cb91..e890535a65 100644
--- a/c/src/tests/psxtests/psx08/task2.c
+++ b/c/src/tests/psxtests/psx08/task2.c
@@ -27,26 +27,30 @@ void *Task_2(
)
{
int status;
- void *return_pointer;
- puts( "Task_2: join to Task_1" );
- status = pthread_join( Task_id, &return_pointer );
- puts( "Task_2: returned from pthread_join" );
- if ( status )
+ puts( "Task_2: sleep 1 second" );
+
+ sleep( 1 );
+
+ /* switch to task 3 */
+
+ puts( "Task_2: join to detached task (Init) -- EINVAL" );
+ status = pthread_join( Init_id, NULL );
+ if ( status != EINVAL )
+ printf( "status = %d\n", status );
+ assert( status == EINVAL );
+
+ puts( "Task_2: join to self task (Init) -- EDEADLK" );
+ status = pthread_join( pthread_self(), NULL );
+ if ( status != EDEADLK )
printf( "status = %d\n", status );
- assert( !status );
-
- if ( return_pointer == &Task_id )
- puts( "Task_2: pthread_join returned correct pointer" );
- else
- printf(
- "Task_2: pthread_join returned incorrect pointer (%p != %p)\n",
- return_pointer,
- &Task_id
- );
-
- puts( "*** END OF POSIX TEST 8 ***" );
- exit( 0 );
+ assert( status == EDEADLK );
+
+ puts( "Task_2: exitting" );
+
+ pthread_exit( &Task2_id );
+
+ /* switch to init task */
return NULL; /* just so the compiler thinks we returned something */
}
diff --git a/c/src/tests/psxtests/psx08/task.c b/c/src/tests/psxtests/psx08/task3.c
index 555b0efeb5..ac8385747a 100644
--- a/c/src/tests/psxtests/psx08/task.c
+++ b/c/src/tests/psxtests/psx08/task3.c
@@ -1,4 +1,4 @@
-/* Task_1
+/* Task_3
*
* This routine serves as a test task. It verifies the basic task
* switching capabilities of the executive.
@@ -22,35 +22,31 @@
#include "system.h"
#include <errno.h>
-void *Task_1(
+void *Task_3(
void *argument
)
{
int status;
+ void *return_pointer;
- puts( "Task_1: sleep 1 second" );
-
- sleep( 1 );
-
- /* switch to task 2 */
-
- puts( "Task_1: join to detached task (Init) -- EINVAL" );
- status = pthread_join( Init_id, NULL );
- if ( status != EINVAL )
- printf( "status = %d\n", status );
- assert( status == EINVAL );
-
- puts( "Task_1: join to self task (Init) -- EDEADLK" );
- status = pthread_join( pthread_self(), NULL );
- if ( status != EDEADLK )
+ puts( "Task_3: join to Task_2" );
+ status = pthread_join( Task2_id, &return_pointer );
+ puts( "Task_3: returned from pthread_join" );
+ if ( status )
printf( "status = %d\n", status );
- assert( status == EDEADLK );
-
- puts( "Task_1: exitting" );
-
- pthread_exit( &Task_id );
-
- /* switch to init task */
+ assert( !status );
+
+ if ( return_pointer == &Task2_id )
+ puts( "Task_3: pthread_join returned correct pointer" );
+ else
+ printf(
+ "Task_3: pthread_join returned incorrect pointer (%p != %p)\n",
+ return_pointer,
+ &Task2_id
+ );
+
+ puts( "*** END OF POSIX TEST 8 ***" );
+ exit( 0 );
return NULL; /* just so the compiler thinks we returned something */
}