diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-07-07 14:16:55 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-07-07 14:16:55 +0000 |
commit | 4479b373d9cdb70724b3f7b7c7a345801c2104bf (patch) | |
tree | 3a7c3b2068f4355edbcd67b56fe6e22c553dabc5 /testsuites/sptests/spassoc01 | |
parent | 2010-07-07 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-4479b373d9cdb70724b3f7b7c7a345801c2104bf.tar.bz2 |
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.
Diffstat (limited to 'testsuites/sptests/spassoc01')
-rw-r--r-- | testsuites/sptests/spassoc01/.cvsignore | 2 | ||||
-rw-r--r-- | testsuites/sptests/spassoc01/Makefile.am | 24 | ||||
-rw-r--r-- | testsuites/sptests/spassoc01/init.c | 229 | ||||
-rw-r--r-- | testsuites/sptests/spassoc01/spassoc01.doc | 39 | ||||
-rw-r--r-- | testsuites/sptests/spassoc01/spassoc01.scn | 38 |
5 files changed, 332 insertions, 0 deletions
diff --git a/testsuites/sptests/spassoc01/.cvsignore b/testsuites/sptests/spassoc01/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/testsuites/sptests/spassoc01/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/testsuites/sptests/spassoc01/Makefile.am b/testsuites/sptests/spassoc01/Makefile.am new file mode 100644 index 0000000000..6228c3bab5 --- /dev/null +++ b/testsuites/sptests/spassoc01/Makefile.am @@ -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 diff --git a/testsuites/sptests/spassoc01/init.c b/testsuites/sptests/spassoc01/init.c new file mode 100644 index 0000000000..97f96b240a --- /dev/null +++ b/testsuites/sptests/spassoc01/init.c @@ -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 */ diff --git a/testsuites/sptests/spassoc01/spassoc01.doc b/testsuites/sptests/spassoc01/spassoc01.doc new file mode 100644 index 0000000000..587b8820f4 --- /dev/null +++ b/testsuites/sptests/spassoc01/spassoc01.doc @@ -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 diff --git a/testsuites/sptests/spassoc01/spassoc01.scn b/testsuites/sptests/spassoc01/spassoc01.scn new file mode 100644 index 0000000000..16d66061fd --- /dev/null +++ b/testsuites/sptests/spassoc01/spassoc01.scn @@ -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 *** |