summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorJennifer Averett <jennifer.averett@oarcorp.com>2014-09-29 14:31:18 -0500
committerJennifer Averett <jennifer.averett@oarcorp.com>2014-10-28 08:09:37 -0500
commit410bcdfe5f9185602dcd3283c436838797bf939b (patch)
treed5f17bc32ca84b6e65e10f5f3fb63841a418ed4f /testsuites
parentcapture: Remove ctload command. (diff)
downloadrtems-410bcdfe5f9185602dcd3283c436838797bf939b.tar.bz2
top: Add new test.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/libtests/Makefile.am2
-rw-r--r--testsuites/libtests/configure.ac1
-rw-r--r--testsuites/libtests/top/Makefile.am21
-rw-r--r--testsuites/libtests/top/init.c105
-rw-r--r--testsuites/libtests/top/system.h63
-rw-r--r--testsuites/libtests/top/task1.c85
-rw-r--r--testsuites/libtests/top/task2.c34
-rw-r--r--testsuites/libtests/top/task3.c45
-rw-r--r--testsuites/libtests/top/top.scn33
9 files changed, 388 insertions, 1 deletions
diff --git a/testsuites/libtests/Makefile.am b/testsuites/libtests/Makefile.am
index f6a27780a4..847cd2a7ad 100644
--- a/testsuites/libtests/Makefile.am
+++ b/testsuites/libtests/Makefile.am
@@ -17,7 +17,7 @@ _SUBDIRS += flashdisk01
_SUBDIRS += capture01
_SUBDIRS += bspcmdline01 cpuuse devfs01 devfs02 devfs03 devfs04 \
- deviceio01 devnullfatal01 dumpbuf01 gxx01 \
+ deviceio01 devnullfatal01 dumpbuf01 gxx01 top\
malloctest malloc02 malloc03 malloc04 malloc05 heapwalk \
putenvtest monitor monitor02 rtmonuse stackchk stackchk01 \
termios termios01 termios02 termios03 termios04 termios05 \
diff --git a/testsuites/libtests/configure.ac b/testsuites/libtests/configure.ac
index e246680374..410fb75691 100644
--- a/testsuites/libtests/configure.ac
+++ b/testsuites/libtests/configure.ac
@@ -109,6 +109,7 @@ termios05/Makefile
termios06/Makefile
termios07/Makefile
termios08/Makefile
+top/Makefile
tztest/Makefile
capture01/Makefile
POSIX/Makefile
diff --git a/testsuites/libtests/top/Makefile.am b/testsuites/libtests/top/Makefile.am
new file mode 100644
index 0000000000..c4aee3ae92
--- /dev/null
+++ b/testsuites/libtests/top/Makefile.am
@@ -0,0 +1,21 @@
+
+rtems_tests_PROGRAMS = top
+top_SOURCES = init.c task1.c task2.c task3.c system.h
+
+dist_rtems_tests_DATA = top.scn
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(top_OBJECTS)
+LINK_LIBS = $(top_LDLIBS)
+
+top$(EXEEXT): $(top_OBJECTS) $(top_DEPENDENCIES)
+ @rm -f top$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/libtests/top/init.c b/testsuites/libtests/top/init.c
new file mode 100644
index 0000000000..c0e980bc4f
--- /dev/null
+++ b/testsuites/libtests/top/init.c
@@ -0,0 +1,105 @@
+/*
+ * This test checks rtems_cpu_usage_top command with
+ * 30 tasks being created and deleted. The command
+ * should show the task list grow to the top 20 tasks
+ * then shrink back down to 5 tasks.
+ *
+ * Input parameters:
+ * argument - task argument
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 2014.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+const char rtems_test_name[] = "TOP";
+
+/*
+ * This method is called by Task_3 to provide
+ * a variable lengh run time for each instance
+ * of the task.
+ */
+
+void add_some(
+ uint32_t per_loop,
+ uint32_t *sum,
+ uint32_t *next
+)
+{
+ int i;
+
+ for ( i=0 ; i<per_loop ; i++ ) {
+ *sum += *next;
+ *next += 1;
+ }
+}
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+ rtems_time_of_day time;
+
+ TEST_BEGIN();
+ build_time( &time, 12, 31, 1988, 9, 15, 0, 0 );
+
+ status = rtems_clock_set( &time );
+ directive_failed( status, "rtems_clock_set" );
+
+ TicksPerSecond = rtems_clock_get_ticks_per_second();
+ if (TicksPerSecond <= 0) {
+ printf(
+ "Invalid ticks per second: %" PRIdrtems_interval "\n",
+ TicksPerSecond
+ );
+ exit (1);
+ }
+
+ /* Create and start the task to run top command. */
+ Task_name[ 2 ] = rtems_build_name( 'T', 'A', '0', '2' );
+ status = rtems_task_create(
+ Task_name[ 2 ],
+ 2,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_TIMESLICE,
+ RTEMS_FLOATING_POINT,
+ &Task_id[ 2 ]
+ );
+ directive_failed( status, "rtems_task_create of TA02" );
+ status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
+ directive_failed( status, "rtems_task_start of TA2" );
+
+ /* Create and start task to run the test. */
+ Task_name[ 1 ] = rtems_build_name( 'T', 'A', '0', '1' );
+ status = rtems_task_create(
+ Task_name[ 1 ],
+ 2,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_TIMESLICE,
+ RTEMS_FLOATING_POINT,
+ &Task_id[ 1 ]
+ );
+ directive_failed( status, "rtems_task_create of TA01" );
+ status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
+ directive_failed( status, "rtems_task_start of TA01" );
+
+ /*
+ * We suspend the Init task rather than delete it so it still
+ * shows up in the output.
+ */
+ status = rtems_task_suspend( RTEMS_SELF );
+ directive_failed( status, "rtems_task_suspend of RTEMS_SELF" );
+}
diff --git a/testsuites/libtests/top/system.h b/testsuites/libtests/top/system.h
new file mode 100644
index 0000000000..945fbcabca
--- /dev/null
+++ b/testsuites/libtests/top/system.h
@@ -0,0 +1,63 @@
+/* system.h
+ *
+ * This include file contains information that is included in every
+ * function in the test set.
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#include <bsp.h>
+#include <tmacros.h>
+
+/* functions */
+
+rtems_task Init(
+ rtems_task_argument argument
+);
+
+rtems_task Task_1(
+ rtems_task_argument argument
+);
+
+rtems_task Task_2(
+ rtems_task_argument argument
+);
+
+rtems_task Task_3(
+ rtems_task_argument argument
+);
+
+void add_some(
+ uint32_t per_loop,
+ uint32_t *sum,
+ uint32_t *next
+);
+
+/* configuration information */
+#define TASK_COUNT 30
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
+#define CONFIGURE_MAXIMUM_TASKS (TASK_COUNT+2)
+#define CONFIGURE_TICKS_PER_TIMESLICE 100
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#include <rtems/confdefs.h>
+
+/* global variables */
+
+TEST_EXTERN rtems_id Task_id[ TASK_COUNT ]; /* array of task ids */
+TEST_EXTERN rtems_name Task_name[ TASK_COUNT ]; /* array of task names */
+TEST_EXTERN rtems_interval TicksPerSecond;
+
+/* end of include file */
diff --git a/testsuites/libtests/top/task1.c b/testsuites/libtests/top/task1.c
new file mode 100644
index 0000000000..fc81f511e2
--- /dev/null
+++ b/testsuites/libtests/top/task1.c
@@ -0,0 +1,85 @@
+/* Task_1
+ *
+ * This test serves as a test task. It creates and deletes
+ * the remaining tasks, twice so that the tasks displayed by
+ * the top command grow past the max tasks displayed then shrink
+ * back down.
+ *
+ * Input parameters:
+ * argument - task argument
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 2014.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "system.h"
+
+static void create_and_start( uint32_t i )
+{
+ rtems_status_code status;
+ char str[30];
+ char name[5];
+
+ sprintf(name, "TA%02" PRId32 " ", i);
+
+ Task_name[ i ] = rtems_build_name(
+ name[0], name[1], name[2], name[3]
+ );
+
+ status = rtems_task_create(
+ Task_name[ i ],
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_TIMESLICE,
+ RTEMS_FLOATING_POINT,
+ &Task_id[ i ]
+ );
+ sprintf(str,"rtems_task_create of %s", name);
+ directive_failed( status, str );
+
+ status = rtems_task_start( Task_id[ i ], Task_3, i );
+ sprintf(str, "rtems_task_start of %s", name);
+ directive_failed( status, str);
+}
+
+rtems_task Task_1(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+ char str[80];
+ uint32_t i,j;
+
+ for(j=0; j<2; j++) {
+
+ for( i=3; i<TASK_COUNT; i++) {
+ create_and_start(i);
+ status = rtems_task_wake_after (TicksPerSecond * 5);
+ directive_failed( status, "rtems_task_wake_after" );
+ }
+
+ status = rtems_task_wake_after (TicksPerSecond * 10);
+ directive_failed( status, "rtems_task_wake_after" );
+
+ for( i=3; i<TASK_COUNT; i++) {
+ status = rtems_task_delete( Task_id[i] );
+ sprintf(str, "task delete TA%02" PRId32 "", i);
+ directive_failed( status, str );
+ status = rtems_task_wake_after (TicksPerSecond * 5);
+ directive_failed( status, "rtems_task_wake_after" );
+ }
+ }
+
+ TEST_END();
+ rtems_test_exit( 0 );
+}
diff --git a/testsuites/libtests/top/task2.c b/testsuites/libtests/top/task2.c
new file mode 100644
index 0000000000..5435d5b66a
--- /dev/null
+++ b/testsuites/libtests/top/task2.c
@@ -0,0 +1,34 @@
+/* Task_2
+ *
+ * This routine serves as a test task. It calls the
+ * top command and forces an exit if the user requests it.
+ *
+ * Input parameters:
+ * argument - task argument
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 2014.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "system.h"
+
+#include <rtems/cpuuse.h>
+
+rtems_task Task_2(
+ rtems_task_argument argument
+)
+{
+ rtems_cpu_usage_top();
+ TEST_END();
+ rtems_test_exit( 0 );
+}
diff --git a/testsuites/libtests/top/task3.c b/testsuites/libtests/top/task3.c
new file mode 100644
index 0000000000..891351bad9
--- /dev/null
+++ b/testsuites/libtests/top/task3.c
@@ -0,0 +1,45 @@
+/* Task_3
+ *
+ * This routine serves as a test task. It receives a task
+ * number and uses it to force each progressive task created
+ * to have a higher cpu utilization than the previous.
+ *
+ * Input parameters:
+ * argument - task argument
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 2014.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "system.h"
+
+rtems_task Task_3(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+ uint32_t sum;
+ uint32_t next;
+ uint32_t per_loop;
+
+ sum = 0;
+ next = 0;
+ per_loop = argument * 1000;
+
+ while( FOREVER ) {
+ add_some( per_loop, &sum, &next );
+
+ status = rtems_task_wake_after (TicksPerSecond * 1);
+ directive_failed( status, "rtems_task_wake_after" );
+ }
+}
diff --git a/testsuites/libtests/top/top.scn b/testsuites/libtests/top/top.scn
new file mode 100644
index 0000000000..49dac7e9e3
--- /dev/null
+++ b/testsuites/libtests/top/top.scn
@@ -0,0 +1,33 @@
+ Press ENTER to exit.
+
+uptime: 140.546370
+-------------------------------------------------------------------------------
+ CPU USAGE BY THREAD
+------------+---------------------+---------------+---------------+------------
+ ID | NAME | RPRI | CPRI | SECONDS | PERCENT
+------------+---------------------+---------------+---------------+------------
+ 0x09010001 | IDLE | 255 | 255 | 112.654821 | 80.153
+ 0x0A010011 | TA15 | 1 | 1 | 1.306286 | 0.929
+ 0x0A010012 | TA16 | 1 | 1 | 1.305471 | 0.928
+ 0x0A010010 | TA14 | 1 | 1 | 1.294906 | 0.921
+ 0x0A010013 | TA17 | 1 | 1 | 1.292205 | 0.919
+ 0x0A01000F | TA13 | 1 | 1 | 1.276434 | 0.908
+ 0x0A010014 | TA18 | 1 | 1 | 1.271627 | 0.904
+ 0x0A01000E | TA12 | 1 | 1 | 1.242711 | 0.884
+ 0x0A010015 | TA19 | 1 | 1 | 1.238464 | 0.881
+ 0x0A01000D | TA11 | 1 | 1 | 1.200918 | 0.854
+ 0x0A010016 | TA20 | 1 | 1 | 1.193498 | 0.849
+ 0x0A01000C | TA10 | 1 | 1 | 1.148041 | 0.816
+ 0x0A010017 | TA21 | 1 | 1 | 1.138710 | 0.810
+ 0x0A01000B | TA09 | 1 | 1 | 1.091268 | 0.776
+ 0x0A010018 | TA22 | 1 | 1 | 1.073192 | 0.763
+ 0x0A01000A | TA08 | 1 | 1 | 1.015671 | 0.722
+ 0x0A010019 | TA23 | 1 | 1 | 0.996919 | 0.709
+ 0x0A010002 | TA02 | 2 | 2 | 0.979956 | 0.697
+ 0x0A010009 | TA07 | 1 | 1 | 0.929823 | 0.661
+ 0x0A01001A | TA24 | 1 | 1 | 0.909891 | 0.647
+
+load monitoring stopped.
+*** END OF TEST CPUUSE ***
+NOTE: Actual output will vary. It should be seen to grow to 20 visible tasks
+then shrink back down to 5 visible tasks.