source: rtems/testsuites/mptests/mp12/init.c @ 116845e8

4.104.114.84.9
Last change on this file since 116845e8 was 116845e8, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 2, 2002 at 12:53:03 AM

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.
  • mp01/task1.c, mp02/task1.c, mp03/task1.c, mp04/task1.c, mp05/task1.c, mp06/task1.c, mp07/task1.c, mp08/task1.c, mp09/task1.c, mp10/init.c, mp11/init.c, mp12/init.c, mp13/init.c, mp13/task2.c: Modified.
  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*  Init
2 *
3 *  This routine is the initialization routine and test code for
4 *  global partitions.  It creates a global partition, obtains and
5 *  releases a buffer, and deletes the partition.  The partition
6 *  is created on node one, and an attempt is made to delete it
7 *  by node two.
8 *  This routine is the initialization task for this test program.
9 *  It is a user initialization task and has the responsibility for creating
10 *  and starting the tasks that make up the test.  If the time of day
11 *  clock is required for the test, it should also be set to a known
12 *  value by this function.
13 *
14 *  Input parameters:
15 *    argument - task argument
16 *
17 *  Output parameters:  NONE
18 *
19 *  COPYRIGHT (c) 1989-1999.
20 *  On-Line Applications Research Corporation (OAR).
21 *
22 *  The license and distribution terms for this file may be
23 *  found in the file LICENSE in this distribution or at
24 *  http://www.OARcorp.com/rtems/license.html.
25 *
26 *  $Id$
27 */
28
29#define TEST_INIT
30#include "system.h"
31
32rtems_unsigned8 Partition_area[ 1024 ] CPU_STRUCTURE_ALIGNMENT;
33
34rtems_task Init(
35  rtems_task_argument argument
36)
37{
38  rtems_status_code  status;
39  void              *bufaddr;
40
41  printf(
42    "\n\n*** TEST 12 -- NODE %d ***\n",
43    Multiprocessing_configuration.node
44   );
45
46  Task_name[ 1 ] = rtems_build_name( '1', '1', '1', ' ' );
47  Task_name[ 2 ] = rtems_build_name( '2', '2', '2', ' ' );
48
49  Partition_name[ 1 ] = rtems_build_name( 'P', 'A', 'R', ' ' );
50
51  puts( "Got to initialization task" );
52
53  if ( Multiprocessing_configuration.node == 2 )  {
54    status = rtems_task_wake_after( 1 * TICKS_PER_SECOND );
55    directive_failed( status, "rtems_task_wake_after" );
56
57    puts( "Getting ID of remote Partition (Global)" );
58
59    do {
60      status = rtems_partition_ident(
61        Partition_name[ 1 ],
62        RTEMS_SEARCH_ALL_NODES,
63        &Partition_id[ 1 ]
64      );
65    } while ( !rtems_is_status_successful( status ) );
66
67    puts( "Attempting to delete remote Partition (Global)" );
68    status = rtems_partition_delete( Partition_id[ 1 ] );
69    fatal_directive_status(
70      status,
71      RTEMS_ILLEGAL_ON_REMOTE_OBJECT,
72      "rtems_partition_delete"
73    );
74    puts(
75     "rtems_partition_delete correctly returned RTEMS_ILLEGAL_ON_REMOTE_OBJECT"
76    );
77
78    puts( "Obtaining a buffer from the global partition" );
79    status = rtems_partition_get_buffer( Partition_id[ 1 ], &bufaddr );
80    directive_failed( status, "rtems_partition_get_buffer" );
81    printf( "Address returned was : 0x%p\n", bufaddr );
82
83    puts( "Releasing a buffer to the global partition" );
84    status = rtems_partition_return_buffer( Partition_id[ 1 ], bufaddr );
85    directive_failed( status, "rtems_partition_return_buffer" );
86
87    status = rtems_task_wake_after( 2 * TICKS_PER_SECOND );
88    directive_failed( status, "rtems_task_wake_after" );
89  }
90  else {
91    puts( "Creating Partition (Global)" );
92    status = rtems_partition_create(
93      Partition_name[ 1 ],
94      Partition_area,
95      128,
96      64,
97      RTEMS_GLOBAL,
98      &Partition_id[ 1 ]
99    );
100    directive_failed( status, "rtems_partition_create" );
101
102    puts( "Sleeping for two seconds" );
103    status = rtems_task_wake_after( 2 * TICKS_PER_SECOND );
104    directive_failed( status, "rtems_task_wake_after" );
105
106    puts( "Deleting Partition (Global)" );
107    status = rtems_partition_delete( Partition_id[ 1 ] );
108    directive_failed( status, "rtems_partition_delete" );
109 }
110 puts( "*** END OF TEST 12 ***" );
111 rtems_test_exit( 0 );
112}
Note: See TracBrowser for help on using the repository browser.