source: rtems/testsuites/psxtests/psx01/task.c @ 749eae97

4.104.115
Last change on this file since 749eae97 was 2e7e636f, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/09 at 01:41:16

2009-05-10 Joel Sherrill <joel.sherrill@…>

  • psx01/init.c, psx01/task.c, psx02/init.c, psx02/task.c, psx03/init.c, psx04/init.c, psx04/task1.c, psx04/task3.c, psx05/init.c, psx06/init.c, psx07/init.c, psx08/init.c, psx09/init.c, psx11/task.c, psx12/init.c, psx13/main.c, psx13/test.c, psxbarrier01/test.c, psxcancel/init.c, psxcleanup/psxcleanup.c, psxenosys/init.c, psxmsgq02/init.c, psxtime/main.c, psxtime/test.c, psxtimer01/psxtimer.c, psxtimer02/psxtimer.c: Fix warnings.
  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*  Task_1_through_3
2 *
3 *  This routine serves as a test task.  It verifies the basic task
4 *  switching capabilities of the executive.
5 *
6 *  Input parameters:
7 *    argument - task argument
8 *
9 *  Output parameters:  NONE
10 *
11 *  COPYRIGHT (c) 1989-2009.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20
21#include "system.h"
22
23void Test_init_routine( void );
24
25void Test_init_routine( void )
26{
27  puts( "Test_init_routine: invoked" );
28}
29
30
31void *Task_1_through_3(
32  void *argument
33)
34{
35  int            status;
36  pthread_once_t once = PTHREAD_ONCE_INIT;
37
38  puts( "Task_1: sched_yield to Init" );
39  status = sched_yield();
40  assert( !status );
41
42    /* switch to Task_1 */
43
44  /* now do some real testing */
45
46  empty_line();
47
48  /* get id of this thread */
49
50  Task_id = pthread_self();
51  printf( "Task_1: ID is 0x%08x\n", Task_id );
52
53  /* exercise pthread_equal */
54
55  status = pthread_equal( Task_id, Task_id );
56  if ( status )
57    puts( "Task_1: pthread_equal - match case passed" );
58  assert( status );
59
60  status = pthread_equal( Init_id, Task_id );
61  if ( !status )
62    puts( "Task_1: pthread_equal - different case passed" );
63  assert( !status );
64
65  puts( "Task_1: pthread_equal - first id bad" );
66  status = pthread_equal( (pthread_t) -1, Task_id );
67  assert( !status );
68
69  puts( "Task_1: pthread_equal - second id bad" );
70  status = pthread_equal( Init_id, (pthread_t) -1 );
71  assert( !status );
72
73  /* exercise pthread_once */
74
75  puts( "Task_1: pthread_once - EINVAL (NULL once_control)" );
76  status = pthread_once( NULL, Test_init_routine );
77  assert( status == EINVAL );
78
79  puts( "Task_1: pthread_once - EINVAL (NULL init_routine)" );
80  status = pthread_once( &once, NULL );
81  assert( status == EINVAL );
82
83  puts( "Task_1: pthread_once - SUCCESSFUL (init_routine executes)" );
84  status = pthread_once( &once, Test_init_routine );
85  assert( !status );
86
87  puts( "Task_1: pthread_once - SUCCESSFUL (init_routine does not execute)" );
88  status = pthread_once( &once, Test_init_routine );
89  assert( !status );
90
91  puts( "*** END OF POSIX TEST 1 ***" );
92  rtems_test_exit( 0 );
93
94  return NULL; /* just so the compiler thinks we returned something */
95}
Note: See TracBrowser for help on using the repository browser.