summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-12-15 06:36:52 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-12-15 08:21:42 +0100
commit2b137eda3830eb2a47f5cabdc48c8e7b349a30d0 (patch)
treee36bdae1c1d3982f238963d9803af7338884af06
parentlibmisc: Include missing header file, fix warnings (diff)
downloadrtems-2b137eda3830eb2a47f5cabdc48c8e7b349a30d0.tar.bz2
psxtests/psxcleanup02: New test
-rw-r--r--testsuites/psxtests/Makefile.am1
-rw-r--r--testsuites/psxtests/configure.ac1
-rw-r--r--testsuites/psxtests/psxcleanup02/Makefile.am19
-rw-r--r--testsuites/psxtests/psxcleanup02/init.c48
-rw-r--r--testsuites/psxtests/psxcleanup02/main.c73
-rw-r--r--testsuites/psxtests/psxcleanup02/psxcleanup02.doc13
-rw-r--r--testsuites/psxtests/psxcleanup02/psxcleanup02.scn4
7 files changed, 159 insertions, 0 deletions
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index e734c6c0b1..858ad42a57 100644
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -1,6 +1,7 @@
ACLOCAL_AMFLAGS = -I ../aclocal
_SUBDIRS = psxclock
+_SUBDIRS += psxcleanup02
if HAS_POSIX
_SUBDIRS += psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \
psx10 psx11 psx12 psx13 psx14 psx15 psx16 \
diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
index 78ae4593d0..67ef83e302 100644
--- a/testsuites/psxtests/configure.ac
+++ b/testsuites/psxtests/configure.ac
@@ -140,6 +140,7 @@ psxchroot01/Makefile
psxclassic01/Makefile
psxcleanup/Makefile
psxcleanup01/Makefile
+psxcleanup02/Makefile
psxclock/Makefile
psxclock01/Makefile
psxcond01/Makefile
diff --git a/testsuites/psxtests/psxcleanup02/Makefile.am b/testsuites/psxtests/psxcleanup02/Makefile.am
new file mode 100644
index 0000000000..6df81d332b
--- /dev/null
+++ b/testsuites/psxtests/psxcleanup02/Makefile.am
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = psxcleanup02
+psxcleanup02_SOURCES = init.c main.c
+
+dist_rtems_tests_DATA = psxcleanup02.scn psxcleanup02.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 = $(psxcleanup02_OBJECTS)
+LINK_LIBS = $(psxcleanup02_LDLIBS)
+
+psxcleanup02$(EXEEXT): $(psxcleanup02_OBJECTS) $(psxcleanup02_DEPENDENCIES)
+ @rm -f psxcleanup02$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxcleanup02/init.c b/testsuites/psxtests/psxcleanup02/init.c
new file mode 100644
index 0000000000..88ecfee47e
--- /dev/null
+++ b/testsuites/psxtests/psxcleanup02/init.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * 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 "tmacros.h"
+
+int main(int argc, char **argv);
+
+const char rtems_test_name[] = "PSXCLEANUP 2";
+
+static void *POSIX_Init(void *arg)
+{
+ TEST_BEGIN();
+
+ main(0, NULL);
+
+ TEST_END();
+ rtems_test_exit(0);
+}
+
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
+#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
+#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 1
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/psxtests/psxcleanup02/main.c b/testsuites/psxtests/psxcleanup02/main.c
new file mode 100644
index 0000000000..c5a3e9502f
--- /dev/null
+++ b/testsuites/psxtests/psxcleanup02/main.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * 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 <assert.h>
+#include <stdio.h>
+#include <pthread.h>
+
+static int step;
+
+static void destroy(void *arg)
+{
+ assert(step == 2);
+ step = 3;
+ printf("destroy\n");
+}
+
+static void cleanup(void *arg)
+{
+ assert(step == 1);
+ step = 2;
+ printf("cleanup\n");
+}
+
+static void *task(void *arg)
+{
+ pthread_key_t key;
+ int eno;
+
+ eno = pthread_key_create(&key, destroy);
+ assert(eno == 0);
+
+ pthread_cleanup_push(cleanup, NULL);
+
+ eno = pthread_setspecific(key, &key);
+ assert(eno == 0);
+
+ assert(step == 0);
+ step = 1;
+
+ pthread_exit(NULL);
+ pthread_cleanup_pop(0);
+
+ return NULL;
+}
+
+int main(int argc, char **argv)
+{
+ pthread_t t;
+ int eno;
+
+ eno = pthread_create(&t, NULL, task, NULL);
+ assert(eno == 0);
+
+ eno = pthread_join(t, NULL);
+ assert(eno == 0);
+
+ return 0;
+}
diff --git a/testsuites/psxtests/psxcleanup02/psxcleanup02.doc b/testsuites/psxtests/psxcleanup02/psxcleanup02.doc
new file mode 100644
index 0000000000..8fb016485a
--- /dev/null
+++ b/testsuites/psxtests/psxcleanup02/psxcleanup02.doc
@@ -0,0 +1,13 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: psxcleanup02
+
+directives:
+
+ - pthread_key_create()
+ - pthread_cleanup_push()
+
+concepts:
+
+ - Ensures that the POSIX cleanup handler are called before the POSIX key
+ destructors.
diff --git a/testsuites/psxtests/psxcleanup02/psxcleanup02.scn b/testsuites/psxtests/psxcleanup02/psxcleanup02.scn
new file mode 100644
index 0000000000..a106fdec85
--- /dev/null
+++ b/testsuites/psxtests/psxcleanup02/psxcleanup02.scn
@@ -0,0 +1,4 @@
+*** BEGIN OF TEST PSXCLEANUP 2 ***
+cleanup
+destroy
+*** END OF TEST PSXCLEANUP 2 ***