source: rtems/testsuites/libtests/top/init.c @ 410bcdfe

4.115
Last change on this file since 410bcdfe was 410bcdfe, checked in by Jennifer Averett <jennifer.averett@…>, on 09/29/14 at 19:31:18

top: Add new test.

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  This test checks rtems_cpu_usage_top command with
3 *  30 tasks being created and deleted.  The command
4 *  should show the task list grow to the top 20 tasks
5 *  then shrink back down to 5 tasks.
6 *
7 *  Input parameters:
8 *    argument - task argument
9 *
10 *  Output parameters:  NONE
11 *
12 *  COPYRIGHT (c) 2014.
13 *  On-Line Applications Research Corporation (OAR).
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.rtems.org/license/LICENSE.
18 */
19
20#ifdef HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#define CONFIGURE_INIT
25#include "system.h"
26
27const char rtems_test_name[] = "TOP";
28
29/*
30 * This method is called by Task_3 to provide
31 * a variable lengh run time for each instance
32 * of the task.
33 */
34
35void add_some(
36  uint32_t  per_loop,
37  uint32_t *sum,
38  uint32_t *next
39)
40{
41  int i;
42
43  for ( i=0 ; i<per_loop ; i++ ) {
44    *sum += *next;
45    *next += 1;
46  }
47}
48
49rtems_task Init(
50  rtems_task_argument argument
51)
52{
53  rtems_status_code status;
54  rtems_time_of_day time;
55
56  TEST_BEGIN();
57  build_time( &time, 12, 31, 1988, 9, 15, 0, 0 );
58
59  status = rtems_clock_set( &time );
60  directive_failed( status, "rtems_clock_set" );
61
62  TicksPerSecond = rtems_clock_get_ticks_per_second();
63  if (TicksPerSecond <= 0) {
64    printf(
65      "Invalid ticks per second: %" PRIdrtems_interval "\n",
66      TicksPerSecond
67    );
68    exit (1);
69  }
70
71  /* Create and start the task to run top command. */
72  Task_name[ 2 ] =  rtems_build_name( 'T', 'A', '0', '2' );
73  status = rtems_task_create(
74     Task_name[ 2 ],
75     2,
76     RTEMS_MINIMUM_STACK_SIZE,
77     RTEMS_TIMESLICE,
78     RTEMS_FLOATING_POINT,
79     &Task_id[ 2 ]
80  );
81  directive_failed( status, "rtems_task_create of TA02" );
82  status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
83  directive_failed( status, "rtems_task_start of TA2" );
84
85  /* Create and start task to run the test. */
86  Task_name[ 1 ] =  rtems_build_name( 'T', 'A', '0', '1' );
87  status = rtems_task_create(
88     Task_name[ 1 ],
89     2,
90     RTEMS_MINIMUM_STACK_SIZE,
91     RTEMS_TIMESLICE,
92     RTEMS_FLOATING_POINT,
93     &Task_id[ 1 ]
94  );
95  directive_failed( status, "rtems_task_create of TA01" );
96  status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
97  directive_failed( status, "rtems_task_start of TA01" );
98
99  /*
100   * We suspend the Init task rather than delete it so it still
101   * shows up in the output.
102   */
103  status = rtems_task_suspend( RTEMS_SELF );
104  directive_failed( status, "rtems_task_suspend of RTEMS_SELF" );
105}
Note: See TracBrowser for help on using the repository browser.