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"
24 #if defined (ACE_HAS_TSS_EMULATION)
33 Some_Object::Some_Object (void)
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
42 if (ACE_Thread::keycreate (&key
, 0) == 0)
44 ACE_Thread::setspecific (key
, this);
49 Some_Object::~Some_Object (void)
55 static Some_Object sobject
;
58 run_main (int, ACE_TCHAR
*[])
60 ACE_START_TEST (ACE_TEXT ("TSS_Static_Test"));
64 if (ACE_Thread::keycreate (&key
, 0) == 0)
67 if (ACE_Thread::getspecific (key
, &specific
) == 0)
71 ACE_DEBUG ((LM_DEBUG
, "Got back pointer: %x from key: %d. "
73 (size_t)specific
, key
));
78 ACE_ERROR ((LM_ERROR
, "Something (%x) was found in tss "
80 "Nothing should be stored in our "
82 (size_t)specific
, key
));
88 ACE_ERROR ((LM_ERROR
, "Unable to get the thread specific "
95 ACE_ERROR ((LM_ERROR
, "Unable to create the thread specific "
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")));
110 #endif /* ACE_HAS_TSS_EMULATION */