Changeset 469e71d in rtems


Ignore:
Timestamp:
Aug 24, 2010, 3:01:04 PM (10 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
e0b6d43e
Parents:
69f2a07
Message:

2010-08-24 Sebastian Huber <sebastian.huber@…>

  • spchain/init.c, spchain/spchain.doc, spchain/spchain.scn: New test cases.
Location:
testsuites/sptests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/ChangeLog

    r69f2a07 r469e71d  
     12010-08-24      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * spchain/init.c, spchain/spchain.doc, spchain/spchain.scn: New test
     4        cases.
     5
    162010-08-23      Sebastian Huber <sebastian.huber@embedded-brains.de>
    27
  • testsuites/sptests/spchain/init.c

    r69f2a07 r469e71d  
    1313#include <rtems/chain.h>
    1414
     15#define EVENT RTEMS_EVENT_13
     16#define TIMEOUT 1
     17
    1518typedef struct {
    1619  rtems_chain_node Node;
    1720  int              id;
    1821} test_node;
     22
     23static void test_chain_get_with_wait(void)
     24{
     25  rtems_status_code sc = RTEMS_SUCCESSFUL;
     26  rtems_chain_control chain;
     27  rtems_chain_node *p = (rtems_chain_node *) 1;
     28
     29  puts( "INIT - Verify rtems_chain_get_with_wait" );
     30  rtems_chain_initialize_empty( &chain );
     31  sc = rtems_chain_get_with_wait( &chain, EVENT, TIMEOUT, &p );
     32  rtems_test_assert( sc == RTEMS_TIMEOUT );
     33  rtems_test_assert( p == NULL );
     34}
     35
     36static void test_chain_with_notification(void)
     37{
     38  rtems_status_code sc = RTEMS_SUCCESSFUL;
     39  rtems_chain_control chain;
     40  rtems_chain_node a;
     41  rtems_chain_node *p = (rtems_chain_node *) 1;
     42  rtems_event_set out = 0;
     43
     44  puts( "INIT - Verify rtems_chain_append_with_notification" );
     45  rtems_chain_initialize_empty( &chain );
     46  sc = rtems_chain_append_with_notification( &chain, &a, rtems_task_self(), EVENT );
     47  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
     48  sc = rtems_chain_get_with_wait( &chain, EVENT, TIMEOUT, &p );
     49  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
     50  rtems_test_assert( p == &a );
     51
     52  puts( "INIT - Verify rtems_chain_prepend_with_notification" );
     53  rtems_chain_initialize_empty( &chain );
     54  sc = rtems_chain_prepend_with_notification( &chain, &a, rtems_task_self(), EVENT );
     55  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
     56  sc = rtems_chain_get_with_wait( &chain, EVENT, TIMEOUT, &p );
     57  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
     58  rtems_test_assert( p == &a );
     59
     60  puts( "INIT - Verify rtems_chain_get_with_notification" );
     61  rtems_chain_initialize_empty( &chain );
     62  rtems_chain_append( &chain, &a );
     63  sc = rtems_chain_get_with_notification( &chain, rtems_task_self(), EVENT, &p );
     64  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
     65  rtems_test_assert( p == &a );
     66  sc = rtems_event_receive(
     67    EVENT,
     68    RTEMS_EVENT_ALL | RTEMS_WAIT,
     69    TIMEOUT,
     70    &out
     71  );
     72  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
     73  rtems_test_assert( out == EVENT );
     74}
     75
     76static void test_chain_with_empty_check(void)
     77{
     78  rtems_chain_control chain;
     79  rtems_chain_node a;
     80  rtems_chain_node b;
     81  rtems_chain_node *p;
     82  bool empty;
     83
     84  puts( "INIT - Verify rtems_chain_append_with_empty_check" );
     85  rtems_chain_initialize_empty( &chain );
     86  empty = rtems_chain_append_with_empty_check( &chain, &a );
     87  rtems_test_assert( empty );
     88  empty = rtems_chain_append_with_empty_check( &chain, &a );
     89  rtems_test_assert( !empty );
     90
     91  puts( "INIT - Verify rtems_chain_prepend_with_empty_check" );
     92  rtems_chain_initialize_empty( &chain );
     93  empty = rtems_chain_prepend_with_empty_check( &chain, &a );
     94  rtems_test_assert( empty );
     95  empty = rtems_chain_prepend_with_empty_check( &chain, &a );
     96  rtems_test_assert( !empty );
     97
     98  puts( "INIT - Verify rtems_chain_get_with_empty_check" );
     99  rtems_chain_initialize_empty( &chain );
     100  rtems_chain_append( &chain, &a );
     101  rtems_chain_append( &chain, &b );
     102  empty = rtems_chain_get_with_empty_check( &chain, &p );
     103  rtems_test_assert( !empty );
     104  rtems_test_assert( p == &a );
     105  empty = rtems_chain_get_with_empty_check( &chain, &p );
     106  rtems_test_assert( empty );
     107  rtems_test_assert( p == &b );
     108}
    19109
    20110rtems_task Init(
     
    53143  }
    54144
     145  test_chain_with_empty_check();
     146  test_chain_with_notification();
     147  test_chain_get_with_wait();
     148
    55149  puts( "*** END OF RTEMS CHAIN API TEST ***" );
    56150  rtems_test_exit(0);
     
    60154
    61155#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
    62 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
     156#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
    63157
    64158#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
  • testsuites/sptests/spchain/spchain.scn

    r69f2a07 r469e71d  
    22Init - Initialize chain empty
    33INIT - Verify rtems_chain_insert
     4INIT - Verify rtems_chain_append_with_empty_check
     5INIT - Verify rtems_chain_prepend_with_empty_check
     6INIT - Verify rtems_chain_get_with_empty_check
     7INIT - Verify rtems_chain_append_with_notification
     8INIT - Verify rtems_chain_prepend_with_notification
     9INIT - Verify rtems_chain_get_with_notification
     10INIT - Verify rtems_chain_get_with_wait
    411*** END OF RTEMS CHAIN API TEST ***
Note: See TracChangeset for help on using the changeset viewer.