2 //=============================================================================
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"
19 #include "ace/Init_ACE.h"
20 #include "ace/Thread.h"
23 #if defined (ACE_HAS_TSS_EMULATION)
32 Some_Object::Some_Object ()
36 // Cause the ACE_Log_Msg to be constructed during static construction
37 ACE_DEBUG ((LM_DEBUG
, ""));
39 // Assign something to TSS during static construction
41 if (ACE_Thread::keycreate (&key
, 0) == 0)
43 ACE_Thread::setspecific (key
, this);
48 Some_Object::~Some_Object ()
54 static Some_Object sobject
;
57 run_main (int, ACE_TCHAR
*[])
59 ACE_START_TEST (ACE_TEXT ("TSS_Static_Test"));
63 if (ACE_Thread::keycreate (&key
, 0) == 0)
66 if (ACE_Thread::getspecific (key
, &specific
) == 0)
70 ACE_DEBUG ((LM_DEBUG
, "Got back pointer: %x from key: %d. "
72 (size_t)specific
, key
));
77 ACE_ERROR ((LM_ERROR
, "Something (%x) was found in tss "
79 "Nothing should be stored in our "
81 (size_t)specific
, key
));
87 ACE_ERROR ((LM_ERROR
, "Unable to get the thread specific "
94 ACE_ERROR ((LM_ERROR
, "Unable to create the thread specific "
102 run_main (int, ACE_TCHAR
*[])
104 ACE_START_TEST (ACE_TEXT ("TSS_Static_Test"));
105 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("This test requires TSS Emulation.\n")));
109 #endif /* ACE_HAS_TSS_EMULATION */