source: rtems/testsuites/psxtests/psx12/init.c @ d6467102

5
Last change on this file since d6467102 was d6467102, checked in by Sebastian Huber <sebastian.huber@…>, on 06/15/16 at 07:04:29

psxtests/psx12: Use one file and simplify

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
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.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <sched.h>
15#include <errno.h>
16
17#include <pmacros.h>
18
19const char rtems_test_name[] = "PSX 12";
20
21static void *sporadic_server( void *argument )
22{
23  puts( "Sporadic Server: exitting" );
24
25  return NULL;
26}
27
28static void *POSIX_Init( void *argument )
29{
30  int                 status;
31  pthread_attr_t      attr;
32  pthread_t           thread;
33  struct sched_param  schedparam;
34
35  TEST_BEGIN();
36
37  /* set the time of day, and print our buffer in multiple ways */
38
39  set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
40
41  /* get id of this thread */
42
43  printf( "Init's ID is 0x%08" PRIxpthread_t "\n", pthread_self() );
44
45  /* invalid scheduling policy error */
46
47  puts( "Init: pthread_attr_init - SUCCESSFUL" );
48  status = pthread_attr_init( &attr );
49  rtems_test_assert( !status );
50
51  status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
52  rtems_test_assert( !status );
53  attr.schedpolicy = -1;
54
55  puts( "Init: pthread_create - EINVAL (invalid scheduling policy)" );
56  status = pthread_create( &thread, &attr, sporadic_server, NULL );
57  rtems_test_assert( status == EINVAL );
58
59  /* replenish period < budget error */
60
61  puts( "Init: pthread_attr_init - SUCCESSFUL" );
62  status = pthread_attr_init( &attr );
63  rtems_test_assert( !status );
64
65  puts( "Init: set scheduling parameter attributes for sporadic server" );
66  status = pthread_attr_setschedpolicy( &attr, SCHED_SPORADIC );
67  rtems_test_assert( !status );
68
69  schedparam.sched_ss_repl_period.tv_sec = 1;
70  schedparam.sched_ss_repl_period.tv_nsec = 0;
71  schedparam.sched_ss_init_budget.tv_sec = 2;
72  schedparam.sched_ss_init_budget.tv_nsec = 0;
73
74  schedparam.sched_priority = 200;
75  schedparam.sched_ss_low_priority = 100;
76
77  status = pthread_attr_setschedparam( &attr, &schedparam );
78  rtems_test_assert( !status );
79
80  status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
81  rtems_test_assert( !status );
82
83  puts( "Init: pthread_create - EINVAL (replenish < budget)" );
84  status = pthread_create( &thread, &attr, sporadic_server, NULL );
85  rtems_test_assert( status == EINVAL );
86
87  /* invalid sched_ss_low_priority error */
88
89  schedparam.sched_ss_repl_period.tv_sec = 2;
90  schedparam.sched_ss_repl_period.tv_nsec = 0;
91  schedparam.sched_ss_init_budget.tv_sec = 1;
92  schedparam.sched_ss_init_budget.tv_nsec = 0;
93
94  schedparam.sched_priority = 200;
95  schedparam.sched_ss_low_priority = -1;
96
97  status = pthread_attr_setschedparam( &attr, &schedparam );
98  rtems_test_assert( !status );
99
100  puts( "Init: pthread_create - EINVAL (invalid sched_ss_low_priority)" );
101  status = pthread_create( &thread, &attr, sporadic_server, NULL );
102  rtems_test_assert( status == EINVAL );
103
104  /* create a thread as a sporadic server */
105
106  schedparam.sched_ss_repl_period.tv_sec = 2;
107  schedparam.sched_ss_repl_period.tv_nsec = 0;
108  schedparam.sched_ss_init_budget.tv_sec = 1;
109  schedparam.sched_ss_init_budget.tv_nsec = 0;
110
111  schedparam.sched_priority = sched_get_priority_max( SCHED_FIFO );
112  schedparam.sched_ss_low_priority = sched_get_priority_max( SCHED_FIFO ) - 6;
113
114  status = pthread_attr_setschedparam( &attr, &schedparam );
115  rtems_test_assert( !status );
116
117  puts( "Init: pthread_create - SUCCESSFUL" );
118  status = pthread_create( &thread, &attr, sporadic_server, NULL );
119  rtems_test_assert( !status );
120
121  status = pthread_join( thread, NULL );
122  rtems_test_assert( !status );
123
124    /* switch to Task_1 */
125
126  TEST_END();
127  rtems_test_exit( 0 );
128
129  return NULL; /* just so the compiler thinks we returned something */
130}
131
132#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
133#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
134
135#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
136
137#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
138
139#define CONFIGURE_POSIX_INIT_THREAD_TABLE
140
141#define CONFIGURE_INIT
142
143#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.