summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtmtests/psxtmkey02/init.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-07-19 13:04:20 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-07-19 13:04:20 +0000
commit43469aff7c49b1ecd8cae2e78f32287152e749eb (patch)
treeb0830790dd9ea53e4685fc304d0342a18f9ca6b3 /testsuites/psxtmtests/psxtmkey02/init.c
parent2011-07-19 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff)
downloadrtems-43469aff7c49b1ecd8cae2e78f32287152e749eb.tar.bz2
2011-07-19 Ricardo Aguirre <el.mastin@ymail.com>
PR 1840/tests * Makefile.am, configure.ac, psxtmtests_plan.csv: Add benchmark of key set and get. * psxtmkey02/.cvsignore, psxtmkey02/Makefile.am, psxtmkey02/init.c, psxtmkey02/psxtmkey02.doc: New files.
Diffstat (limited to 'testsuites/psxtmtests/psxtmkey02/init.c')
-rw-r--r--testsuites/psxtmtests/psxtmkey02/init.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/testsuites/psxtmtests/psxtmkey02/init.c b/testsuites/psxtmtests/psxtmkey02/init.c
new file mode 100644
index 0000000000..fb6c27778d
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmkey02/init.c
@@ -0,0 +1,99 @@
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * 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$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <timesys.h>
+#include <rtems/timerdrv.h>
+#include <errno.h>
+#include <pthread.h>
+#include "test_support.h"
+
+pthread_key_t Key;
+int Value1;
+
+void benchmark_pthread_setspecific( void *value_p )
+{
+ long end_time;
+ int status;
+
+ benchmark_timer_initialize();
+ status = pthread_setspecific( Key, value_p );
+ end_time = benchmark_timer_read();
+ rtems_test_assert( status == 0 );
+
+ put_time(
+ "pthread_setspecific",
+ end_time,
+ 1, /* Only executed once */
+ 0,
+ 0
+ );
+
+}
+
+void benchmark_pthread_getspecific( void *expected )
+{
+ long end_time;
+ void *value_p;
+
+ benchmark_timer_initialize();
+ value_p = pthread_getspecific( Key );
+ end_time = benchmark_timer_read();
+ rtems_test_assert( value_p == expected );
+
+ put_time(
+ "pthread_getspecific",
+ end_time,
+ 1, /* Only executed once */
+ 0,
+ 0
+ );
+}
+
+void *POSIX_Init(
+ void *argument
+)
+{
+ int status;
+
+ puts( "\n\n*** POSIX TIME TEST PSXTMKEY02 ***" );
+
+ /* create the key */
+ status = pthread_key_create( &Key, NULL );
+ rtems_test_assert( status == 0 );
+
+ benchmark_pthread_getspecific( NULL );
+ benchmark_pthread_setspecific( &Value1 );
+ benchmark_pthread_getspecific( &Value1 );
+
+ /* destroy the key */
+ status = pthread_key_delete( Key );
+ rtems_test_assert( status == 0 );
+
+ puts( "*** END OF POSIX TIME TEST PSXTMKEY02 ***" );
+ rtems_test_exit(0);
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
+#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+/* end of file */