source: rtems/testsuites/psxtmtests/psxtmkey02/init.c @ fd46711

4.11
Last change on this file since fd46711 was fd46711, checked in by bjorn larsson <bjornlarsson@…>, on Mar 21, 2014 at 8:35:26 PM

psxtmtests: Add test.h support

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2013.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http:www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <timesys.h>
15#include <rtems/timerdrv.h>
16#include <errno.h>
17#include <pthread.h>
18#include "test_support.h"
19
20const char rtems_test_name[] = "PSXTMKEY 02";
21
22/* forward declarations to avoid warnings */
23void *POSIX_Init(void *argument);
24void benchmark_pthread_setspecific(void *value_p);
25void benchmark_pthread_getspecific( void *expected );
26
27pthread_key_t Key;
28int           Value1;
29
30void benchmark_pthread_setspecific( void *value_p )
31{
32  benchmark_timer_t end_time;
33  int  status;
34
35  benchmark_timer_initialize();
36    status = pthread_setspecific( Key, value_p );
37  end_time = benchmark_timer_read();
38  rtems_test_assert( status == 0 );
39
40  put_time(
41    "pthread_setspecific: only case: only case",
42    end_time,
43    1,        /* Only executed once */
44    0,
45    0
46  );
47
48}
49
50void benchmark_pthread_getspecific( void *expected )
51{
52  benchmark_timer_t end_time;
53  void *value_p;
54
55  benchmark_timer_initialize();
56    value_p = pthread_getspecific( Key );
57  end_time = benchmark_timer_read();
58  rtems_test_assert( value_p == expected );
59
60  put_time(
61    "pthread_getspecific: only case",
62    end_time,
63    1,        /* Only executed once */
64    0,
65    0
66  );
67}
68
69void *POSIX_Init(
70  void *argument
71)
72{
73  int  status;
74
75  TEST_BEGIN();
76
77  /* create the key */
78  status = pthread_key_create( &Key, NULL );
79  rtems_test_assert( status == 0 );
80
81  benchmark_pthread_getspecific( NULL );
82  benchmark_pthread_setspecific( &Value1 );
83  benchmark_pthread_getspecific( &Value1 );
84
85  /* destroy the key */
86  status = pthread_key_delete( Key );
87  rtems_test_assert( status == 0 );
88
89  TEST_END();
90  rtems_test_exit(0);
91}
92
93/* configuration information */
94
95#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
96#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
97
98#define CONFIGURE_MAXIMUM_POSIX_THREADS  2
99#define CONFIGURE_MAXIMUM_POSIX_KEYS     1
100#define CONFIGURE_POSIX_INIT_THREAD_TABLE
101
102#define CONFIGURE_INIT
103#include <rtems/confdefs.h>
104/* end of file */
Note: See TracBrowser for help on using the repository browser.