diff options
author | Wilhelm Pflueger <Wilhelm.Pflueger@web.de> | 2011-02-20 01:57:37 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-02-22 12:48:27 +0000 |
commit | c6d9c4fe83c98bf9d5ce7cb2a192316302f13e7c (patch) | |
tree | a33ffe024bda5aea835b440b3ae4675d9344e839 /sal/qa/osl/process/osl_Thread.cxx | |
parent | 84999a62ff2e240f4e44184d83e147d42e645b6c (diff) |
EasyHacks: Re-animate tests in sal/qa/osl
Some tests in osl_process are not running:
a) the batch file for the batch test is not copied to the
execution path
b) osl_execProc_exe_name_in_argument_list() throws an assertion.
Diffstat (limited to 'sal/qa/osl/process/osl_Thread.cxx')
-rw-r--r-- | sal/qa/osl/process/osl_Thread.cxx | 104 |
1 files changed, 55 insertions, 49 deletions
diff --git a/sal/qa/osl/process/osl_Thread.cxx b/sal/qa/osl/process/osl_Thread.cxx index 70f64b201629..90879785394b 100644 --- a/sal/qa/osl/process/osl_Thread.cxx +++ b/sal/qa/osl/process/osl_Thread.cxx @@ -42,7 +42,13 @@ #include <osl/mutex.hxx> #include <osl/time.h> -#include <testshl/simpleheader.hxx> +#include <string.h> + +#include <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/plugin/TestPlugIn.h> + +#define t_print printf using namespace osl; using namespace rtl; @@ -89,7 +95,7 @@ void StopWatch::start() m_bIsValid = false; m_bIsRunning = true; osl_getSystemTime( &t1 ); - t_print("# %d %d nsecs\n", t1.Seconds, t1.Nanosec); + t_print("# %u %u nsecs\n", (unsigned)t1.Seconds, (unsigned)t1.Nanosec); // gettimeofday(&t1, 0); } @@ -100,7 +106,7 @@ void StopWatch::stop() // gettimeofday(&t2, 0); // Timer ausfragen osl_getSystemTime( &t2 ); - t_print("# %d %d nsecs\n", t2.Seconds, t2.Nanosec); + t_print("# %u %u nsecs\n", (unsigned) t2.Seconds, (unsigned) t2.Nanosec); if (m_bIsRunning) { // check ob gestartet. @@ -120,7 +126,7 @@ void StopWatch::stop() m_nNanoSec = 1000000000 + static_cast<sal_Int32>(t2.Nanosec) - static_cast<sal_Int32>(t1.Nanosec); m_nSeconds -= 1; } - t_print("# %d %d nsecs\n", m_nSeconds, m_nNanoSec ); + t_print("# %u %u nsecs\n", (unsigned) m_nSeconds, (unsigned) m_nNanoSec ); //if (m_nNanoSec < 0) //{ //m_nNanoSec += 1000000000; @@ -290,7 +296,7 @@ public: OCountThread() { m_nWaitSec = 0; - t_print("new OCountThread thread %d!\n", getIdentifier()); + t_print("new OCountThread thread %u!\n", (unsigned) getIdentifier()); } sal_Int32 getValue() { return m_aFlag.getValue(); } @@ -336,7 +342,7 @@ protected: } void SAL_CALL onTerminated() { - t_print("normally terminate this thread %d!\n", getIdentifier()); + t_print("normally terminate this thread %u!\n", (unsigned) getIdentifier()); } public: @@ -431,12 +437,12 @@ protected: } void SAL_CALL onTerminated() { - t_print("normally terminate this thread %d!\n", getIdentifier()); + t_print("normally terminate this thread %u!\n", (unsigned) getIdentifier()); } public: ONoScheduleThread() { - t_print("new thread id %d!\n", getIdentifier()); + t_print("new thread id %u!\n", (unsigned) getIdentifier()); } ~ONoScheduleThread() { @@ -561,8 +567,8 @@ namespace osl_Thread termAndJoinThread(newthread); delete newthread; - t_print(" nValue = %d\n", nValue); - t_print("isRunning = %d\n", isRunning); + t_print(" nValue = %d\n", (int) nValue); + t_print("isRunning = %s\n", isRunning == sal_True ? "true" : "false"); CPPUNIT_ASSERT_MESSAGE( "Creates a new thread", @@ -738,7 +744,7 @@ namespace osl_Thread //{ ThreadHelper::thread_sleep_tenth_sec(3); nValue = aThread->getValue(); // (1) - t_print(" getValue is %d !", nValue ); + t_print(" getValue is %d !", (int) nValue ); if (nValue >= 2) { aThread->setSuspend(); @@ -814,9 +820,9 @@ namespace osl_Thread termAndJoinThread(pCountThread); delete pCountThread; - t_print("SuspendValue: %d\n", nSuspendValue); - t_print("ResumeValue: %d\n", nResumeValue); - t_print("LaterValue: %d\n", nLaterValue); + t_print("SuspendValue: %d\n", (int) nSuspendValue); + t_print("ResumeValue: %d\n", (int) nResumeValue); + t_print("LaterValue: %d\n", (int) nLaterValue); /* LLA: this assumption is no longer relevant: nResumeValue == nSuspendValue && */ CPPUNIT_ASSERT_MESSAGE( @@ -843,7 +849,7 @@ namespace osl_Thread termAndJoinThread(newthread); delete newthread; - t_print(" nValue = %d\n", nValue); + t_print(" nValue = %d\n", (int) nValue); CPPUNIT_ASSERT_MESSAGE( "Creates a suspended thread, then resume", @@ -893,8 +899,8 @@ namespace osl_Thread aCountThread->join(); delete aCountThread; - t_print(" nValue = %d\n", nValue); - t_print("nLaterValue = %d\n", nLaterValue); + t_print(" nValue = %d\n", (int) nValue); + t_print("nLaterValue = %d\n", (int) nLaterValue); CPPUNIT_ASSERT_MESSAGE( "Terminate the thread", @@ -922,8 +928,8 @@ namespace osl_Thread sal_Int32 nLaterValue = aCountThread->getValue(); delete aCountThread; - t_print(" nValue = %d\n", nValue); - t_print("nLaterValue = %d\n", nLaterValue); + t_print(" nValue = %d\n", (int) nValue); + t_print("nLaterValue = %d\n", (int) nLaterValue); CPPUNIT_ASSERT_MESSAGE( "Suspend then resume the thread", @@ -1178,8 +1184,8 @@ namespace osl_Thread rtl::OString sPrio = getPrioName(_aPriority); t_print("After 10 tenth seconds\n"); - t_print("nValue in %s Prio Thread is %d\n",sPrio.getStr(), nValueNormal); - t_print("nValue in %s Prio Thread is %d\n", sPrio.getStr(), nValueNormal2); + t_print("nValue in %s Prio Thread is %d\n",sPrio.getStr(), (int) nValueNormal); + t_print("nValue in %s Prio Thread is %d\n", sPrio.getStr(), (int) nValueNormal2); // ThreadHelper::thread_sleep_tenth_sec(1); pThread->join(); @@ -1196,7 +1202,7 @@ namespace osl_Thread ); double nDeltaPercent = nDelta / nQuotient * 100; - t_print("Delta value %d, percent %f\n",nDelta, nDeltaPercent); + t_print("Delta value %d, percent %f\n", (int) nDelta, nDeltaPercent); // LLA: it's not a bug if the current OS is not able to handle thread scheduling right and good. // like Windows XP @@ -1282,9 +1288,9 @@ namespace osl_Thread // sal_Int32 nValueLowest = 0; //nValueLowest = aLowestThread->getValue(); t_print("After 10 tenth seconds\n"); - t_print("nValue in Highest Prio Thread is %d\n",nValueHighest); - t_print("nValue in AboveNormal Prio Thread is %d\n",nValueAboveNormal); - t_print("nValue in Normal Prio Thread is %d\n",nValueNormal); + t_print("nValue in Highest Prio Thread is %d\n", (int) nValueHighest); + t_print("nValue in AboveNormal Prio Thread is %d\n", (int) nValueAboveNormal); + t_print("nValue in Normal Prio Thread is %d\n", (int) nValueNormal); // LLA: this is not a save test, so we only check if all values not zero // LLA: CPPUNIT_ASSERT_MESSAGE( @@ -1366,11 +1372,11 @@ namespace osl_Thread nValueLowest = pLowestThread->getValue(); t_print("After 10 tenth seconds\n"); - t_print("nValue in Highest Prio Thread is %d\n",nValueHighest); - t_print("nValue in AboveNormal Prio Thread is %d\n",nValueAboveNormal); - t_print("nValue in Normal Prio Thread is %d\n",nValueNormal); - t_print("nValue in BelowNormal Prio Thread is %d\n",nValueBelowNormal); - t_print("nValue in Lowest Prio Thread is %d\n",nValueLowest); + t_print("nValue in Highest Prio Thread is %d\n", (int) nValueHighest); + t_print("nValue in AboveNormal Prio Thread is %d\n", (int) nValueAboveNormal); + t_print("nValue in Normal Prio Thread is %d\n", (int) nValueNormal); + t_print("nValue in BelowNormal Prio Thread is %d\n", (int) nValueBelowNormal); + t_print("nValue in Lowest Prio Thread is %d\n", (int) nValueLowest); delete pHighestThread; delete pAboveNormalThread; @@ -1463,10 +1469,10 @@ namespace osl_Thread t_print("After 5 tenth seconds\n"); // t_print("nValue in Highest Prio Thread is %d\n",nValueHighest); - t_print("nValue in AboveNormal Prio Thread is %d\n",nValueAboveNormal); - t_print("nValue in Normal Prio Thread is %d\n",nValueNormal); - t_print("nValue in BelowNormal Prio Thread is %d\n",nValueBelowNormal); - t_print("nValue in Lowest Prio Thread is %d\n",nValueLowest); + t_print("nValue in AboveNormal Prio Thread is %d\n", (int) nValueAboveNormal); + t_print("nValue in Normal Prio Thread is %d\n", (int) nValueNormal); + t_print("nValue in BelowNormal Prio Thread is %d\n", (int) nValueBelowNormal); + t_print("nValue in Lowest Prio Thread is %d\n", (int) nValueLowest); // delete pHighestThread; delete pAboveNormalThread; @@ -1559,9 +1565,9 @@ namespace osl_Thread t_print("After 5 tenth seconds\n"); // t_print("nValue in Highest Prio Thread is %d\n",nValueHighest); // t_print("nValue in AboveNormal Prio Thread is %d\n",nValueAboveNormal); - t_print("nValue in Normal Prio Thread is %d\n",nValueNormal); - t_print("nValue in BelowNormal Prio Thread is %d\n",nValueBelowNormal); - t_print("nValue in Lowest Prio Thread is %d\n",nValueLowest); + t_print("nValue in Normal Prio Thread is %d\n", (int) nValueNormal); + t_print("nValue in BelowNormal Prio Thread is %d\n", (int) nValueBelowNormal); + t_print("nValue in Lowest Prio Thread is %d\n", (int) nValueLowest); // delete pHighestThread; // delete pAboveNormalThread; @@ -1794,7 +1800,7 @@ namespace osl_Thread delete aCountThread; t_print("nTenthSec = %f \n", nTenthSec); t_print("nSec = %f \n", nSec); - t_print("nValue = %d \n", nValue); + t_print("nValue = %d \n", (int) nValue); CPPUNIT_ASSERT_MESSAGE( "Wait: Blocks the calling thread for the given number of time.", @@ -1906,8 +1912,8 @@ namespace osl_Thread ThreadHelper::thread_sleep_tenth_sec(3); sal_Int32 nLaterValue = aThread->getValue(); // resumeAndWaitThread(aThread); - t_print(" value = %d\n", nValue); - t_print("later value = %d\n", nLaterValue); + t_print(" value = %d\n", (int) nValue); + t_print("later value = %d\n", (int) nLaterValue); // if value and latervalue not equal, than the thread would not suspended CPPUNIT_ASSERT_MESSAGE( @@ -1924,8 +1930,8 @@ namespace osl_Thread aThread->join(); sal_Int32 nValue_join = aThread->getValue(); - t_print("value after term = %d\n", nValue_term); - t_print("value after join = %d\n", nValue_join); + t_print("value after term = %d\n", (int) nValue_term); + t_print("value after join = %d\n", (int) nValue_join); // nValue_term and nValue_join should be the same // but should be differ from nValue @@ -1957,8 +1963,8 @@ namespace osl_Thread resumeAndWaitThread(&aThread); - t_print(" value = %d\n", nValue); - t_print("later value = %d\n", nLaterValue); + t_print(" value = %d\n", (int) nValue); + t_print("later value = %d\n", (int) nLaterValue); //On windows, suspend works, so the values are same #ifdef WNT @@ -1981,7 +1987,7 @@ namespace osl_Thread termAndJoinThread(&aThread); sal_Int32 nValue_term = aThread.getValue(); - t_print(" value term = %d\n", nValue_term); + t_print(" value term = %d\n", (int) nValue_term); CPPUNIT_ASSERT_MESSAGE( "Schedule: don't schedule in thread run method, terminate failed.", @@ -2326,13 +2332,13 @@ namespace osl_ThreadData }; // class getData // ----------------------------------------------------------------------------- - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_ThreadData::ctors, "osl_ThreadData"); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_ThreadData::setData, "osl_ThreadData"); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_ThreadData::getData, "osl_ThreadData"); + CPPUNIT_TEST_SUITE_REGISTRATION(osl_ThreadData::ctors); + CPPUNIT_TEST_SUITE_REGISTRATION(osl_ThreadData::setData); + CPPUNIT_TEST_SUITE_REGISTRATION(osl_ThreadData::getData); } // namespace osl_ThreadData // this macro creates an empty function, which will called by the RegisterAllFunctions() // to let the user the possibility to also register some functions by hand. -NOADDITIONAL; +CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |