1*87d2adbcSAndrew Rist /**************************************************************
2*87d2adbcSAndrew Rist *
3*87d2adbcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*87d2adbcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*87d2adbcSAndrew Rist * distributed with this work for additional information
6*87d2adbcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*87d2adbcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*87d2adbcSAndrew Rist * "License"); you may not use this file except in compliance
9*87d2adbcSAndrew Rist * with the License. You may obtain a copy of the License at
10*87d2adbcSAndrew Rist *
11*87d2adbcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*87d2adbcSAndrew Rist *
13*87d2adbcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*87d2adbcSAndrew Rist * software distributed under the License is distributed on an
15*87d2adbcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*87d2adbcSAndrew Rist * KIND, either express or implied. See the License for the
17*87d2adbcSAndrew Rist * specific language governing permissions and limitations
18*87d2adbcSAndrew Rist * under the License.
19*87d2adbcSAndrew Rist *
20*87d2adbcSAndrew Rist *************************************************************/
21*87d2adbcSAndrew Rist
22*87d2adbcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include "precompiled_sal.hxx"
25cdf0e10cSrcweir #include "sal/config.h"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <cstdlib>
28cdf0e10cSrcweir #include <iostream>
29cdf0e10cSrcweir #include <limits>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include "boost/noncopyable.hpp"
32cdf0e10cSrcweir #include "cppunit/TestAssert.h"
33cdf0e10cSrcweir #include "cppunit/TestFixture.h"
34cdf0e10cSrcweir #include "cppunit/extensions/HelperMacros.h"
35cdf0e10cSrcweir #include "cppunit/plugin/TestPlugIn.h"
36cdf0e10cSrcweir #include "osl/thread.hxx"
37cdf0e10cSrcweir
38cdf0e10cSrcweir namespace {
39cdf0e10cSrcweir
40cdf0e10cSrcweir class TestThread: public osl::Thread, private boost::noncopyable {
41cdf0e10cSrcweir private:
42cdf0e10cSrcweir virtual void SAL_CALL run();
43cdf0e10cSrcweir };
44cdf0e10cSrcweir
run()45cdf0e10cSrcweir void TestThread::run() {
46cdf0e10cSrcweir #if defined WNT
47cdf0e10cSrcweir if (std::getenv("URE_TEST_SETTHREADNAME") != 0) {
48cdf0e10cSrcweir // On Windows, setting thread names appears to only take effect when the
49cdf0e10cSrcweir // process is being debugged, so attach a debugger now:
50cdf0e10cSrcweir std::cout << "set: ";
51cdf0e10cSrcweir std::cin.ignore(std::numeric_limits< int >::max(), '\n');
52cdf0e10cSrcweir }
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir setName("TestThread");
55cdf0e10cSrcweir if (std::getenv("URE_TEST_SETTHREADNAME") != 0) {
56cdf0e10cSrcweir // On Linux, the thread name can now be observed with "ps -L"; on
57cdf0e10cSrcweir // Windows with the Microsoft compiler, the thread name can now be
58cdf0e10cSrcweir // observed in a debugger.
59cdf0e10cSrcweir std::cout << "stop: ";
60cdf0e10cSrcweir std::cin.ignore(std::numeric_limits< int >::max(), '\n');
61cdf0e10cSrcweir }
62cdf0e10cSrcweir }
63cdf0e10cSrcweir
64cdf0e10cSrcweir class Test: public CppUnit::TestFixture {
65cdf0e10cSrcweir private:
66cdf0e10cSrcweir CPPUNIT_TEST_SUITE(Test);
67cdf0e10cSrcweir CPPUNIT_TEST(test);
68cdf0e10cSrcweir CPPUNIT_TEST_SUITE_END();
69cdf0e10cSrcweir
70cdf0e10cSrcweir void test();
71cdf0e10cSrcweir };
72cdf0e10cSrcweir
test()73cdf0e10cSrcweir void Test::test() {
74cdf0e10cSrcweir TestThread t;
75cdf0e10cSrcweir t.create();
76cdf0e10cSrcweir t.join();
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
79cdf0e10cSrcweir CPPUNIT_TEST_SUITE_REGISTRATION(Test);
80cdf0e10cSrcweir
81cdf0e10cSrcweir }
82cdf0e10cSrcweir
83cdf0e10cSrcweir CPPUNIT_PLUGIN_IMPLEMENT();
84