Ticket #1593: sysinit_testcase_v1.patch

File sysinit_testcase_v1.patch, 13.6 KB (added by zhangwenjie, on 07/27/10 at 14:17:05)

The test case for sysinit API

  • testsuites/sptests/ChangeLog

    diff --git a/testsuites/sptests/ChangeLog b/testsuites/sptests/ChangeLog
    index ff494c4..64d5582 100644
    a b  
     12010-07-27      Zhang Wenjie <157724595@163.com>
     2
     3        PR 1593/sptests
     4        * sptests/Makefile.am, sptests/configure.ac,
     5        sptests/spsysinit/Makefile.am, sptests/spsysinit/spsysinit.doc,
     6        sptests/spsysinit/spsysinit.scn, sptests/spsysinit/init.c,
     7        sptests/spsysinit/sysinitfirst.c, sptests/spsysinit/sysinitlast.c,
     8        sptests/spsysinit/sysinitsecond.c, sptests/spsysinit/sysinitthird.c,
     9        sptests/spsysinit/sysinittest.h: Add the test case for Sysinit API.
     10
    1112010-06-24      Bharath Suri <bharath.s.jois@gmail.com>
    212
    313        * Makefile.am, configure.ac: Removed some fifo tests.
  • testsuites/sptests/Makefile.am

    diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
    index 16b95e3..93abdfd 100644
    a b SUBDIRS = \ 
    2525    spintrcritical05 spintrcritical06 spintrcritical07 spintrcritical08 \
    2626    spintrcritical09 spintrcritical10 spintrcritical11 spintrcritical12 \
    2727    spintrcritical13 spintrcritical14 spintrcritical15 spintrcritical16 \
    28     spintrcritical17 spmkdir
     28    spintrcritical17 spmkdir spsysinit
    2929 
    3030DIST_SUBDIRS = $(SUBDIRS) spfatal_support spintrcritical_support
    3131EXTRA_DIST = spfatal_support/init.c spfatal_support/system.h
  • testsuites/sptests/configure.ac

    diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
    index 748a1d8..1b39b8f 100644
    a b spstkalloc/Makefile 
    148148spthreadq01/Makefile
    149149spwatchdog/Makefile
    150150spwkspace/Makefile
     151spsysinit/Makefile
    151152])
    152153AC_OUTPUT
  • new file testsuites/sptests/spsysinit/Makefile.am

    diff --git a/testsuites/sptests/spsysinit/Makefile.am b/testsuites/sptests/spsysinit/Makefile.am
    new file mode 100644
    index 0000000..cd4844f
    - +  
     1##
     2## $Id: Makefile.am,v 1.23 2009/04/03 12:48:12 ralf Exp $
     3##
     4
     5MANAGERS = io semaphore
     6
     7noinst_LIBRARIES = libsysinit.a
     8libsysinit_a_SOURCES = sysinitfirst.c sysinitsecond.c \
     9        sysinitthird.c sysinitlast.c
     10
     11rtems_tests_PROGRAMS = spsysinit
     12spsysinit_SOURCES = init.c sysinittest.h
     13
     14dist_rtems_tests_DATA = spsysinit.scn
     15dist_rtems_tests_DATA += spsysinit.doc
     16
     17include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
     18include $(top_srcdir)/../automake/compile.am
     19include $(top_srcdir)/../automake/leaf.am
     20
     21spsysinit_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
     22
     23AM_CPPFLAGS += -I$(top_srcdir)/../support/include
     24
     25spsysinit_LDLIBS = -L. -lsysinit
     26
     27LINK_OBJS = $(spsysinit_OBJECTS) $(spsysinit_LDADD)
     28LINK_LIBS = $(spsysinit_LDLIBS)
     29
     30spsysinit$(EXEEXT): $(spsysinit_OBJECTS) $(spsysinit_DEPENDENCIES)
     31        @rm -f spsysinit$(EXEEXT)
     32        $(make-exe)
     33
     34include $(top_srcdir)/../automake/local.am
  • new file testsuites/sptests/spsysinit/init.c

    diff --git a/testsuites/sptests/spsysinit/init.c b/testsuites/sptests/spsysinit/init.c
    new file mode 100644
    index 0000000..34c915a
    - +  
     1/**
     2 * @file
     3 *
     4 * @ingroup test_sysinit
     5 *
     6 * @brief test sysinit API .
     7 */
     8
     9/*
     10 *
     11 * Copyright (c) 2010
     12 * Zhangwenjie <157724595@163.com>
     13 *
     14 * The license and distribution terms for this file may be
     15 * found in the file LICENSE in this distribution or at
     16 * http://www.rtems.com/license/LICENSE.
     17 *
     18 * $Id$
     19 */
     20
     21#define CONFIGURE_INIT
     22#include <tmacros.h>
     23#include <rtems/score/sysinit.h>
     24#include "sysinittest.h"
     25
     26Group_Order Running_Order = 0;
     27
     28SYSINIT_REFERENCE( Sysinit_Group_First_Test );
     29SYSINIT_REFERENCE( Sysinit_Group_Second_Test );
     30SYSINIT_REFERENCE( Sysinit_Group_Third_Test );
     31SYSINIT_REFERENCE( Sysinit_Group_Last_Test );
     32
     33rtems_task Init(
     34  rtems_task_argument argument
     35)
     36
     37  puts( "\n\n*** SYSINIT TEST 1 ***" );
     38
     39  Running_Order = ORDER_GROUP_FIRST;
     40  puts( "\nSysinit Iterate:" );
     41
     42  _Sysinit_Iterate( SYSINIT_TEST_NOMAL );
     43
     44  Running_Order = ORDER_GROUP_LAST;
     45  puts( "\n\nSysinit Iterate Reversed:" );
     46
     47  _Sysinit_Iterate_reversed( SYSINIT_TEST_REVERSED );
     48
     49  puts( "\n*** END OF SYSINIT TEST 1 ***" );
     50 
     51  rtems_test_exit( 0 );
     52}
     53
     54/* configuration information */
     55
     56#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
     57#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
     58
     59#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
     60
     61#define CONFIGURE_EXTRA_TASK_STACKS         (1 * RTEMS_MINIMUM_STACK_SIZE)
     62#define CONFIGURE_MAXIMUM_TASKS             1
     63
     64#include <rtems/confdefs.h>
     65/*end of file*/
  • new file testsuites/sptests/spsysinit/spsysinit.doc

    diff --git a/testsuites/sptests/spsysinit/spsysinit.doc b/testsuites/sptests/spsysinit/spsysinit.doc
    new file mode 100644
    index 0000000..fac0eab
    - +  
     1#
     2# $Id$
     3#
     4# Copyright (c) 2009
     5# Zhangwenjie <157724595@163.com>
     6#
     7# The license and distribution terms for this file may be
     8# found in the file LICENSE in this distribution or at
     9# http://www.rtems.com/license/LICENSE.
     10#
     11
     12This file describes the directives and concepts tested by this test set.
     13
     14test set name:  spsysinit01
     15
     16directives:
     17
     18  _Sysinit_Iterate
     19  _Sysinit_Iterate_reversed
     20  SYSINIT_ENTRY
     21  SYSINIT_REFERENCE
     22 
     23concepts:
     24
     25  a.  Verifies sysinit API can iterate every reference object in nomal order
     26      and in reversed order
     27
     28  b.  Verifies executive can include only wanted reference object into sysinit
     29      section.
     30
     31output:
     32
     33  "Sysinit module start nomal test" is printed in nomal sequenced order . 
     34  Then "Sysinit module start reversed test" is printed in reversed sequenced
     35  order.
  • new file testsuites/sptests/spsysinit/spsysinit.scn

    diff --git a/testsuites/sptests/spsysinit/spsysinit.scn b/testsuites/sptests/spsysinit/spsysinit.scn
    new file mode 100644
    index 0000000..ff89bae
    - +  
     1*** SYSINIT TEST 1 ***
     2Sysinit Iterate:
     3First Sysinit module start nomal test
     4Second Sysinit module start nomal test
     5Third Sysinit module start nomal test
     6Last Sysinit module start nomal test
     7
     8Sysinit Iterate Reversed:
     9Last Sysinit module start reversed test
     10Third Sysinit module start reversed test
     11Second Sysinit module start reversed test
     12First Sysinit module start reversed test
     13*** END OF SYSINIT TEST 1 ***
     14
  • new file testsuites/sptests/spsysinit/sysinitfirst.c

    diff --git a/testsuites/sptests/spsysinit/sysinitfirst.c b/testsuites/sptests/spsysinit/sysinitfirst.c
    new file mode 100644
    index 0000000..4760a7c
    - +  
     1/**
     2 * @file
     3 *
     4 * @ingroup test_sysinit
     5 *
     6 * @brief Sysinit_Group_First_Test for sequenced initialization api and
     7 *  it is compiled into a library.
     8 */
     9
     10/*
     11 *
     12 * Copyright (c) 2010
     13 * Zhangwenjie <157724595@163.com>
     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.com/license/LICENSE.
     18 *
     19 * $Id$
     20 */
     21
     22#include <tmacros.h>
     23#include <rtems/score/sysinit.h>
     24#include "sysinittest.h"
     25
     26void Sysinit_Group_First_Test(
     27  Sysinit_State state
     28)
     29{
     30  switch ( state ) {
     31    case SYSINIT_INITIALIZE:
     32      break;
     33    case SYSINIT_TERMINATE:
     34      break;
     35    case SYSINIT_TEST_NOMAL:
     36      if ( Running_Order > ORDER_GROUP_FIRST )
     37        directive_failed( RTEMS_INTERNAL_ERROR, "Sysinit_Group_First_Test" );
     38      puts( "\nFirst Sysinit module start nomal test" );                       
     39      break;
     40    case SYSINIT_TEST_REVERSED:
     41      if ( Running_Order < ORDER_GROUP_FIRST )
     42        directive_failed( RTEMS_INTERNAL_ERROR, "Sysinit_Group_First_Test" );
     43      puts( "\nFirst Sysinit module start reversed test" );             
     44      break;
     45    default:
     46      puts( "\nFirst Sysinit module is in wrong status" );
     47      rtems_fatal_error_occurred( RTEMS_INCORRECT_STATE );
     48      break;
     49  }
     50
     51  Running_Order = ORDER_GROUP_FIRST;
     52}
     53
     54SYSINIT_ENTRY( Sysinit_Group_First_Test, SYSINIT_TEST_GROUP_FIRST );
  • new file testsuites/sptests/spsysinit/sysinitlast.c

    diff --git a/testsuites/sptests/spsysinit/sysinitlast.c b/testsuites/sptests/spsysinit/sysinitlast.c
    new file mode 100644
    index 0000000..debf5f8
    - +  
     1/**
     2 * @file
     3 *
     4 * @ingroup test_sysinit
     5 *
     6 * @brief Sysinit_Group_Last_Test for sequenced initialization api and
     7 * it is compiled into a library.
     8 */
     9
     10/*
     11 *
     12 * Copyright (c) 2010
     13 * Zhangwenjie <157724595@163.com>
     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.com/license/LICENSE.
     18 *
     19 * $Id$ 
     20 */
     21
     22#include <tmacros.h>
     23#include <rtems/score/sysinit.h>
     24#include "sysinittest.h"
     25
     26void Sysinit_Group_Last_Test(
     27  Sysinit_State state
     28)
     29
     30  switch ( state ) {
     31    case SYSINIT_INITIALIZE:
     32      break;
     33    case SYSINIT_TERMINATE:
     34      break;
     35    case SYSINIT_TEST_NOMAL:
     36      if ( Running_Order > ORDER_GROUP_LAST )
     37        directive_failed( RTEMS_INTERNAL_ERROR, "Sysinit_Group_Last_Test" );
     38      puts( "\nLast Sysinit module start nomal test" );
     39      break;
     40    case SYSINIT_TEST_REVERSED:
     41      if ( Running_Order < ORDER_GROUP_LAST )
     42        directive_failed( RTEMS_INTERNAL_ERROR, "Sysinit_Group_Last_Test" );
     43      puts( "\nLast Sysinit module start reversed test" );
     44      break;
     45    default:
     46      puts( "\nLast Sysinit module is in wrong status" );
     47      rtems_fatal_error_occurred( RTEMS_INCORRECT_STATE );
     48      break;
     49  }
     50
     51  Running_Order = ORDER_GROUP_LAST;
     52}
     53
     54SYSINIT_ENTRY( Sysinit_Group_Last_Test, SYSINIT_GROUP_LAST );
  • new file testsuites/sptests/spsysinit/sysinitsecond.c

    diff --git a/testsuites/sptests/spsysinit/sysinitsecond.c b/testsuites/sptests/spsysinit/sysinitsecond.c
    new file mode 100644
    index 0000000..1d6791d
    - +  
     1/**
     2 * @file
     3 *
     4 * @ingroup test_sysinit
     5 *
     6 * @brief Sysinit_Group_Second_Test for sequenced initialization api and
     7 *  it is compiled into a library.
     8 */
     9
     10/*
     11 *
     12 * Copyright (c) 2010
     13 * Zhangwenjie <157724595@163.com>
     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.com/license/LICENSE.
     18 *
     19 * $Id$
     20 */
     21#include <tmacros.h>
     22#include <rtems/score/sysinit.h>
     23#include "sysinittest.h"
     24
     25void Sysinit_Group_Second_Test(
     26  Sysinit_State state
     27)
     28{
     29  switch ( state ) {
     30    case SYSINIT_INITIALIZE:
     31      break;
     32    case SYSINIT_TERMINATE:
     33      break;
     34    case SYSINIT_TEST_NOMAL:
     35      if ( Running_Order > ORDER_GROUP_SECOND )
     36        directive_failed( RTEMS_INTERNAL_ERROR, "Sysinit_Group_Second_Test" );
     37      puts( "\nSecond Sysinit module start nomal test" );
     38      break;
     39    case SYSINIT_TEST_REVERSED:
     40      if ( Running_Order < ORDER_GROUP_SECOND )
     41        directive_failed( RTEMS_INTERNAL_ERROR, "Sysinit_Group_Second_Test" );
     42      puts( "\nSecond Sysinit module start reversed test" );
     43      break;
     44    default:
     45      puts( "\nSecond Sysinit module is in wrong status" );
     46      rtems_fatal_error_occurred( RTEMS_INCORRECT_STATE );
     47      break;
     48  }
     49       
     50  Running_Order = ORDER_GROUP_SECOND;
     51}
     52
     53SYSINIT_ENTRY( Sysinit_Group_Second_Test, SYSINIT_TEST_GROUP_SECOND );
  • new file testsuites/sptests/spsysinit/sysinittest.h

    diff --git a/testsuites/sptests/spsysinit/sysinittest.h b/testsuites/sptests/spsysinit/sysinittest.h
    new file mode 100644
    index 0000000..66dcedc
    - +  
     1/**
     2 * @file
     3 *
     4 * @ingroup test_sysinit
     5 *
     6 * @brief This include file contains information that is included in every
     7 *  sysinit function module in the test set.
     8 */
     9
     10/*
     11 *
     12 * Copyright (c) 2010
     13 * Zhangwenjie <157724595@163.com>
     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.com/license/LICENSE.
     18 *
     19 * $Id$
     20 */
     21
     22/**
     23 * @brief Group Order.
     24 */
     25typedef enum {
     26  ORDER_GROUP_FIRST = 0,
     27  ORDER_GROUP_SECOND,
     28  ORDER_GROUP_THIRD,
     29  ORDER_GROUP_LAST
     30} Group_Order;
     31
     32#define SYSINIT_TEST_GROUP_FIRST    "9000"
     33#define SYSINIT_TEST_GROUP_SECOND   "9001"
     34#define SYSINIT_TEST_GROUP_THIRD    "9002"
     35#define SYSINIT_TEST_GROUP_LAST     "9999"
     36
     37#define SYSINIT_TEST_NOMAL  21458
     38#define SYSINIT_TEST_REVERSED  21459
     39
     40extern Group_Order Running_Order;
     41
     42/* end of include file */
  • new file testsuites/sptests/spsysinit/sysinitthird.c

    diff --git a/testsuites/sptests/spsysinit/sysinitthird.c b/testsuites/sptests/spsysinit/sysinitthird.c
    new file mode 100644
    index 0000000..51ac23b
    - +  
     1/**
     2 * @file
     3 *
     4 * @ingroup test_sysinit
     5 *
     6 * @brief Sysinit_Group_Third_Test for sequenced initialization api and
     7 * it is compiled into a library.
     8 */
     9
     10/*
     11 *
     12 * Copyright (c) 2010
     13 * Zhangwenjie <157724595@163.com>
     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.com/license/LICENSE.
     18 *
     19 * $Id$
     20 */
     21
     22#include <tmacros.h>
     23#include <rtems/score/sysinit.h>
     24#include "sysinittest.h"
     25
     26void Sysinit_Group_Third_Test(
     27  Sysinit_State state
     28)
     29{
     30  switch ( state ) {
     31    case SYSINIT_INITIALIZE:
     32      break;
     33    case SYSINIT_TERMINATE:
     34      break;
     35    case SYSINIT_TEST_NOMAL:
     36      if ( Running_Order > ORDER_GROUP_THIRD )
     37        directive_failed( RTEMS_INTERNAL_ERROR, "Sysinit_Group_Third_Test" );
     38      puts( "\nThird Sysinit module start nomal test" );
     39      break;
     40    case SYSINIT_TEST_REVERSED:
     41      if ( Running_Order < ORDER_GROUP_THIRD )
     42        directive_failed( RTEMS_INTERNAL_ERROR, "Sysinit_Group_Third_Test" );
     43      puts( "\nThird Sysinit module start reversed test" );
     44      break;   
     45    default:
     46      puts( "\nThird Sysinit module is in wrong status" );
     47      rtems_fatal_error_occurred( RTEMS_INCORRECT_STATE );
     48      break;     
     49  }
     50       
     51  Running_Order = ORDER_GROUP_THIRD;
     52}
     53
     54SYSINIT_ENTRY( Sysinit_Group_Third_Test, SYSINIT_TEST_GROUP_THIRD );