2010-07-07 Bharath Suri <bharath.s.jois@gmail.com>

PR 1603/testing
	* spassoc01/init.c, spassoc01/Makefile.am,
	spassoc01/spassoc01.doc, spassoc01/spassoc01.scn: Added new test.
	* Makefile.am, configure.ac: Added new test spassoc01 for
	rtems_assoc routines.
This commit is contained in:
Joel Sherrill
2010-07-07 14:16:55 +00:00
parent 0b86fd8b6e
commit 4479b373d9
8 changed files with 344 additions and 2 deletions
+8
View File
@@ -1,3 +1,11 @@
2010-07-07 Bharath Suri <bharath.s.jois@gmail.com>
PR 1603/testing
* spassoc01/init.c, spassoc01/Makefile.am,
spassoc01/spassoc01.doc, spassoc01/spassoc01.scn: Added new test.
* Makefile.am, configure.ac: Added new test spassoc01 for
rtems_assoc routines.
2010-07-07 Joel Sherrill <joel.sherrill@oarcorp.com>
PR 1606/cpukit
+3 -2
View File
@@ -15,8 +15,9 @@ SUBDIRS = \
sp50 sp51 sp52 sp53 sp54 sp55 sp56 sp57 sp58 sp59 \
sp60 sp61 sp62 sp63 sp64 sp65 sp66 sp67 sp68 sp69 \
sp70 sp71 \
spchain spclockget spcoverage spobjgetnext spnotepad01 spprintk spsize \
spstkalloc spthreadq01 spwatchdog spwkspace \
spassoc01 spchain spclockget spcoverage spobjgetnext \
spnotepad01 spprintk spsize spstkalloc spthreadq01 \
spwatchdog spwkspace \
sperror01 sperror02 sperror03 \
spfatal01 spfatal02 spfatal03 spfatal04 spfatal05 spfatal06 spfatal07 \
spfatal08 spfatal10 spfatal11 spfatal12 spfatal13 spfatal14 \
+1
View File
@@ -97,6 +97,7 @@ sp68/Makefile
sp69/Makefile
sp70/Makefile
sp71/Makefile
spassoc01/Makefile
spchain/Makefile
spclockget/Makefile
spcoverage/Makefile
+2
View File
@@ -0,0 +1,2 @@
Makefile
Makefile.in
+24
View File
@@ -0,0 +1,24 @@
##
## $Id$
##
rtems_tests_PROGRAMS = spassoc01
spassoc01_SOURCES = init.c
dist_rtems_tests_DATA = spassoc01.scn
dist_rtems_tests_DATA += spassoc01.doc
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 = $(spassoc01_OBJECTS) $(spassoc01_LDADD)
LINK_LIBS = $(spassoc01_LDLIBS)
spassoc01$(EXEEXT): $(spassoc01_OBJECTS) $(spassoc01_DEPENDENCIES)
@rm -f spassoc01$(EXEEXT)
$(make-exe)
include $(top_srcdir)/../automake/local.am
+229
View File
@@ -0,0 +1,229 @@
/*
* COPYRIGHT (c) 1989-2010.
* 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.com/license/LICENSE.
*
* $Id$
*/
#include <tmacros.h>
#include "test_support.h"
#include <stdio.h>
#include <rtems/assoc.h>
const rtems_assoc_t assoc_table_null[] =
{
{ NULL , 0 , 0 },
{ "zero" , 1 , 8 },
{ "one" , 2 , 4 },
{ "two" , 4 , 2 },
{ "three" , 8 , 1 },
{ NULL , -1, -1 }
};
const rtems_assoc_t assoc_table_default[] =
{
{ "(default)", 0 , 0 },
{ "zero" , 1 , 8 },
{ "one" , 2 , 4 },
{ "two" , 4 , 2 },
{ "three" , 8 , 1 },
{ NULL , -1, -1 }
};
const rtems_assoc_t assoc_table[] =
{
{ "zero" , 1 , 8 },
{ "one" , 2 , 4 },
{ "two" , 4 , 2 },
{ "three", 8 , 1 },
{ NULL , -1, -1 }
};
uint32_t local;
uint32_t remote;
const rtems_assoc_t *assoc_item;
char *name;
static void reset_name( void )
{
memset( name, 0, 40 );
}
rtems_task Init(
rtems_task_argument argument
)
{
name = malloc(40);
puts( "\n\n*** TEST ASSOC ROUTINES - 1 ***" );
puts( "Init - get local by name -- OK" );
local = rtems_assoc_local_by_name( assoc_table, "zero" );
rtems_test_assert( local == 1 );
puts( "Init - get local by name -- expect 0" );
local = rtems_assoc_local_by_name( assoc_table, "four" );
rtems_test_assert( local == 0 );
puts( "Init - get local by remote bitfield -- OK" );
local = rtems_assoc_local_by_remote_bitfield( assoc_table, 1 );
rtems_test_assert( local == 8 );
puts( "Init - get local by remote bitfield -- expect 0" );
local = rtems_assoc_local_by_remote_bitfield( assoc_table, 0 );
rtems_test_assert( local == 0 );
puts( "Init - get local by remote -- OK" );
local = rtems_assoc_local_by_remote( assoc_table, 1 );
rtems_test_assert( local == 8 );
puts( "Init - get local by remote -- expect 0" );
local = rtems_assoc_local_by_remote( assoc_table, 0 );
rtems_test_assert( local == 0 );
reset_name();
puts( "Init - get name by local bitfield -- OK" );
name = rtems_assoc_name_by_local_bitfield( assoc_table, 1, name );
rtems_test_assert ( !strcmp( name, "zero" ) );
reset_name();
puts( "Init - get name by local bitfield -- OK" );
name = rtems_assoc_name_by_local_bitfield( assoc_table, 3, name );
rtems_test_assert ( !strcmp( name, "zero one" ) );
reset_name();
puts( "Init - get name by local bitfield -- expect\"\"" );
name = rtems_assoc_name_by_local_bitfield( assoc_table, 0, name );
rtems_test_assert ( !strcmp( name, "" ) );
reset_name();
puts( "Init - get name by local -- OK" );
rtems_test_assert( !strcmp( rtems_assoc_name_by_local( assoc_table, 1 ),
"zero" ) );
reset_name();
puts( "Init - get name by local -- using bad value" );
puts( rtems_assoc_name_by_local( assoc_table, 0 ) );
reset_name();
puts( "Init - get name by remote bitfield -- OK" );
name =
rtems_assoc_name_by_remote_bitfield( assoc_table, 1, name );
rtems_test_assert ( !strcmp( name, "three" ) );
reset_name();
puts( "Init - get name by remote bitfield -- OK" );
name =
rtems_assoc_name_by_remote_bitfield( assoc_table, 3, name );
rtems_test_assert ( !strcmp( name, "three two" ) );
reset_name();
puts( "Init - get name by remote bitfield -- expect\"\"" );
name =
rtems_assoc_name_by_remote_bitfield( assoc_table, 0, name );
rtems_test_assert ( !strcmp( name, "" ) );
reset_name();
puts( "Init - get name by remote -- OK" );
rtems_test_assert( !strcmp( rtems_assoc_name_by_remote( assoc_table, 1 ),
"three" ) );
reset_name();
puts( "Init - get name by remote -- using bad value" );
puts( rtems_assoc_name_by_remote( assoc_table, 0 ) );
puts( "Init - get ptr by local -- OK" );
assoc_item = rtems_assoc_ptr_by_local( assoc_table, 1 );
rtems_test_assert( assoc_item == assoc_table );
puts( "Init - get ptr by local -- expect NULL" );
assoc_item = rtems_assoc_ptr_by_local( assoc_table, 0 );
rtems_test_assert( assoc_item == 0 );
puts( "Init - get ptr by remote -- OK" );
assoc_item = rtems_assoc_ptr_by_remote( assoc_table, 8 );
rtems_test_assert( assoc_item == assoc_table );
puts( "Init - get ptr by remote -- expect NULL" );
assoc_item = rtems_assoc_ptr_by_remote( assoc_table, 0 );
rtems_test_assert( assoc_item == 0 );
puts( "Init - get ptr by name -- OK" );
assoc_item = rtems_assoc_ptr_by_name( assoc_table, "zero" );
rtems_test_assert( assoc_item == assoc_table );
puts( "Init - get ptr by name -- expect NULL" );
assoc_item = rtems_assoc_ptr_by_name( assoc_table, "six" );
rtems_test_assert( assoc_item == 0 );
puts( "Init - get remote by local bitfield -- OK" );
remote = rtems_assoc_remote_by_local_bitfield( assoc_table, 1 );
rtems_test_assert( remote == 8 );
puts( "Init - get remote by local bitfield -- expect 0" );
remote = rtems_assoc_remote_by_local_bitfield( assoc_table, 0 );
rtems_test_assert( remote == 0 );
puts( "Init - get remote by local -- OK" );
remote = rtems_assoc_remote_by_local( assoc_table, 1 );
rtems_test_assert( remote == 8 );
puts( "Init - get remote by local -- expect 0" );
remote = rtems_assoc_remote_by_local( assoc_table, 0 );
rtems_test_assert( remote == 0 );
puts( "Init - get remote by name -- OK" );
remote = rtems_assoc_remote_by_name( assoc_table, "zero" );
rtems_test_assert( remote == 8 );
puts( "Init - get remote by name -- expect 0" );
remote = rtems_assoc_remote_by_name( assoc_table, "six" );
rtems_test_assert( remote == 0 );
puts( "Init - get ptr by name -- expect (default)" );
assoc_item = rtems_assoc_ptr_by_name( assoc_table_default, "six" );
rtems_test_assert( assoc_item == assoc_table_default );
puts( "Init - get ptr by local -- expect (default)" );
assoc_item = rtems_assoc_ptr_by_local( assoc_table_default, 0 );
rtems_test_assert( assoc_item == assoc_table_default );
puts( "Init - get ptr by remote -- expect (default)" );
assoc_item = rtems_assoc_ptr_by_remote( assoc_table_default, 0 );
rtems_test_assert( assoc_item == assoc_table_default );
puts( "Init - get ptr by name -- expect NULL" );
assoc_item = rtems_assoc_ptr_by_name( assoc_table_null, "six" );
rtems_test_assert( assoc_item == 0 );
puts( "Init - get ptr by local -- expect NULL" );
assoc_item = rtems_assoc_ptr_by_local( assoc_table_null, 0 );
rtems_test_assert( assoc_item == 0 );
puts( "Init - get ptr by remote -- expect NULL" );
assoc_item = rtems_assoc_ptr_by_remote( assoc_table_null, 0 );
rtems_test_assert( assoc_item == 0 );
free( name );
puts( "*** END OF TEST ASSOC ROUTINES - 1 ***" );
rtems_test_exit(0);
}
/* configuration information */
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */
@@ -0,0 +1,39 @@
#
# $Id$
#
# COPYRIGHT (c) 1989-2010.
# 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.com/license/LICENSE.
#
This file describes the directives and concepts tested by this test set.
test set name: spassoc01
directives:
+ rtems_assoc_local_by_name
+ rtems_assoc_local_by_remote_bitfield
+ rtems_assoc_local_by_remote
+ rtems_assoc_name_by_local_bitfield
+ rtems_assoc_name_by_local
+ rtems_assoc_name_by_remote_bitfield
+ rtems_assoc_name_by_remote
+ rtems_assoc_name_bad
+ rtems_assoc_ptr_by_local
+ rtems_assoc_ptr_by_remote
+ rtems_assoc_ptr_by_name
+ rtems_assoc_remote_by_local_bitfield
+ rtems_assoc_remote_by_local
+ rtems_assoc_remote_by_name
concepts:
+ exercise the rtems_assoc* routines completely, including all the
possible branching
@@ -0,0 +1,38 @@
*** TEST ASSOC ROUTINES - 1 ***
Init - get local by name -- OK
Init - get local by name -- expect 0
Init - get local by remote bitfield -- OK
Init - get local by remote bitfield -- expect 0
Init - get local by remote -- OK
Init - get local by remote -- expect 0
Init - get name by local bitfield -- OK
Init - get name by local bitfield -- OK
Init - get name by local bitfield -- expect""
Init - get name by local -- OK
Init - get name by local -- using bad value
<assocnamebad.c: : BAD NAME>
Init - get name by remote bitfield -- OK
Init - get name by remote bitfield -- OK
Init - get name by remote bitfield -- expect""
Init - get name by remote -- OK
Init - get name by remote -- using bad value
<assocnamebad.c: : BAD NAME>
Init - get ptr by local -- OK
Init - get ptr by local -- expect NULL
Init - get ptr by remote -- OK
Init - get ptr by remote -- expect NULL
Init - get ptr by name -- OK
Init - get ptr by name -- expect NULL
Init - get remote by local bitfield -- OK
Init - get remote by local bitfield -- expect 0
Init - get remote by local -- OK
Init - get remote by local -- expect 0
Init - get remote by name -- OK
Init - get remote by name -- expect 0
Init - get ptr by name -- expect (default)
Init - get ptr by local -- expect (default)
Init - get ptr by remote -- expect (default)
Init - get ptr by name -- expect NULL
Init - get ptr by local -- expect NULL
Init - get ptr by remote -- expect NULL
*** END OF TEST ASSOC ROUTINES - 1 ***