source: rtems/testsuites/psxtests/psx01/task.c @ 39615f4

4.104.11
Last change on this file since 39615f4 was 39615f4, checked in by Ralf Corsepius <ralf.corsepius@…>, on Oct 27, 2009 at 2:10:54 PM

Use PRIxpthread_t to print pthread_t's.

  • 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%08" PRIxpthread_t "\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.