summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxkey01
diff options
context:
space:
mode:
authorJennifer Averett <Jennifer.Averett@OARcorp.com>2008-02-04 19:39:43 +0000
committerJennifer Averett <Jennifer.Averett@OARcorp.com>2008-02-04 19:39:43 +0000
commitf8d39b8dcd3cec1893ff9edd216eddff08f9b752 (patch)
tree32a540afb484b4bb471a60ea2a52be3ad76282f6 /testsuites/psxtests/psxkey01
parent2008-02-04 Jennifer Averett <jennifer.averett@OARcorp.com> (diff)
downloadrtems-f8d39b8dcd3cec1893ff9edd216eddff08f9b752.tar.bz2
2008-02-04 Jennifer Averett <jennifer.averett@OARcorp.com>
* Makefile.am, configure.ac, psxmsgq01/Makefile.am, psxmsgq01/init.c: Added tests for failure path coverages. Consolidated methods used in multiple places into support routines. * psxkey01/Makefile.am, psxkey01/init.c, psxkey01/psxkey01.scn, psxkey01/system.h, psxkey01/task.c, psxmsgq02/Makefile.am, psxmsgq02/init.c, psxmsgq02/psxmsgq02.scn, psxmsgq02/system.h: New files.
Diffstat (limited to 'testsuites/psxtests/psxkey01')
-rw-r--r--testsuites/psxtests/psxkey01/Makefile.am30
-rw-r--r--testsuites/psxtests/psxkey01/init.c60
-rw-r--r--testsuites/psxtests/psxkey01/psxkey01.scn5
-rw-r--r--testsuites/psxtests/psxkey01/system.h55
-rw-r--r--testsuites/psxtests/psxkey01/task.c52
5 files changed, 202 insertions, 0 deletions
diff --git a/testsuites/psxtests/psxkey01/Makefile.am b/testsuites/psxtests/psxkey01/Makefile.am
new file mode 100644
index 0000000000..6abd282e29
--- /dev/null
+++ b/testsuites/psxtests/psxkey01/Makefile.am
@@ -0,0 +1,30 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxkey01.exe
+psxkey01_exe_SOURCES = init.c task.c system.h ../include/pmacros.h \
+ ../../support/src/test_support.c
+
+
+dist_rtems_tests_DATA = psxkey01.scn
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+psxkey01_exe_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
+AM_CPPFLAGS += -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(psxkey01_exe_OBJECTS) $(psxkey01_exe_LDADD)
+LINK_LIBS = $(psxkey01_exe_LDLIBS)
+
+psxkey01.exe$(EXEEXT): $(psxkey01_exe_OBJECTS) $(psxkey01_exe_DEPENDENCIES)
+ @rm -f psxkey01.exe$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxkey01/init.c b/testsuites/psxtests/psxkey01/init.c
new file mode 100644
index 0000000000..278e4b6029
--- /dev/null
+++ b/testsuites/psxtests/psxkey01/init.c
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ *
+ * $Id$
+ */
+
+#define CONFIGURE_INIT
+#include "system.h"
+#include <errno.h>
+#include "tmacros.h"
+#include <rtems/score/wkspace.h>
+#include <rtems/score/heap.h>
+
+
+void Key_destructor(
+ void *key_data
+)
+{
+}
+
+
+void *POSIX_Init(
+ void *argument
+)
+{
+ int status;
+ unsigned int remaining;
+ uint32_t *key_data;
+ Heap_Information_block info;
+ void *temp;
+ int i;
+
+ puts( "\n\n*** POSIX KEY 01 TEST ***" );
+
+ /* set the time of day, and print our buffer in multiple ways */
+
+ set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
+
+ /* get id of this thread */
+
+ Init_id = pthread_self();
+ printf( "Init's ID is 0x%08x\n", Init_id );
+
+ Allocate_majority_of_workspace(84);
+
+ puts("Init: pthread_key_create - ENOMEM (Workspace not available)");
+ empty_line();
+ status = pthread_key_create( &Key_id[0], Key_destructor );
+ fatal_directive_check_status_only( status, ENOMEM, "no workspace available" );
+
+ puts( "*** END OF POSIX KEY 01 TEST ***" );
+ rtems_test_exit( 0 );
+
+ return NULL; /* just so the compiler thinks we returned something */
+}
diff --git a/testsuites/psxtests/psxkey01/psxkey01.scn b/testsuites/psxtests/psxkey01/psxkey01.scn
new file mode 100644
index 0000000000..597b0f8e23
--- /dev/null
+++ b/testsuites/psxtests/psxkey01/psxkey01.scn
@@ -0,0 +1,5 @@
+*** POSIX KEY 01 TEST ***
+Init's ID is 0x0b010001
+Allocate_majority_of_workspace:
+Init: pthread_key_create - ENOMEM (Workspace not available)
+*** END OF POSIX KEY 01 TEST ***
diff --git a/testsuites/psxtests/psxkey01/system.h b/testsuites/psxtests/psxkey01/system.h
new file mode 100644
index 0000000000..280e4a71a0
--- /dev/null
+++ b/testsuites/psxtests/psxkey01/system.h
@@ -0,0 +1,55 @@
+/* system.h
+ *
+ * This include file contains information that is included in every
+ * function in the test set.
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+/* functions */
+
+#include <pmacros.h>
+
+void *POSIX_Init(
+ void *argument
+);
+
+void *Task_1(
+ void *argument
+);
+
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 21
+#define CONFIGURE_MAXIMUM_POSIX_KEYS 21
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#include <rtems/confdefs.h>
+
+/* global variables */
+
+#ifdef CONFIGURE_INIT
+#define TEST_EXTERN
+#else
+#define TEST_EXTERN extern
+#endif
+
+TEST_EXTERN pthread_t Init_id;
+TEST_EXTERN pthread_t Task_id[CONFIGURE_MAXIMUM_POSIX_THREADS-1];
+TEST_EXTERN pthread_key_t Key_id[CONFIGURE_MAXIMUM_POSIX_KEYS-1];
+TEST_EXTERN uint32_t Data_array[ CONFIGURE_MAXIMUM_POSIX_THREADS ];
+
+#undef TEST_EXTERN
+/* end of include file */
diff --git a/testsuites/psxtests/psxkey01/task.c b/testsuites/psxtests/psxkey01/task.c
new file mode 100644
index 0000000000..13ac9b2f85
--- /dev/null
+++ b/testsuites/psxtests/psxkey01/task.c
@@ -0,0 +1,52 @@
+/* Task_1
+ *
+ * This routine serves as a test task. It verifies the basic task
+ * switching capabilities of the executive.
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+#include "system.h"
+#include <errno.h>
+
+void *Task_1(
+ void *arg
+)
+{
+ pthread_t id = *(pthread_t *) arg;
+ int status;
+ uint32_t *key_data;
+
+ printf( "Thread 0x%08x\n", id );
+ printf( "Task_1: Setting the key to %d\n", 1 );
+ status = pthread_setspecific( Key_id, &Data_array[ 1 ] );
+ if ( status )
+ printf( "status = %d\n", status );
+ assert( !status );
+
+ key_data = pthread_getspecific( Key_id );
+ printf( "Task_1: Got the key value of %ld\n",
+ (unsigned long) ((uint32_t *)key_data - Data_array) );
+ if ( status )
+ printf( "status = %d\n", status );
+ assert( !status );
+
+ puts( "Task_1: exitting" );
+ pthread_exit( NULL );
+
+ /* switch to task 2 */
+
+ return NULL; /* just so the compiler thinks we returned something */
+}