Doxygen changes
[ACE_TAO.git] / ACE / tests / TSS_Static_Test.cpp
blob8a3aef6f659f524cd500d2187891be478913f329
2 //=============================================================================
3 /**
4 * @file TSS_Static_Test.cpp
6 * This program tests the interaction between TSS and thread keys
7 * created during static construction. VxWorks static construction
8 * is quite broken. This test is designed to test changes to work
9 * around a bug in the VxWorks loader that constructs static objects
10 * multiple times. It sounds hard to believe, but I've seen it!
12 * @author Chad Elliott <elliott_c@ociweb.com>
14 //=============================================================================
17 #include "test_config.h"
18 #include "ace/ACE.h"
19 #include "ace/Init_ACE.h"
20 #include "ace/Thread.h"
24 #if defined (ACE_HAS_TSS_EMULATION)
26 class Some_Object
28 public:
29 Some_Object (void);
30 ~Some_Object (void);
33 Some_Object::Some_Object (void)
35 ACE::init ();
37 // Cause the ACE_Log_Msg to be constructed during static construction
38 ACE_DEBUG ((LM_DEBUG, ""));
40 // Assign something to TSS during static construction
41 ACE_thread_key_t key;
42 if (ACE_Thread::keycreate (&key, 0) == 0)
44 ACE_Thread::setspecific (key, this);
49 Some_Object::~Some_Object (void)
51 ACE::fini ();
55 static Some_Object sobject;
57 int
58 run_main (int, ACE_TCHAR *[])
60 ACE_START_TEST (ACE_TEXT ("TSS_Static_Test"));
62 int status = 0;
63 ACE_thread_key_t key;
64 if (ACE_Thread::keycreate (&key, 0) == 0)
66 void* specific = 0;
67 if (ACE_Thread::getspecific (key, &specific) == 0)
69 if (specific == 0)
71 ACE_DEBUG ((LM_DEBUG, "Got back pointer: %x from key: %d. "
72 "Good!\n",
73 (size_t)specific, key));
75 else
77 ++status;
78 ACE_ERROR ((LM_ERROR, "Something (%x) was found in tss "
79 "slot %d.\n"
80 "Nothing should be stored in our "
81 "TSS slot!\n",
82 (size_t)specific, key));
85 else
87 ++status;
88 ACE_ERROR ((LM_ERROR, "Unable to get the thread specific "
89 "storage.\n"));
92 else
94 ++status;
95 ACE_ERROR ((LM_ERROR, "Unable to create the thread specific "
96 "storage key.\n"));
98 ACE_END_TEST;
99 return status;
101 #else
103 run_main (int, ACE_TCHAR *[])
105 ACE_START_TEST (ACE_TEXT ("TSS_Static_Test"));
106 ACE_DEBUG ((LM_INFO, ACE_TEXT ("This test requires TSS Emulation.\n")));
107 ACE_END_TEST;
108 return 0;
110 #endif /* ACE_HAS_TSS_EMULATION */