Changeset 611909e in rtems


Ignore:
Timestamp:
Aug 21, 2011, 8:07:23 PM (9 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, 5, master
Children:
7b58954
Parents:
74f1c73e
Message:

2011-08-21 Petr Benes <benesp16@…>

PR 1886/cpukit

  • sprbtree01/init.c, sprbtree01/sprbtree01.scn: This patch enables inserting duplicate keys into rbtree. It is possible to turn on this feature when initializing the tree.
Location:
testsuites/sptests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/ChangeLog

    r74f1c73e r611909e  
     12011-08-21      Petr Benes <benesp16@fel.cvut.cz>
     2
     3        PR 1886/cpukit
     4        * sprbtree01/init.c, sprbtree01/sprbtree01.scn: This patch enables
     5        inserting duplicate keys into rbtree. It is possible to turn on this
     6        feature when initializing the tree.
     7
    182011-08-18      Sebastian Huber <sebastian.huber@embedded-brains.de>
    29
  • testsuites/sptests/sprbtree01/init.c

    r74f1c73e r611909e  
    101101
    102102  puts( "Init - Initialize rbtree empty" );
    103   rtems_rbtree_initialize_empty( &rbtree1, &test_compare_function );
    104  
     103  rtems_rbtree_initialize_empty( &rbtree1, &test_compare_function,
     104                                 RTEMS_RBTREE_UNIQUE );
     105
     106  if ( !rtems_rbtree_is_unique( &rbtree1 ) )
     107    puts( "INIT - FAILED IS UNIQUE CHECK" );
     108  if ( rtems_rbtree_is_unique( NULL ) )
     109    puts( "INIT - FAILED IS UNIQUE CHECK" );
     110
    105111  /* verify that the rbtree insert work */
    106112  puts( "INIT - Verify rtems_rbtree_insert with two nodes" );
     
    112118  rtems_rbtree_insert( &rbtree1, &node2.Node );
    113119
    114   p = _RBTree_Insert_unprotected( &rbtree1, NULL );
     120  p = rtems_rbtree_insert( &rbtree1, NULL );
    115121  if (p != (void *)(-1))
    116122    puts( "INIT - FAILED NULL NODE INSERT" );
     
    150156  node2.key = node1.key;
    151157  rtems_rbtree_insert(&rbtree1, &node1.Node);
    152   rtems_rbtree_insert(&rbtree1, &node2.Node);
     158  p = rtems_rbtree_insert(&rbtree1, &node2.Node);
     159
     160  if (p != &node1.Node)
     161    puts( "INIT - FAILED DUPLICATE INSERT" );
     162
    153163  for ( p = rtems_rbtree_get_min(&rbtree1), id = 1 ; p ;
    154164      p = rtems_rbtree_get_min(&rbtree1) , id++ ) {
     
    528538  }
    529539  rtems_rbtree_initialize( &rbtree1, &test_compare_function,
    530                            &node_array[0].Node, 100, sizeof(test_node));
     540                           &node_array[0].Node, 100,
     541                           sizeof(test_node), RTEMS_RBTREE_UNIQUE );
    531542
    532543  puts( "INIT - Removing 100 nodes" );
     
    541552
    542553    if ( t->id != id ) {
     554      puts( "INIT - ERROR ON RBTREE ID MISMATCH" );
     555      rtems_test_exit(0);
     556    }
     557
     558    if (!rb_assert(rbtree1.root) )
     559      puts( "INIT - FAILED TREE CHECK" );
     560  }
     561
     562  if(!rtems_rbtree_is_empty(&rbtree1)) {
     563    puts( "INIT - TREE NOT EMPTY" );
     564    rtems_test_exit(0);
     565  }
     566
     567  /* Initialize the tree for duplicate keys */
     568  puts( "Init - Initialize duplicate rbtree empty" );
     569  rtems_rbtree_initialize_empty( &rbtree1, &test_compare_function,
     570                                 RTEMS_RBTREE_DUPLICATE );
     571
     572  if ( rtems_rbtree_is_unique( &rbtree1 ) )
     573    puts( "INIT - FAILED IS UNIQUE CHECK" );
     574  if ( rtems_rbtree_is_unique( NULL ) )
     575    puts( "INIT - FAILED IS UNIQUE CHECK" );
     576
     577  puts( "INIT - Verify rtems_rbtree_insert with 100 nodes value [0,99]" );
     578  for (i = 0; i < 100; i++) {
     579    node_array[i].id = i;
     580    node_array[i].key = i%5;
     581    rtems_rbtree_insert( &rbtree1, &node_array[i].Node );
     582
     583    if (!rb_assert(rbtree1.root) )
     584      puts( "INIT - FAILED TREE CHECK" );
     585  }
     586
     587  puts( "INIT - Verify rtems_rbtree_find in a duplicate tree" );
     588  search_node.key = 2;
     589  p = rtems_rbtree_find(&rbtree1, &search_node.Node);
     590  if(rtems_rbtree_container_of(p,test_node,Node)->id != 2) {
     591    puts ("INIT - ERROR ON RBTREE ID MISMATCH");
     592    rtems_test_exit(0);
     593  }
     594
     595  puts( "INIT - Removing 100 nodes" );
     596
     597  for ( p = rtems_rbtree_get_min(&rbtree1), id = 0 ; p ;
     598      p = rtems_rbtree_get_min(&rbtree1) , id++ ) {
     599    test_node *t = rtems_rbtree_container_of(p,test_node,Node);
     600    if ( id > 99 ) {
     601      puts( "INIT - TOO MANY NODES ON RBTREE" );
     602      rtems_test_exit(0);
     603    }
     604    if ( t->id != ( ((id*5)%100) + (id/20) ) ) {
     605      puts( "INIT - ERROR ON RBTREE ID MISMATCH" );
     606      rtems_test_exit(0);
     607    }
     608
     609    if (!rb_assert(rbtree1.root) )
     610      puts( "INIT - FAILED TREE CHECK" );
     611  }
     612
     613  if(!rtems_rbtree_is_empty(&rbtree1)) {
     614    puts( "INIT - TREE NOT EMPTY" );
     615    rtems_test_exit(0);
     616  }
     617
     618  puts( "INIT - Verify rtems_rbtree_insert with 100 nodes value [99,0]" );
     619  for (i = 0; i < 100; i++) {
     620    node_array[i].id = 99-i;
     621    node_array[i].key = (99-i)%5;
     622    rtems_rbtree_insert( &rbtree1, &node_array[i].Node );
     623
     624    if (!rb_assert(rbtree1.root) )
     625      puts( "INIT - FAILED TREE CHECK" );
     626  }
     627
     628  puts( "INIT - Verify rtems_rbtree_find in a duplicate tree" );
     629  search_node.key = 2;
     630  p = rtems_rbtree_find(&rbtree1, &search_node.Node);
     631  if(rtems_rbtree_container_of(p,test_node,Node)->id != 97) {
     632    puts ("INIT - ERROR ON RBTREE ID MISMATCH");
     633    rtems_test_exit(0);
     634  }
     635
     636  puts( "INIT - Removing 100 nodes" );
     637
     638  for ( p = rtems_rbtree_get_min(&rbtree1), id = 0 ; p ;
     639      p = rtems_rbtree_get_min(&rbtree1) , id++ ) {
     640    test_node *t = rtems_rbtree_container_of(p,test_node,Node);
     641    if ( id > 99 ) {
     642      puts( "INIT - TOO MANY NODES ON RBTREE" );
     643      rtems_test_exit(0);
     644    }
     645    if ( t->id != ( (((99-id)*5)%100) + (id/20) ) ) {
    543646      puts( "INIT - ERROR ON RBTREE ID MISMATCH" );
    544647      rtems_test_exit(0);
  • testsuites/sptests/sprbtree01/sprbtree01.scn

    r74f1c73e r611909e  
    2525INIT - Verify rtems_rbtree_initialize with 100 nodes value [0,99]
    2626INIT - Removing 100 nodes
     27Init - Initialize duplicate rbtree empty
     28INIT - Verify rtems_rbtree_insert with 100 nodes value [0,99]
     29INIT - Verify rtems_rbtree_find in a duplicate tree
     30INIT - Removing 100 nodes
     31INIT - Verify rtems_rbtree_insert with 100 nodes value [99,0]
     32INIT - Verify rtems_rbtree_find in a duplicate tree
     33INIT - Removing 100 nodes
    2734*** END OF RTEMS RBTREE API TEST ***
Note: See TracChangeset for help on using the changeset viewer.