From d6f65e40eaee24f67fdd26fbc64fad7b7271932d Mon Sep 17 00:00:00 2001 From: Bjorn Larsson Date: Wed, 26 Mar 2014 09:56:43 -0500 Subject: sptests: split sp09 screen 5,6 into spsem_err01, spsem_err02, and sptask_err01. sp09 screen 5 split into spsem_err01, sp09 screen 6 split into spsem_err02, and sptask_err01. --- testsuites/sptests/spsem_err02/Makefile.am | 22 ++++ testsuites/sptests/spsem_err02/init.c | 158 +++++++++++++++++++++++++ testsuites/sptests/spsem_err02/spsem_err02.doc | 25 ++++ testsuites/sptests/spsem_err02/spsem_err02.scn | 20 ++++ testsuites/sptests/spsem_err02/system.h | 54 +++++++++ testsuites/sptests/spsem_err02/task2.c | 48 ++++++++ 6 files changed, 327 insertions(+) create mode 100644 testsuites/sptests/spsem_err02/Makefile.am create mode 100644 testsuites/sptests/spsem_err02/init.c create mode 100644 testsuites/sptests/spsem_err02/spsem_err02.doc create mode 100644 testsuites/sptests/spsem_err02/spsem_err02.scn create mode 100644 testsuites/sptests/spsem_err02/system.h create mode 100644 testsuites/sptests/spsem_err02/task2.c (limited to 'testsuites/sptests/spsem_err02') diff --git a/testsuites/sptests/spsem_err02/Makefile.am b/testsuites/sptests/spsem_err02/Makefile.am new file mode 100644 index 0000000000..fc28cb84ca --- /dev/null +++ b/testsuites/sptests/spsem_err02/Makefile.am @@ -0,0 +1,22 @@ + +rtems_tests_PROGRAMS = spsem_err02 +spsem_err02_SOURCES = init.c task2.c system.h + +dist_rtems_tests_DATA = spsem_err02.scn +dist_rtems_tests_DATA += spsem_err02.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 = $(spsem_err02_OBJECTS) +LINK_LIBS = $(spsem_err02_LDLIBS) + +spsem_err02$(EXEEXT): $(spsem_err02_OBJECTS) $(spsem_err02_DEPENDENCIES) + @rm -f spsem_err02$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/sptests/spsem_err02/init.c b/testsuites/sptests/spsem_err02/init.c new file mode 100644 index 0000000000..bd76a72118 --- /dev/null +++ b/testsuites/sptests/spsem_err02/init.c @@ -0,0 +1,158 @@ +/* + * COPYRIGHT (c) 2014. + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#define CONFIGURE_INIT +#include "system.h" + +const char rtems_test_name[] = "SP SEMAPHORE ERROR 02"; + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + + TEST_BEGIN(); + + Semaphore_name[ 1 ] = rtems_build_name( 'S', 'M', '1', ' ' ); + Semaphore_name[ 2 ] = rtems_build_name( 'S', 'M', '2', ' ' ); + Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' ); + + status = rtems_task_create( + Task_name[ 2 ], + 1, + RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, + &Task_id[ 2 ] + ); + directive_failed( status, "rtems_task_create of TA2" ); + puts( "TA1 - rtems_task_create - TA2 created - RTEMS_SUCCESSFUL" ); + + puts( "TA1 - rtems_task_start - start TA2 - RTEMS_SUCCESSFUL" ); + status = rtems_task_start( Task_id[ 2 ], Task_2, 0 ); + directive_failed( status, "rtems_task_start of TA2" ); + + /* OK */ + status = rtems_semaphore_create( + Semaphore_name[ 1 ], + 1, + RTEMS_DEFAULT_ATTRIBUTES, + RTEMS_NO_PRIORITY, + &Semaphore_id[ 1 ] + ); + directive_failed( status, "rtems_semaphore_create" ); + puts( "TA1 - rtems_semaphore_create - 1 - RTEMS_SUCCESSFUL" ); + + status = rtems_semaphore_create( + Semaphore_name[ 2 ], + 1, + RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY, + RTEMS_NO_PRIORITY, + &Semaphore_id[ 2 ] + ); + directive_failed( status, "rtems_semaphore_create" ); + puts( "TA1 - rtems_semaphore_create - 2 - RTEMS_SUCCESSFUL" ); + + status = rtems_semaphore_obtain( + 100, + RTEMS_DEFAULT_OPTIONS, + RTEMS_NO_TIMEOUT + ); + fatal_directive_status( + status, + RTEMS_INVALID_ID, + "rtems_semaphore_obtain with illegal id" + ); + puts( "TA1 - rtems_semaphore_obtain - RTEMS_INVALID_ID" ); + + status = rtems_semaphore_obtain( + Semaphore_id[ 1 ], + RTEMS_DEFAULT_OPTIONS, + RTEMS_NO_TIMEOUT + ); + directive_failed( status, "rtems_semaphore_obtain successful" ); + puts( "TA1 - rtems_semaphore_obtain - got sem 1 - RTEMS_SUCCESSFUL" ); + + status = rtems_semaphore_obtain( + Semaphore_id[ 1 ], + RTEMS_NO_WAIT, + RTEMS_NO_TIMEOUT + ); + fatal_directive_status( + status, + RTEMS_UNSATISFIED, + "rtems_semaphore_obtain not available" + ); + puts( "TA1 - rtems_semaphore_obtain - RTEMS_UNSATISFIED" ); + + puts( "TA1 - rtems_semaphore_obtain - timeout in 3 seconds" ); + status = rtems_semaphore_obtain( + Semaphore_id[ 1 ], + RTEMS_DEFAULT_OPTIONS, + 3 * rtems_clock_get_ticks_per_second() + ); + fatal_directive_status( + status, + RTEMS_TIMEOUT, + "rtems_semaphore_obtain timeout" + ); + puts( "TA1 - rtems_semaphore_obtain - woke up with RTEMS_TIMEOUT" ); + + status = rtems_semaphore_release( Semaphore_id[ 2 ] ); + fatal_directive_status( + status, + RTEMS_NOT_OWNER_OF_RESOURCE, + "rtems_semaphore_release and not owner" + ); + puts( "TA1 - rtems_semaphore_release - RTEMS_NOT_OWNER_OF_RESOURCE" ); + + status = rtems_semaphore_release( 100 ); + fatal_directive_status( + status, + RTEMS_INVALID_ID, + "rtems_semaphore_release with illegal id" + ); + puts( "TA1 - rtems_semaphore_release - RTEMS_INVALID_ID" ); + + puts( "TA1 - rtems_task_wake_after - yield processor - RTEMS_SUCCESSFUL" ); + status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); + directive_failed( status, "rtems_task_wake_after (yield)" ); + + puts( "TA1 - rtems_semaphore_delete - delete sem 1 - RTEMS_SUCCESSFUL" ); + status = rtems_semaphore_delete( Semaphore_id[ 1 ] ); + directive_failed( status, "rtems_semaphore_delete of SM1" ); + + puts( "TA1 - rtems_semaphore_obtain - binary semaphore" ); + status = rtems_semaphore_obtain( + Semaphore_id[ 2 ], + RTEMS_DEFAULT_OPTIONS, + RTEMS_NO_TIMEOUT + ); + directive_failed( status, "rtems_semaphore_obtain"); + + puts( "TA1 - rtems_semaphore_delete - delete sem 2 - RTEMS_RESOURCE_IN_USE" ); + + status = rtems_semaphore_delete( Semaphore_id[ 2 ] ); + fatal_directive_status( + status, + RTEMS_RESOURCE_IN_USE, + "rtems_semaphore_delete of SM2" + ); + + puts( "TA1 - rtems_task_wake_after - yield processor - RTEMS_SUCCESSFUL" ); + status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); + directive_failed( status, "rtems_task_wake_after (yield)" ); + + TEST_END(); +} diff --git a/testsuites/sptests/spsem_err02/spsem_err02.doc b/testsuites/sptests/spsem_err02/spsem_err02.doc new file mode 100644 index 0000000000..b391479811 --- /dev/null +++ b/testsuites/sptests/spsem_err02/spsem_err02.doc @@ -0,0 +1,25 @@ +# COPYRIGHT (c) 1989-2014. +# 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: test9 + +directives: + sm_create, sm_obtain, sm_release, sm_delete + +concepts: + + a. Verifies all error codes returned by the executive in single + processor configurations. + + b. Verifies error conditions in the following kernel routines or macros: + _Ck_date_time, _Expired, _Q_submit, _Get_mnodes, _Get_node, + _Free_mem, _Get_mem, _Valid_block, _Set_tcb, _Set_resource, + _In_range, _On_boundary diff --git a/testsuites/sptests/spsem_err02/spsem_err02.scn b/testsuites/sptests/spsem_err02/spsem_err02.scn new file mode 100644 index 0000000000..56fa2e8290 --- /dev/null +++ b/testsuites/sptests/spsem_err02/spsem_err02.scn @@ -0,0 +1,20 @@ +*** TEST SEMAPHORE ERROR 02 *** +TA1 - rtems_task_create - TA2 created - RTEMS_SUCCESSFUL +TA1 - rtems_task_start - start TA2 - RTEMS_SUCCESSFUL +TA1 - rtems_semaphore_create - 1 - RTEMS_SUCCESSFUL +TA1 - rtems_semaphore_create - 2 - RTEMS_SUCCESSFUL +TA1 - rtems_semaphore_obtain - RTEMS_INVALID_ID +TA1 - rtems_semaphore_obtain - got sem 1 - RTEMS_SUCCESSFUL +TA1 - rtems_semaphore_obtain - RTEMS_UNSATISFIED +TA1 - rtems_semaphore_obtain - timeout in 3 seconds +TA2 - rtems_semaphore_obtain - sem 1 - RTEMS_WAIT FOREVER +TA1 - rtems_semaphore_obtain - woke up with RTEMS_TIMEOUT +TA1 - rtems_semaphore_release - RTEMS_NOT_OWNER_OF_RESOURCE +TA1 - rtems_semaphore_release - RTEMS_INVALID_ID +TA1 - rtems_task_wake_after - yield processor - RTEMS_SUCCESSFUL +TA1 - rtems_semaphore_delete - delete sem 1 - RTEMS_SUCCESSFUL +TA1 - rtems_semaphore_obtain - binary semaphore +TA1 - rtems_semaphore_delete - delete sem 2 - RTEMS_RESOURCE_IN_USE +TA1 - rtems_task_wake_after - yield processor - RTEMS_SUCCESSFUL +TA2 - rtems_semaphore_obtain - woke up with RTEMS_OBJECT_WAS_DELETED +*** END TEST SEMAPHORE ERROR 02 *** diff --git a/testsuites/sptests/spsem_err02/system.h b/testsuites/sptests/spsem_err02/system.h new file mode 100644 index 0000000000..cc48e74b61 --- /dev/null +++ b/testsuites/sptests/spsem_err02/system.h @@ -0,0 +1,54 @@ +/* + * This include file contains information that is included in every + * function in the test set. + */ + +/* + * COPYRIGHT (c) 1989-2014. + * 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. + */ + +#include + +/* functions */ + +rtems_task Init( + rtems_task_argument argument +); + +rtems_task Task_2( + rtems_task_argument argument +); + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS 10 +#define CONFIGURE_MAXIMUM_TIMERS 1 +#define CONFIGURE_MAXIMUM_SEMAPHORES 2 +#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1 +#define CONFIGURE_MAXIMUM_PERIODS 1 +#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 0 +#define CONFIGURE_TICKS_PER_TIMESLICE 100 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_EXTRA_TASK_STACKS (20 * RTEMS_MINIMUM_STACK_SIZE) + +#include + +/* global variables */ + +TEST_EXTERN rtems_id Task_id[ 11 ]; /* array of task ids */ +TEST_EXTERN rtems_name Task_name[ 11 ]; /* array of task names */ + +TEST_EXTERN rtems_name Semaphore_name[ 4 ]; /* array of semaphore names */ +TEST_EXTERN rtems_id Semaphore_id[ 4 ]; /* array of semaphore ids */ + +/* end of include file */ diff --git a/testsuites/sptests/spsem_err02/task2.c b/testsuites/sptests/spsem_err02/task2.c new file mode 100644 index 0000000000..e415acf2f6 --- /dev/null +++ b/testsuites/sptests/spsem_err02/task2.c @@ -0,0 +1,48 @@ +/* Task_2 + * + * This routine serves as a test task. Its only purpose is to generate the + * error where a semaphore is deleted while a task is waiting for it. + * + * Input parameters: + * argument - task argument + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989-1999. + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "system.h" + +rtems_task Task_2( + rtems_task_argument argument +) +{ + rtems_status_code status; + + puts( "TA2 - rtems_semaphore_obtain - sem 1 - RTEMS_WAIT FOREVER" ); + status = rtems_semaphore_obtain( + Semaphore_id[ 1 ], + RTEMS_DEFAULT_OPTIONS, + RTEMS_NO_TIMEOUT + ); + fatal_directive_status( + status, + RTEMS_OBJECT_WAS_DELETED, + "rtems_semaphore_obtain waiting to be deleted" + ); + puts( + "TA2 - rtems_semaphore_obtain - woke up with RTEMS_OBJECT_WAS_DELETED" + ); + + status = rtems_task_delete( RTEMS_SELF ); + directive_failed( status, "rtems_task_delete of TA2" ); +} -- cgit v1.2.3