source: rtems/testsuites/psxtests/psx01/init.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 3.3 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.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <sched.h>
15#include <sys/utsname.h>
16
17#define CONFIGURE_INIT
18#include "system.h"
19#include "pritime.h"
20
21void *POSIX_Init(
22  void *argument
23)
24{
25  struct timespec tr;
26  int             status;
27  int             priority;
28  pthread_t       thread_id;
29  struct utsname  uts;
30
31  puts( "\n\n*** POSIX TEST 1 ***" );
32
33  /* print some system information */
34
35  puts( "Init: uname - EFAULT (invalid uts pointer argument)" );
36  status = uname( NULL );
37  rtems_test_assert( status == -1 );
38  rtems_test_assert( errno == EFAULT );
39
40  status = uname( &uts );
41  rtems_test_assert( !status );
42  printf( "Init: uts.sysname: %s\n", uts.sysname );
43  printf( "Init: uts.nodename: %s\n", uts.nodename );
44  printf( "Init: uts.release: %s\n", uts.release );
45  printf( "Init: uts.version: %s\n", uts.version );
46  printf( "Init: uts.machine: %s\n", uts.machine );
47  puts("");
48
49  /* get id of this thread */
50
51  Init_id = pthread_self();
52  printf( "Init: ID is 0x%08" PRIxpthread_t "\n", Init_id );
53
54  /* exercise get minimum priority */
55
56  priority = sched_get_priority_min( SCHED_FIFO );
57  printf( "Init: sched_get_priority_min (SCHED_FIFO) -- %d\n", priority );
58  rtems_test_assert( priority != -1 );
59
60  puts( "Init: sched_get_priority_min -- EINVAL (invalid policy)" );
61  priority = sched_get_priority_min( -1 );
62  rtems_test_assert( priority == -1 );
63  rtems_test_assert( errno == EINVAL );
64
65  /* exercise get maximum priority */
66
67  priority = sched_get_priority_max( SCHED_FIFO );
68  printf( "Init: sched_get_priority_max (SCHED_FIFO) -- %d\n", priority );
69  rtems_test_assert( priority != -1 );
70
71  puts( "Init: sched_get_priority_max -- EINVAL (invalid policy)" );
72  priority = sched_get_priority_max( -1 );
73  rtems_test_assert( priority == -1 );
74  rtems_test_assert( errno == EINVAL );
75
76  puts( "Init: sched_rr_get_interval -- ESRCH (invalid PID)" );
77  status = sched_rr_get_interval( 4, &tr );
78  rtems_test_assert( status == -1 );
79  rtems_test_assert( errno == ESRCH );
80
81  puts( "Init: sched_rr_get_interval -- EINVAL (invalid interval pointer)" );
82  status = sched_rr_get_interval( getpid(), NULL );
83  rtems_test_assert( status == -1 );
84  rtems_test_assert( errno == EINVAL );
85
86  /* print the round robin time quantum */
87
88  status = sched_rr_get_interval( getpid(), &tr );
89  printf(
90    "Init: Round Robin quantum is %" PRIdtime_t " seconds, %ld nanoseconds\n",
91    tr.tv_sec,
92    tr.tv_nsec
93  );
94  rtems_test_assert( !status );
95
96  /* create a thread */
97
98  puts( "Init: pthread_create - SUCCESSFUL" );
99  status = pthread_create( &thread_id, NULL, Task_1_through_3, NULL );
100  rtems_test_assert( !status );
101
102  /* too may threads error */
103
104  puts( "Init: pthread_create - EAGAIN (too many threads)" );
105  status = pthread_create( &thread_id, NULL, Task_1_through_3, NULL );
106  rtems_test_assert( status == EAGAIN );
107
108  puts( "Init: sched_yield to Task_1" );
109  status = sched_yield();
110  rtems_test_assert( !status );
111
112    /* switch to Task_1 */
113
114  /* exit this thread */
115
116  puts( "Init: pthread_exit" );
117  pthread_exit( NULL );
118
119    /* switch to Task_1 */
120
121  return NULL; /* just so the compiler thinks we returned something */
122}
Note: See TracBrowser for help on using the repository browser.