Return-Path: X-Original-To: apmail-openoffice-commits-archive@www.apache.org Delivered-To: apmail-openoffice-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DD8D4175D5 for ; Wed, 2 Sep 2015 01:43:58 +0000 (UTC) Received: (qmail 53682 invoked by uid 500); 2 Sep 2015 01:43:53 -0000 Delivered-To: apmail-openoffice-commits-archive@openoffice.apache.org Received: (qmail 53642 invoked by uid 500); 2 Sep 2015 01:43:53 -0000 Mailing-List: contact commits-help@openoffice.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openoffice.apache.org Delivered-To: mailing list commits@openoffice.apache.org Received: (qmail 53633 invoked by uid 99); 2 Sep 2015 01:43:53 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Sep 2015 01:43:53 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 6AC00AC0040 for ; Wed, 2 Sep 2015 01:43:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1700699 - in /openoffice/trunk/main/sal/qa/rtl/doublelock: makefile.mk rtl_doublelocking.cxx Date: Wed, 02 Sep 2015 01:43:52 -0000 To: commits@openoffice.apache.org From: damjan@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150902014353.6AC00AC0040@hades.apache.org> Author: damjan Date: Wed Sep 2 01:43:52 2015 New Revision: 1700699 URL: http://svn.apache.org/r1700699 Log: #i125003# migrate main/sal/qa/rtl/doublelock from cppunit to Google Test. Also fix an include file problem that stopped it from compiling. Modified: openoffice/trunk/main/sal/qa/rtl/doublelock/makefile.mk openoffice/trunk/main/sal/qa/rtl/doublelock/rtl_doublelocking.cxx Modified: openoffice/trunk/main/sal/qa/rtl/doublelock/makefile.mk URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sal/qa/rtl/doublelock/makefile.mk?rev=1700699&r1=1700698&r2=1700699&view=diff ============================================================================== --- openoffice/trunk/main/sal/qa/rtl/doublelock/makefile.mk (original) +++ openoffice/trunk/main/sal/qa/rtl/doublelock/makefile.mk Wed Sep 2 01:43:52 2015 @@ -31,11 +31,16 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk +.IF "$(ENABLE_UNIT_TESTS)" != "YES" +all: + @echo unit tests are disabled. Nothing to do. + +.ELSE + + CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) -CFLAGSCXX += $(CPPUNIT_CFLAGS) - # BEGIN ---------------------------------------------------------------- # auto generated Target:testjob by codegen.pl @@ -43,24 +48,19 @@ CFLAGSCXX += $(CPPUNIT_CFLAGS) CFLAGS+=/Ob1 .ENDIF -SHL1OBJS= \ +APP1OBJS= \ $(SLO)$/rtl_doublelocking.obj -SHL1TARGET= rtl_doublelocking -SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) - -SHL1IMPLIB= i$(SHL1TARGET) -DEF1NAME =$(SHL1TARGET) -SHL1VERSIONMAP = $(PRJ)$/qa$/export.map +APP1TARGET= rtl_doublelocking +APP1STDLIBS= $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB) +APP1RPATH = NONE +APP1TEST = enabled # END ------------------------------------------------------------------ -#------------------------------- All object files ------------------------------- -# do this here, so we get right dependencies - -SLOFILES=$(SHL1OBJS) - # --- Targets ------------------------------------------------------ .INCLUDE : target.mk -.INCLUDE : _cppunit.mk + +.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES" + Modified: openoffice/trunk/main/sal/qa/rtl/doublelock/rtl_doublelocking.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sal/qa/rtl/doublelock/rtl_doublelocking.cxx?rev=1700699&r1=1700698&r2=1700699&view=diff ============================================================================== --- openoffice/trunk/main/sal/qa/rtl/doublelock/rtl_doublelocking.cxx (original) +++ openoffice/trunk/main/sal/qa/rtl/doublelock/rtl_doublelocking.cxx Wed Sep 2 01:43:52 2015 @@ -28,9 +28,8 @@ //------------------------------------------------------------------------ #include -#ifndef _RTL_USTRING_HXX_ -#include -#endif +#include +#include #ifndef _OSL_THREAD_HXX #include @@ -39,7 +38,7 @@ #include -#include +#include "gtest/gtest.h" // ----------------------------------------------------------------------------- #define CONST_TEST_STRING "gregorian" @@ -56,9 +55,9 @@ inline void printOUString( ::rtl::OUStri { rtl::OString aString; - t_print( "OUString: " ); + printf( "OUString: " ); aString = ::rtl::OUStringToOString( _suStr, RTL_TEXTENCODING_ASCII_US ); - t_print( "'%s'\n", aString.getStr( ) ); + printf( "'%s'\n", aString.getStr( ) ); } // ----------------------------------------------------------------------------- @@ -73,7 +72,7 @@ namespace ThreadHelper { // if (nVerbose == VERBOSE) // { - // t_print("wait %d tenth seconds. ", _nTenthSec ); + // printf("wait %d tenth seconds. ", _nTenthSec ); // fflush(stdout); // } #ifdef WNT //Windows @@ -87,7 +86,7 @@ namespace ThreadHelper #endif // if (nVerbose == VERBOSE) // { - // t_print("done\n"); + // printf("done\n"); // } } } @@ -150,7 +149,7 @@ public: { if (isRunning()) { - t_print("error: not terminated.\n"); + printf("error: not terminated.\n"); } } }; @@ -162,95 +161,85 @@ namespace rtl_DoubleLocking /** Test of the osl::Thread::create method */ - class getValue : public CppUnit::TestFixture + class getValue : public ::testing::Test { public: // initialise your test code values here. - void setUp() + void SetUp() { } - void tearDown() + void TearDown() { } + }; // class create + TEST_F(getValue, getValue_001) + { + rtl::OUString aStr = Gregorian::get(); + printOUString(aStr); - void getValue_001() - { - rtl::OUString aStr = Gregorian::get(); - printOUString(aStr); - - CPPUNIT_ASSERT_MESSAGE( - "Gregorian::get() failed, wrong value expected.", - aStr.getLength() != 0 - ); - } - - /** check 2 threads. + ASSERT_TRUE(aStr.getLength() != 0) + << "Gregorian::get() failed, wrong value expected."; + } - ALGORITHM: - Here the function should show, that 2 different threads, - which only increase a value, should run at the same time with same prio. - The test fails, if the difference between the two values is more than 5% - but IMHO this isn't a failure, it's only a feature of the OS. - */ + /** check 2 threads. - void getValue_002() - { - // initial 5 threads with different priorities - OGetThread* pThread = new OGetThread(); - OGetThread* p2Thread = new OGetThread(); + ALGORITHM: + Here the function should show, that 2 different threads, + which only increase a value, should run at the same time with same prio. + The test fails, if the difference between the two values is more than 5% + but IMHO this isn't a failure, it's only a feature of the OS. + */ + TEST_F(getValue, getValue_002) + { + // initial 5 threads with different priorities + OGetThread* pThread = new OGetThread(); + OGetThread* p2Thread = new OGetThread(); - //Create them and start running at the same time - pThread->create(); - p2Thread->create(); + //Create them and start running at the same time + pThread->create(); + p2Thread->create(); - ThreadHelper::thread_sleep_tenth_sec(50); + ThreadHelper::thread_sleep_tenth_sec(50); - pThread->terminate(); - p2Thread->terminate(); + pThread->terminate(); + p2Thread->terminate(); - sal_Int32 nValueOK = 0; - nValueOK = pThread->getOK(); + sal_Int32 nValueOK = 0; + nValueOK = pThread->getOK(); - sal_Int32 nValueOK2 = 0; - nValueOK2 = p2Thread->getOK(); + sal_Int32 nValueOK2 = 0; + nValueOK2 = p2Thread->getOK(); - t_print("Value in Thread #1 is %d\n", nValueOK); - t_print("Value in Thread #2 is %d\n", nValueOK2); + printf("Value in Thread #1 is %d\n", nValueOK); + printf("Value in Thread #2 is %d\n", nValueOK2); - sal_Int32 nValueFails = 0; - nValueFails = pThread->getFails(); + sal_Int32 nValueFails = 0; + nValueFails = pThread->getFails(); - sal_Int32 nValueFails2 = 0; - nValueFails2 = p2Thread->getFails(); + sal_Int32 nValueFails2 = 0; + nValueFails2 = p2Thread->getFails(); - t_print("Fails in Thread #1 is %d\n", nValueFails); - t_print("Fails in Thread #2 is %d\n", nValueFails2); + printf("Fails in Thread #1 is %d\n", nValueFails); + printf("Fails in Thread #2 is %d\n", nValueFails2); - // ThreadHelper::thread_sleep_tenth_sec(1); - pThread->join(); - p2Thread->join(); + // ThreadHelper::thread_sleep_tenth_sec(1); + pThread->join(); + p2Thread->join(); - delete pThread; - delete p2Thread; + delete pThread; + delete p2Thread; - CPPUNIT_ASSERT_MESSAGE( - "getValue() failed, wrong value expected.", - nValueOK != 0 && nValueFails == 0 && nValueFails2 == 0 - ); - } + ASSERT_TRUE(nValueOK != 0 && nValueFails == 0 && nValueFails2 == 0) + << "getValue() failed, wrong value expected."; + } - CPPUNIT_TEST_SUITE(getValue); - CPPUNIT_TEST(getValue_001); - CPPUNIT_TEST(getValue_002); - CPPUNIT_TEST_SUITE_END(); - }; // class create -// ----------------------------------------------------------------------------- - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_DoubleLocking::getValue, "rtl_DoubleLocking"); } // namespace rtl_DoubleLocking -// 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; +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}