source: rtems/c/src/tests/psxtests/psx12/init.c @ d802489

4.104.114.84.95
Last change on this file since d802489 was d802489, checked in by Joel Sherrill <joel.sherrill@…>, on 08/02/02 at 00:53:21

2002-08-01 Joel Sherrill <joel@…>

  • Per PR47 add support for buffered test output. This involved adding defines to redirect output to a buffer and dump it when full, at "test pause", and at exit. To avoid problems when redefining exit(), all tests were modified to call rtems_test_exit(). Some tests, notable psxtests, had to be modified to include the standard test macro .h file (pmacros.h or tmacros.h) to enable this support.
  • include/pmacros.h, psx01/task.c, psx02/init.c, psx02/task.c, psx03/init.c, psx04/init.c, psx05/init.c, psx06/init.c, psx07/init.c, psx08/task3.c, psx09/init.c, psx10/init.c, psx11/init.c, psx12/init.c, psx13/Makefile.am, psx13/main.c, psx13/test.c, psxcancel/init.c, psxchroot01/Makefile.am, psxchroot01/main.c, psxchroot01/test.c, psxfile01/Makefile.am, psxfile01/main.c, psxfile01/test.c, psxfile01/test_cat.c, psxfile01/test_extend.c, psxfile01/test_write.c, psxmount/Makefile.am, psxmount/main.c, psxmount/test.c, psxmsgq01/init.c, psxreaddir/Makefile.am, psxreaddir/main.c, psxreaddir/test.c, psxsem01/init.c, psxstat/Makefile.am, psxstat/main.c, psxstat/test.c, psxtime/main.c, psxtime/test.c, psxtimer/psxtimer.c: Modified.
  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-1999.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.OARcorp.com/rtems/license.html.
8 *
9 *  $Id$
10 */
11
12#define CONFIGURE_INIT
13#include "system.h"
14#include <errno.h>
15
16void print_schedparam(
17  char               *prefix,
18  struct sched_param *schedparam
19)
20{
21  printf( "%ssched priority      = %d\n", prefix, schedparam->sched_priority );
22#if defined(_POSIX_SPORADIC_SERVER)
23  printf( "%sss_low_priority     = %d\n", prefix, schedparam->ss_low_priority );
24  printf( "%sss_replenish_period = (%ld, %ld)\n", prefix,
25     schedparam->ss_replenish_period.tv_sec,
26     schedparam->ss_replenish_period.tv_nsec );
27  printf( "%sss_initial_budget = (%ld, %ld)\n", prefix,
28     schedparam->ss_initial_budget.tv_sec,
29     schedparam->ss_initial_budget.tv_nsec );
30#else
31  printf( "%s_POSIX_SPORADIC_SERVER is not defined\n" );
32#endif
33}
34
35void *POSIX_Init(
36  void *argument
37)
38{
39  int                 status;
40  pthread_attr_t      attr;
41  struct sched_param  schedparam;
42
43  puts( "\n\n*** POSIX TEST 12 ***" );
44
45  /* set the time of day, and print our buffer in multiple ways */
46
47  set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
48
49  /* get id of this thread */
50
51  Init_id = pthread_self();
52  printf( "Init's ID is 0x%08x\n", Init_id );
53 
54  /* invalid scheduling policy error */
55
56  puts( "Init: pthread_attr_init - SUCCESSFUL" );
57  status = pthread_attr_init( &attr );
58  assert( !status );
59
60  status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
61  assert( !status );
62  attr.schedpolicy = -1;
63
64  puts( "Init: pthread_create - EINVAL (invalid scheduling policy)" );
65  status = pthread_create( &Task_id, &attr, Task_1, NULL );
66  assert( status == EINVAL );
67
68  /* replenish period < budget error */
69
70  puts( "Init: pthread_attr_init - SUCCESSFUL" );
71  status = pthread_attr_init( &attr );
72  assert( !status );
73
74  puts( "Init: set scheduling parameter attributes for sporadic server" );
75  status = pthread_attr_setschedpolicy( &attr, SCHED_SPORADIC );
76  assert( !status );
77
78  schedparam.ss_replenish_period.tv_sec = 1;
79  schedparam.ss_replenish_period.tv_nsec = 0;
80  schedparam.ss_initial_budget.tv_sec = 2;
81  schedparam.ss_initial_budget.tv_nsec = 0;
82 
83  schedparam.sched_priority = 200;
84  schedparam.ss_low_priority = 100;
85
86  status = pthread_attr_setschedparam( &attr, &schedparam );
87  assert( !status );
88
89  status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
90  assert( !status );
91 
92  puts( "Init: pthread_create - EINVAL (replenish < budget)" );
93  status = pthread_create( &Task_id, &attr, Task_1, NULL );
94  assert( status == EINVAL );
95
96  /* invalid ss_low_priority error */
97
98  schedparam.ss_replenish_period.tv_sec = 2;
99  schedparam.ss_replenish_period.tv_nsec = 0;
100  schedparam.ss_initial_budget.tv_sec = 1;
101  schedparam.ss_initial_budget.tv_nsec = 0;
102 
103  schedparam.sched_priority = 200;
104  schedparam.ss_low_priority = -1;
105
106  status = pthread_attr_setschedparam( &attr, &schedparam );
107  assert( !status );
108
109  puts( "Init: pthread_create - EINVAL (invalid ss_low_priority)" );
110  status = pthread_create( &Task_id, &attr, Task_1, NULL );
111  assert( status == EINVAL );
112
113  /* create a thread as a sporadic server */
114
115  schedparam.ss_replenish_period.tv_sec = 2;
116  schedparam.ss_replenish_period.tv_nsec = 0;
117  schedparam.ss_initial_budget.tv_sec = 1;
118  schedparam.ss_initial_budget.tv_nsec = 0;
119 
120  schedparam.sched_priority = 200;
121  schedparam.ss_low_priority = 100;
122 
123  status = pthread_attr_setschedparam( &attr, &schedparam );
124  assert( !status );
125 
126  puts( "Init: pthread_create - SUCCESSFUL" );
127  status = pthread_create( &Task_id, &attr, Task_1, NULL );
128  assert( !status );
129
130  status = pthread_join( Task_id, NULL );
131  assert( status );
132
133    /* switch to Task_1 */
134
135  puts( "*** END OF POSIX TEST 12 ***" );
136  rtems_test_exit( 0 );
137
138  return NULL; /* just so the compiler thinks we returned something */
139}
Note: See TracBrowser for help on using the repository browser.