[rtems commit] psxtests/psxcleanup02: New test

Sebastian Huber sebh at rtems.org
Tue Dec 15 07:22:27 UTC 2015


Module:    rtems
Branch:    master
Commit:    2b137eda3830eb2a47f5cabdc48c8e7b349a30d0
Changeset: http://git.rtems.org/rtems/commit/?id=2b137eda3830eb2a47f5cabdc48c8e7b349a30d0

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Dec 15 06:36:52 2015 +0100

psxtests/psxcleanup02: New test

---

 testsuites/psxtests/Makefile.am                   |  1 +
 testsuites/psxtests/configure.ac                  |  1 +
 testsuites/psxtests/psxcleanup02/Makefile.am      | 19 ++++++
 testsuites/psxtests/psxcleanup02/init.c           | 48 +++++++++++++++
 testsuites/psxtests/psxcleanup02/main.c           | 73 +++++++++++++++++++++++
 testsuites/psxtests/psxcleanup02/psxcleanup02.doc | 13 ++++
 testsuites/psxtests/psxcleanup02/psxcleanup02.scn |  4 ++
 7 files changed, 159 insertions(+)

diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index e734c6c..858ad42 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 78ae459..67ef83e 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 0000000..6df81d3
--- /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 at .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 0000000..88ecfee
--- /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 at 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 0000000..c5a3e95
--- /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 at 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 0000000..8fb0164
--- /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 0000000..a106fde
--- /dev/null
+++ b/testsuites/psxtests/psxcleanup02/psxcleanup02.scn
@@ -0,0 +1,4 @@
+*** BEGIN OF TEST PSXCLEANUP 2 ***
+cleanup
+destroy
+*** END OF TEST PSXCLEANUP 2 ***




More information about the vc mailing list