Kaydet (Commit) 0fcd1180 authored tarafından Lars Langhans's avatar Lars Langhans

testshl2 code

üst 3c3feccb
ts testshl2 : sal NULL
ts testshl2 usr1 - all ts_mkout NULL
ts testshl2\source\cppunit nmake - all ts_tss NULL
ts testshl2\source\result nmake - all ts_tsr ts_tss NULL
ts testshl2\source nmake - all ts_tst ts_tsr ts_tss NULL
ts testshl2\util nmake - all ts_tstu ts_tst ts_tsr ts_tss NULL
ts testshl2\inc get - all ts_tsti NULL
mkdir: %_DEST%\inc%_EXT%\cppunit
mkdir: %_DEST%\inc%_EXT%\cppunit\portability
mkdir: %_DEST%\inc%_EXT%\cppunit\autoregister
mkdir: %_DEST%\inc%_EXT%\cppunit\extensions
..\inc\cppunit\*.h %_DEST%\inc%_EXT%\cppunit\*.h
..\inc\cppunit\*.hxx %_DEST%\inc%_EXT%\cppunit\*.hxx
..\inc\cppunit\portability\*.h %_DEST%\inc%_EXT%\cppunit\portability\*.h
..\inc\cppunit\extensions\*.h %_DEST%\inc%_EXT%\cppunit\extensions\*.h
..\inc\cppunit\autoregister\htestresult.h %_DEST%\inc%_EXT%\cppunit\autoregister\htestresult.h
..\inc\cppunit\autoregister\treswrapper.h %_DEST%\inc%_EXT%\cppunit\autoregister\treswrapper.h
..\inc\cppunit\autoregister\testfunc.h %_DEST%\inc%_EXT%\cppunit\autoregister\testfunc.h
..\inc\cppunit\autoregister\registertestfunction.h %_DEST%\inc%_EXT%\cppunit\autoregister\registertestfunction.h
..\inc\cppunit\autoregister\callbackstructure.h %_DEST%\inc%_EXT%\cppunit\autoregister\callbackstructure.h
..\inc\cppunit\autoregister\callbackfunc_fktptr.h %_DEST%\inc%_EXT%\cppunit\autoregister\callbackfunc_fktptr.h
# ..\src\result\inc\cppunit\*.h %_DEST%\inc%_EXT%\cppunit\*.h
# ..\src\result\inc\cppunit\result\*.h %_DEST%\inc%_EXT%\cppunit\result\*.h
# ..\%__SRC%\lib\tstutil.lib %_DEST%\lib%_EXT%\tstutil.lib
# ..\%__SRC%\bin\testshl.exe %_DEST%\bin%_EXT%\testshl.exe
..\%__SRC%\bin\testshl2.exe %_DEST%\bin%_EXT%\testshl2.exe
..\%__SRC%\bin\testshl2 %_DEST%\bin%_EXT%\testshl2
mkdir: %_DEST%\inc%_EXT%\testshl
..\inc\*.hxx %_DEST%\inc%_EXT%\testshl\*.hxx
..\inc\*.h %_DEST%\inc%_EXT%\testshl\*.h
..\%__SRC%\lib\cppunit.lib %_DEST%\lib%_EXT%\cppunit.lib
..\%__SRC%\lib\*.a %_DEST%\lib%_EXT%\*.a
#include <stdio.h>
#include <stdlib.h>
#include "autoregisterhelper.hxx"
#include <rtl/ustring.hxx>
#include <cppunit/autoregister/registerfunc.h>
#include <cppunit/autoregister/callbackstructure.h>
#include <cppunit/result/callbackfunc.h>
#include <cppunit/autoregister/testfunc.h>
#include "filehelper.hxx"
FunctionList m_Functions;
// osl::Mutex m_Mutex;
void SAL_CALL registerFunc(FktPtr _pFunc, const char* _sFuncName)
{
// printf("Function register call for func(%s) successful.\n", _sFuncName);
m_Functions.push_back(_pFunc);
}
// -----------------------------------------------------------------------------
AutomaticRegisterHelper::AutomaticRegisterHelper(rtl::OUString const& _sDLLName, GetOpt & _aOptions /*, JobList * _pJobList*/)
:DynamicLibraryHelper(_sDLLName, _aOptions)
{
// try to get the entry pointer
FktRegAllPtr pFunc = (FktRegAllPtr) m_pModule->getSymbol( rtl::OUString::createFromAscii( "registerAllTestFunction" ) );
if (pFunc)
{
// FktRegFuncPtr pRegisterFunc = &DynamicLibraryHelper::registerFunc;
// pFunc(pRegisterFunc);
// osl::Guard aGuard(m_Mutex);
FktRegFuncPtr pRegisterFunc = &registerFunc;
CallbackStructure aCallback;
aCallback.aRegisterFunction = pRegisterFunc;
aCallback.aCallbackDispatch = &CallbackDispatch;
if (_aOptions.hasOpt("-forward"))
{
aCallback.psForward = _aOptions.getOpt("-forward").getStr();
}
// aCallback.pJobList = _pJobList;
//# aCallback.aStartTest = &TestResult_startTest;
//# aCallback.aAddFailure = &TestResult_addFailure;
//# aCallback.aAddError = &TestResult_addError;
//# aCallback.aEndTest = &TestResult_endTest;
//# aCallback.aShouldStop = &TestResult_shouldStop;
//# aCallback.aAddInfo = &TestResult_addInfo;
//# aCallback.aEnterNode = &TestResult_enterNode;
//# aCallback.aLeaveNode = &TestResult_leaveNode;
aCallback.nBits = FileHelper::createFlags(_aOptions);
pFunc(&aCallback);
if (aCallback.nMagic == aCallback.nMagic2)
{
// ok internal simple test done.
m_aFunctionList = m_Functions;
}
else
{
// ERROR, the function seams not to be what we thing it's to be.
fprintf(stderr, "error: Internal test failed. Value Magic2 != Magic\n");
exit(-1);
}
}
else
{
fprintf(stderr, "warning: Function 'registerAllTestFunction' not found.\n");
}
}
void AutomaticRegisterHelper::CallAll(hTestResult _hResult)
{
for (FunctionList::const_iterator it = m_aFunctionList.begin();
it != m_aFunctionList.end();
++it)
{
FktPtr pFunc = *it;
if (pFunc)
{
(pFunc)(_hResult);
}
}
}
This diff is collapsed.
#include "dynamicregister.hxx"
#ifndef _OSL_PROCESS_H_
#include <osl/process.h>
#endif
// #include <osl/mutex.hxx>
#include <rtl/string.hxx>
#include <rtl/ustring.hxx>
#include "filehelper.hxx"
// -----------------------------------------------------------------------------
DynamicLibraryHelper::DynamicLibraryHelper(rtl::OUString const& _sDLLName, GetOpt & _aOptions)
:m_pModule(new ::osl::Module()),
m_suDLLName(_sDLLName),
m_aOptions(_aOptions)
{
// create and load the module (shared library)
if (! m_pModule->load( FileHelper::convertPath( _sDLLName ) ))
{
rtl::OString sDLLName = rtl::OUStringToOString(_sDLLName, RTL_TEXTENCODING_ASCII_US);
fprintf(stderr, "warning: Can't load module '%s'.\n", sDLLName.getStr());
}
}
DynamicLibraryHelper::~DynamicLibraryHelper()
{
delete m_pModule;
}
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
// -----------------------------------------------------------------------------
// taken from setup2
std::string getTempPath()
{
std::string sTempDir;
char* pTmp = getenv( "TEMP" );
if (pTmp == NULL) pTmp = getenv("temp");
if (pTmp == NULL) pTmp = getenv("TMP");
if (pTmp == NULL) pTmp = getenv("tmp");
if( pTmp && strlen(pTmp) >= 2 )
{
sTempDir = std::string( pTmp );
}
else
{
#ifdef UNX
int nLen;
pTmp = P_tmpdir;
nLen = strlen(pTmp);
if (pTmp[ nLen - 1] == '/')
{
char cBuf[256];
char* pBuf = cBuf;
strncpy( pBuf, pTmp, nLen - 1 );
pBuf[nLen - 1] = '\0';
sTempDir = std::string( pBuf );
}
else
{
sTempDir = std::string( pTmp );
}
#else
fprintf(stderr, "error: No temp dir found.\n");
#endif
}
return sTempDir;
}
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include "filehelper.hxx"
#include "getopt.hxx"
#ifndef _OSL_PROCESS_H_
#include <osl/process.h>
#endif
#ifndef _OSL_FILE_HXX_
#include <osl/file.hxx>
#endif
#ifndef _SAL_TRES_H_
#include <rtl/tres.h>
#endif
namespace FileHelper
{
// -----------------------------------------------------------------------------
// taken from setup2
std::string getTempPath()
{
std::string sTempDir;
char* pTmp = getenv( "TEMP" );
if (pTmp == NULL) pTmp = getenv("temp");
if (pTmp == NULL) pTmp = getenv("TMP");
if (pTmp == NULL) pTmp = getenv("tmp");
if( pTmp && strlen(pTmp) >= 2 )
{
sTempDir = std::string( pTmp );
}
else
{
#ifdef UNX
int nLen;
pTmp = P_tmpdir;
nLen = strlen(pTmp);
if (pTmp[ nLen - 1] == '/')
{
char cBuf[256];
char* pBuf = cBuf;
strncpy( pBuf, pTmp, nLen - 1 );
pBuf[nLen - 1] = '\0';
sTempDir = std::string( pBuf );
}
else
{
sTempDir = std::string( pTmp );
}
#else
fprintf(stderr, "error: No temp dir found.\n");
#endif
}
return sTempDir;
}
// -----------------------------------------------------------------------------
rtl::OUString convertPath( rtl::OUString const& _suSysPath )
{
// PRE: String should contain a filename, relativ or absolut
rtl::OUString fURL;
if ( _suSysPath.indexOf(rtl::OUString::createFromAscii("..")) != -1 )
{
// filepath contains '..' so it's a relative path make it absolut.
rtl::OUString curDirPth;
osl_getProcessWorkingDir( &curDirPth.pData );
osl::FileBase::getAbsoluteFileURL( curDirPth, _suSysPath, fURL );
}
else
{
osl::FileBase::getFileURLFromSystemPath( _suSysPath, fURL );
}
return fURL;
}
// -----------------------------------------------------------------------------
rtl::OUString convertPath( rtl::OString const& sysPth )
{
rtl::OUString sysPath( rtl::OUString::createFromAscii( sysPth.getStr() ) );
return convertPath(sysPath);
}
/**
* create bitmap of comandline parameters
*/
//# CmdLineBits createFlags( vector< sal_Char* > const& cmdln )
//# {
//# CmdLineBits retflags = rtl_tres_Flag_OK;
//#
//# vector< sal_Char* >::const_iterator iter = cmdln.begin();
//# while( iter != cmdln.end() )
//# {
//# fprintf( stderr, "%s\n", *iter );
//# if ( *iter[0] == '-' )
//# {
//# rtl::OString item( *iter );
//# if ( item == "-boom" ) // stop near error position, exception only
//# retflags |= rtl_tres_Flag_BOOM;
//#
//# if ( item == "-verbose" )
//# retflags |= rtl_tres_Flag_VERBOSE;
//#
//# if ( item == "-skip" )
//# retflags |= rtl_tres_Flag_SKIP;
//#
//# if ( item == "-log" )
//# retflags |= rtl_tres_Flag_LOG;
//#
//# if ( item == "-his" )
//# retflags |= rtl_tres_Flag_HIS;
//#
//# if ( item == "-time" )
//# retflags |= rtl_tres_Flag_TIME;
//#
//# if ( item == "-msg" )
//# retflags |= rtl_tres_Flag_MSG;
//# }
//# iter++;
//# }
//#
//# return retflags;
//# }
//#
//# CmdLineBits createFlags(int argc, char* argv[])
//# {
//# vector< sal_Char* > cmdln;
//# sal_Int32 i;
//#
//# /* collect comandline */
//# for ( i = 1; i < argc; i++ )
//# cmdln.push_back( argv[i] );
//#
//# return createFlags(cmdln);
//# }
CmdLineBits createFlags( GetOpt & _aOptions )
{
CmdLineBits retflags = rtl_tres_Flag_OK;
if (_aOptions.hasOpt("-boom")) // stop near error position, exception only
{
retflags |= rtl_tres_Flag_BOOM;
}
return retflags;
}
// -----------------------------------------------------------------------------
/**
* display usage screen
*/
//# void usage()
//# {
//# fprintf( stdout,
//# "USAGE: testshl shlname [-boom][-verbose][-log][-his][-msg]\n" );
//# exit(0);
//# }
} // namespace FileHelper
This diff is collapsed.
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: lla $ $Date: 2003-01-09 11:06:02 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..
PRJNAME=testshl2
TARGET=testshl2
TARGETTYPE=CUI
ENABLE_EXCEPTIONS=TRUE
#USE_LDUMP2=TRUE
#LDUMP2=LDUMP3
# --- Settings -----------------------------------------------------
.INCLUDE : svpre.mk
.INCLUDE : settings.mk
.INCLUDE : sv.mk
# ------------------------------------------------------------------
COMMON_OBJFILES=\
$(OBJ)$/getopt.obj \
$(OBJ)$/filehelper.obj \
$(OBJ)$/dynamicregister.obj
TESTSHL_OBJFILES=\
$(OBJ)$/autoregisterhelper.obj \
$(OBJ)$/testshl.obj
VERSIONER_OBJFILES=\
$(OBJ)$/versionhelper.obj \
$(OBJ)$/versioner.obj
# for right dependencies
# OBJFILES= $(COMMON_OBJFILES) $(TESTSHL_OBJFILES) $(VERSIONER_OBJFILES)
# ------------------------------------------------------------------
APP1TARGET= $(TARGET)
APP1OBJS= $(COMMON_OBJFILES) $(TESTSHL_OBJFILES)
APP1STDLIBS=$(SALLIB)
APP1DEPN= \
$(LB)$/cppunit_no_regallfkt.lib \
$(SLB)$/testresult.lib
APP1LIBS= \
$(LB)$/cppunit_no_regallfkt.lib \
$(SLB)$/testresult.lib
#
# ------------------------------------------------------------------
APP2TARGET= versioner
APP2OBJS= $(COMMON_OBJFILES) $(VERSIONER_OBJFILES)
APP2STDLIBS=$(SALLIB)
APP2DEPN=
APP2LIBS=
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
/*************************************************************************
*
* $RCSfile: testshl.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: lla $ $Date: 2003-01-09 11:06:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#ifdef SOLARIS
#include <sys/time.h>
#endif
#ifdef WNT
// #define UNDER_WINDOWS_DEBUGGING
// Nice feature, to debug under windows, install msdev locally and use DebugBreak() to stop a new process at a point you want.
#ifdef UNDER_WINDOWS_DEBUGGING
#include <tools/presys.h>
#include <windows.h>
#include <tools/postsys.h>
#define VCL_NEED_BASETSD
#endif /* UNDER_WINDOWS_DEBUGGING */
#endif /* WNT */
#include <iostream>
#include <vector>
#ifndef _RTL_STRING_HXX_
#include <rtl/string.hxx>
#endif
// #include <rtl/tres.h>
#include "autoregisterhelper.hxx"
// #include "cmdlinebits.hxx"
#include "log.hxx"
#include "filehelper.hxx"
#include "getopt.hxx"
#include "cppunit/result/outputter.hxx"
#include "cppunit/joblist.hxx"
// #include <osl/time.h>
using namespace std;
#include "cppunit/result/testshlTestResult.h"
#include "cppunit/result/emacsTestResult.hxx"
Log initLog(GetOpt & _aOptions)
{
rtl::OString logPath;
if (_aOptions.hasOpt("-logPath"))
{
logPath = _aOptions.getOpt("-logPath");
}
else
{
logPath = FileHelper::getTempPath().c_str();
}
rtl::OString sLogFile(logPath);
sLogFile += "/testshl2.log";
Log log( FileHelper::convertPath( sLogFile ) );
if ( log.open() != osl::FileBase::E_None )
{
cerr << "could not open LogFile: " << log.getName().getStr() << endl;
exit(1);
}
return log;
}
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int main( int argc, char* argv[] )
#else
int _cdecl main( int argc, char* argv[] )
#endif
{
static char* optionSet[] = {
"-boom, stop near error position, exception only",
"-mode=s, the output mode, emacs, xml, old. Default is -mode old",
"-logPath=s, destination path for logging",
"-noerrors, shows all tests, but not it's errors.",
"-onlyerrors, shows only the failed test functions",
"-tc=s@, name(s) of testcase(s) to generate",
"-jobonly=s, job control file, these jobs should only executed.",
"-jobfilter=s, use a filter for just some tests.",
"-onlyshowjobs, show only all jobs, do no tests.",
"-forward=s, this string will forwarded to the test libraries.",
"-h:s, display help or help on option",
"-help:s, see -h",
NULL
};
GetOpt opt( argv, optionSet );
// someone indicates that he needs help
if ( opt.hasOpt( "-h" ) || opt.hasOpt( "-help" ) )
{
opt.showUsage();
exit(0);
}
// get path for logging stuff..
rtl::OString logPth;
// ...if available
if ( opt.hasOpt( "-logPth" ))
{
logPth = opt.getOpt( "-logPth" );
}
if (opt.getParams().empty())
{
std::cerr << "error: At least on library should given." << std::endl;
opt.showUsage();
exit(0);
}
/* show usage screen if too less parameters */
// if ( argc < 2 )
// usage();
#ifdef UNDER_WINDOWS_DEBUGGING
DebugBreak();
#endif
// ---
//# CmdLineBits nCmdlinebitflags = createFlags( argc, argv );
//# rtl::OUString suLibraryName = rtl::OUString::createFromAscii(argv[1]);
rtl::OUString suLibraryName = rtl::OStringToOUString(opt.getFirstParam(), RTL_TEXTENCODING_ASCII_US );
// Log aLog = initLog(opt);
AutomaticRegisterHelper aHelper(suLibraryName, opt /*, &aJobs*/);
// create and open log
CppUnit::TestResult* pResult;
if (opt.hasOpt("-mode"))
{
if (opt.getOpt("-mode").equals("emacs") == sal_True)
{
pResult = new CppUnit::emacsTestResult(opt);
}
}
else
{
pResult = new CppUnit::testshlTestResult(opt);
}
aHelper.CallAll(pResult);
Outputter aOutput(cout);
pResult->print(aOutput);
// aLog << *pResult;
// cout << (*pResult);
// cout << "Done." << std::endl;
delete pResult;
return 0;
}
// all functions, which exist in the library
// all functions + the given, no one twice
// only the given functions
// Signals info
// We can only say which function has thrown a signal, and what signal was thrown,
// but not really where the signal was thrown. You have to debug this function by hand.
// Exception info
// Due to the fact that exceptions will caught, on exceptions the ASSERTION text is given.
// but we know also the real thrown exception
// PARAMETER:
// - BaselibTest.txt anders benennen.
// - in eigenes Verzeichnis setzen.
// - log file, nicht nur cout.
// - emacs mode
// - test runner in perl.
// - Version/Buildno. im Datum
// - xml
// Remove rtl_tres_state from SAL!
#include <stdio.h>
#include <stdlib.h>
#include "versionhelper.hxx"
#include <rtl/ustring.hxx>
#include <iostream>
/**
* display usage screen
*/
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int main( int argc, char* argv[] )
#else
int _cdecl main( int argc, char* argv[] )
#endif
{
static char* optionSet[] = {
"-h:s, display help or help on option",
"-help:s, see -h",
NULL
};
GetOpt opt( argv, optionSet );
// someone indicates that he needs help
if ( opt.hasOpt( "-h" ) || opt.hasOpt( "-help" ) )
{
opt.showUsage();
exit(0);
}
rtl::OUString suLibraryName = rtl::OStringToOUString(opt.getFirstParam(), RTL_TEXTENCODING_ASCII_US );
VersionHelper aHelper(suLibraryName, opt);
std::cout << aHelper << std::endl;
return 0;
}
#include <stdlib.h>
#include "versionhelper.hxx"
#include <rtl/ustring.hxx>
// -----------------------------------------------------------------------------
VersionHelper::VersionHelper(rtl::OUString const& _sDLLName, GetOpt & _aOptions)
:DynamicLibraryHelper(_sDLLName, _aOptions),
m_pInfo(NULL)
{
// try to get the entry pointer
FktGetVersionInfoPtr pFunc = (FktGetVersionInfoPtr) m_pModule->getSymbol( rtl::OUString::createFromAscii( "GetVersionInfo" ) );
if (pFunc)
{
const VersionInfo *pVersion = (pFunc)();
m_pInfo = pVersion;
}
}
void VersionHelper::print(std::ostream &stream)
{
stream << m_pInfo->aTime << std::endl;
stream << m_pInfo->aDate << std::endl;
stream << m_pInfo->aUpd << std::endl;
stream << m_pInfo->aMinor << std::endl;
stream << m_pInfo->aBuild << std::endl;
stream << m_pInfo->aInpath << std::endl;
}
std::ostream &
operator <<( std::ostream &stream,
VersionHelper &_aVersion )
{
_aVersion.print (stream);
return stream;
}
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: lla $ $Date: 2003-01-09 11:06:14 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..
PRJNAME=testshl2
TARGET=testshl2
# --- Settings -----------------------------------------------------
.INCLUDE : svpre.mk
.INCLUDE : settings.mk
.INCLUDE : sv.mk
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: lla $ $Date: 2003-01-09 11:06:17 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..$/..
PRJINC=
PRJNAME=testshl2
TARGET=onefunc
TARGETTYPE=CUI
ENABLE_EXCEPTIONS=TRUE
#USE_LDUMP2=TRUE
#LDUMP2=LDUMP3
# --- Settings -----------------------------------------------------
.INCLUDE : svpre.mk
.INCLUDE : settings.mk
.INCLUDE : sv.mk
# ------------------------------------------------------------------
#--------------------------------- Objectfiles ---------------------------------
OBJFILES=$(OBJ)$/onefuncstarter.obj
SLOFILES=$(SLO)$/onefunc.obj
# -------------------------------------------------------------------------------
LIB1TARGET= $(LB)$/$(TARGET)_libfile.lib
LIB1OBJFILES= $(SLOFILES)
.IF "$(GUI)" == "UNX"
LIB1ARCHIV=$(LB)$/lib$(TARGET)$(DLLPOSTFIX).a
.ENDIF
# ------------------------------------------------------------------
SHL2OBJS = $(SLOFILES)
SHL2TARGET= $(TARGET)_DLL
SHL2STDLIBS+=\
$(SALLIB)
SHL2DEPN=
SHL2IMPLIB= i$(SHL2TARGET)
SHL2DEF= $(MISC)$/$(SHL2TARGET).def
DEF2NAME =$(SHL2TARGET)
DEF2EXPORTFILE= export.exp
#----------------------------- prog with *.lib file -----------------------------
APP1TARGET= $(TARGET)starter
APP1OBJS=$(OBJFILES)
APP1STDLIBS=$(SALLIB)
APP1DEPN= $(APP1OBJS) $(LIB1TARGET)
APP1LIBS= $(LIB1TARGET)
#-------------------------- executable with LIBARCHIV --------------------------
APP2TARGET= $(TARGET)starter2
APP2OBJS= $(OBJFILES)
APP2STDLIBS=$(SALLIB)
.IF "$(GUI)" == "UNX"
APP2STDLIBS+=$(LB)$/lib$(TARGET)$(DLLPOSTFIX).a
.ENDIF
.IF "$(GUI)" == "WNT"
APP2STDLIBS+=$(LIB1TARGET)
.ENDIF
APP2DEPN= $(APP1OBJS) $(LIB1TARGET)
APP2LIBS=
#----------------------- executable with dynamic library -----------------------
APP3TARGET= $(TARGET)starter3
APP3OBJS= $(OBJFILES)
APP3STDLIBS=$(SALLIB)
.IF "$(GUI)" == "WNT"
APP3STDLIBS+=i$(SHL2TARGET).lib
.ENDIF
.IF "$(GUI)" == "UNX"
APP3STDLIBS+=-l$(SHL2TARGET)
.ENDIF
APP3DEPN= $(APP1OBJS) $(LIB1TARGET)
APP3LIBS=
# APP3DEF=
#----------------------- executable without any other files -----------------------
APP4TARGET= $(TARGET)starter4
APP4OBJS= $(OBJFILES)
APP4STDLIBS=$(SALLIB)
APP4DEPN= $(APP1OBJS)
APP4LIBS=
# APP3DEF=
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
#include <stdio.h>
#include <sal/types.h>
#include "registerfunc.h"
extern "C" void SAL_CALL firstfunc()
{
printf("first func called.\n");
}
extern "C" void SAL_CALL secondfunc()
{
printf("second func called.\n");
}
extern "C" void SAL_CALL registerAllTestFunction(FktRegFuncPtr _pFunc)
{
if (_pFunc)
{
(_pFunc)(&firstfunc, "firstfunc");
(_pFunc)(&secondfunc, "secondfunc");
}
}
#include <vector>
#include <stdio.h>
#include "registerfunc.h"
#ifndef _OSL_MODULE_HXX_
#include <osl/module.hxx>
#endif
#ifndef _OSL_PROCESS_H_
#include <osl/process.h>
#endif
#ifndef _OSL_FILE_HXX_
#include <osl/file.hxx>
#endif
#include <rtl/string.hxx>
#include <rtl/ustring.hxx>
typedef std::vector<FktPtr> FunctionList;
FunctionList m_Functions;
extern "C" bool SAL_CALL registerFunc(FktPtr _pFunc, const char* _sFuncName)
{
printf("Function register call for func(%s) successful.\n", _sFuncName);
m_Functions.push_back(_pFunc);
// FktPtr pFunc = _pFunc;
// if (_pFunc)
// {
// (_pFunc)();
// }
return true;
}
void callAll()
{
for(FunctionList::const_iterator it = m_Functions.begin();
it != m_Functions.end();
++it)
{
FktPtr pFunc = *it;
if (pFunc)
{
(pFunc)();
}
}
}
// void test_link_at_compiletime()
// {
// FktRegFuncPtr pRegisterFunc = &registerFunc;
// registerAll(pRegisterFunc);
// callAll();
// }
// -----------------------------------------------------------------------------
rtl::OUString convertPath( rtl::OString const& sysPth )
{
// PRE: String should contain a filename, relativ or absolut
rtl::OUString sysPath( rtl::OUString::createFromAscii( sysPth.getStr() ) );
rtl::OUString fURL;
if ( sysPth.indexOf("..") != -1 )
{
// filepath contains '..' so it's a relative path make it absolut.
rtl::OUString curDirPth;
osl_getProcessWorkingDir( &curDirPth.pData );
osl::FileBase::getAbsoluteFileURL( curDirPth, sysPath, fURL );
}
else
{
osl::FileBase::getFileURLFromSystemPath( sysPath, fURL );
}
return fURL;
}
// -----------------------------------------------------------------------------
void test_link_at_runtime()
{
::osl::Module* pModule;
pModule = new ::osl::Module();
// create and load the module (shared library)
// pModule = new ::osl::Module();
#ifdef WNT
pModule->load( convertPath( rtl::OString( "onefunc_DLL.dll" ) ) );
#endif
#ifdef UNX
pModule->load( convertPath( rtl::OString( "libonefunc_DLL.so" ) ) );
#endif
// get entry pointer
FktRegAllPtr pFunc = (FktRegAllPtr) pModule->getSymbol( rtl::OUString::createFromAscii( "registerAllTestFunction" ) );
if (pFunc)
{
FktRegFuncPtr pRegisterFunc = &registerFunc;
pFunc(pRegisterFunc);
callAll();
}
delete pModule;
}
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int main( int argc, char* argv[] )
#else
int _cdecl main( int argc, char* argv[] )
#endif
{
// test_link_at_compiletime();
test_link_at_runtime();
return 0;
}
#ifndef _register_h
#define _register_h
#include <sal/types.h>
typedef void (* FktPtr)(void);
// register the given void* as a function pointer, true, if successful
extern "C" bool SAL_CALL registerFunc(FktPtr aFunc, const char* aFuncName);
typedef bool (* FktRegFuncPtr)(FktPtr aFunc, const char* aFuncName);
extern "C" void SAL_CALL registerAllTestFunction(FktRegFuncPtr aFunc);
typedef void (* FktRegAllPtr)(FktRegFuncPtr aFunc);
#endif
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: lla $ $Date: 2003-01-09 11:06:19 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..$/..
PRJINC=
PRJNAME=testshl2
TARGET=demotest
TARGETTYPE=CUI
ENABLE_EXCEPTIONS=TRUE
#USE_LDUMP2=TRUE
#LDUMP2=LDUMP3
# --- Settings -----------------------------------------------------
.INCLUDE : svpre.mk
.INCLUDE : settings.mk
.INCLUDE : sv.mk
# ------------------------------------------------------------------
#--------------------------------- Objectfiles ---------------------------------
SLOFILES=$(SLO)$/testshl_test.obj
# ------------------------------------------------------------------
SHL2OBJS = $(SLOFILES)
SHL2TARGET= $(TARGET)
SHL2STDLIBS=\
$(SALLIB) \
$(SOLARLIBDIR)$/cppunit.lib
SHL2DEPN=
SHL2IMPLIB= i$(SHL2TARGET)
SHL2DEF= $(MISC)$/$(SHL2TARGET).def
DEF2NAME =$(SHL2TARGET)
DEF2EXPORTFILE= export.exp
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
/*************************************************************************
*
* $RCSfile: testshl_test.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: lla $ $Date: 2003-01-09 11:06:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <stdio.h>
#ifdef WNT
// #define UNDER_WINDOWS_DEBUGGING
// Nice feature, to debug under windows, install msdev locally and use DebugBreak() to stop a new process at a point you want.
#ifdef UNDER_WINDOWS_DEBUGGING
#include <tools/presys.h>
#include <windows.h>
#include <tools/postsys.h>
#define VCL_NEED_BASETSD
#endif /* UNDER_WINDOWS_DEBUGGING */
#endif /* WNT */
#include <vector>
#ifndef _SAL_TRES_H_
#include <rtl/tres.h>
#endif
#ifndef _TESTSHL_TSTMGR_H_
#include "tstmgr.h"
#endif
#ifndef _RTL_STRING_HXX_
#include <rtl/string.hxx>
#endif
#include <osl/time.h>
using namespace std;
/**
* create bitmap of comandline parameters
*/
sal_uInt32 createFlags( vector< sal_Char* > const& cmdln )
{
sal_uInt32 retflags = rtl_tres_Flag_OK;
vector< sal_Char* >::const_iterator iter = cmdln.begin();
while( iter != cmdln.end() )
{
fprintf( stderr, "%s\n", *iter );
if ( *iter[0] == '-' )
{
rtl::OString item( *iter );
if ( item == "-boom" )
retflags |= rtl_tres_Flag_BOOM;
if ( item == "-verbose" )
retflags |= rtl_tres_Flag_VERBOSE;
if ( item == "-skip" )
retflags |= rtl_tres_Flag_SKIP;
if ( item == "-log" )
retflags |= rtl_tres_Flag_LOG;
if ( item == "-his" )
retflags |= rtl_tres_Flag_HIS;
if ( item == "-time" )
retflags |= rtl_tres_Flag_TIME;
if ( item == "-msg" )
retflags |= rtl_tres_Flag_MSG;
}
iter++;
}
return retflags;
}
sal_uInt32 createFlags(int argc, char* argv[])
{
vector< sal_Char* > cmdln;
sal_Int32 i;
/* collect comandline */
for ( i = 1; i < argc; i++ )
cmdln.push_back( argv[i] );
return createFlags(cmdln);
}
// -----------------------------------------------------------------------------
/**
* display usage screen
*/
void usage()
{
fprintf( stdout,
"USAGE: testshl shlname scename [-boom][-verbose][-log][-his][-msg]\n" );
exit(0);
}
#include <fstream>
#include <cppunit/TestFixture.h>
#include <cppunit/TestCaller.h>
#include <cppunit/TestSuite.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestAssert.h>
#include <cppunit/TextTestResult.h>
namespace CppunitTest
{
class AStringTest : public CppUnit::TestCase
{
rtl::OString *m_pStr;
public:
AStringTest()
:m_pStr(NULL) {}
void setUp()
{
m_pStr = new rtl::OString("test1");
// throw std::exception("initialization failed.");
}
void tearDown()
{
delete m_pStr;
}
void testEquality()
{
CPPUNIT_ASSERT( *m_pStr == "test1" );
CPPUNIT_ASSERT( (*m_pStr).equalsIgnoreAsciiCase("Test1") );
CPPUNIT_ASSERT( (*m_pStr).equalsIgnoreAsciiCase("Test2") );
CPPUNIT_ASSERT( *m_pStr == "test1" );
CPPUNIT_ASSERT( *m_pStr == "must also fail" );
}
void testEquality2()
{
rtl::OString aStr("test2");
CPPUNIT_ASSERT( aStr == "test2" );
CPPUNIT_ASSERT_MESSAGE("ein vergleichstest", aStr == "test2");
CPPUNIT_ASSERT( aStr == "must also fail" );
}
void testThrow()
{
throw std::exception("an own exception!");
CPPUNIT_ASSERT( *m_pStr == "test2" );
}
};
CppUnit::TestSuite *suite1()
{
CppUnit::TestSuite *suite = new CppUnit::TestSuite( "AStringTest" );
// CppUnit::TestSuite suite;
// CppUnit::TextTestResult result;
suite->addTest( new CppUnit::TestCaller<AStringTest>( "throw test", &AStringTest::testThrow ));
// suite->addTest( new CppUnit::TestCaller<AStringTest>( "test op eq", &AStringTest::testEquality ));
// suite->addTest( new CppUnit::TestCaller<AStringTest>( "test op eq", &AStringTest::testEquality2 ));
return suite;
}
// -----------------------------------------------------------------------------
class ASimpleTest : public CppUnit::TestCase
{
public:
void testEqual()
{
CPPUNIT_ASSERT( 1 == 1 );
}
};
CppUnit::TestSuite *suite2()
{
CppUnit::TestSuite *suite = new CppUnit::TestSuite( "A simple test" );
// CppUnit::TestSuite suite;
// CppUnit::TextTestResult result;
suite->addTest( new CppUnit::TestCaller<ASimpleTest>( "1 == 1", &ASimpleTest::testEqual ));
return suite;
}
// -----------------------------------------------------------------------------
CppUnit::TestSuite *suite()
{
CppUnit::TestSuite *suite = new CppUnit::TestSuite( "A simple test" );
// CppUnit::TestSuite suite;
// CppUnit::TextTestResult result;
suite->addTest( suite1() );
// suite->addTest( suite2() );
return suite;
}
}
void cppunitbased_test()
{
{
// ofstream out("c:\\temp\\output.txt", ios::out);
CppUnit::TextTestResult aResult;
CppUnit::TestSuite* pSuite = CppunitTest::suite();
int nTests = pSuite->countTestCases();
pSuite->run(&aResult);
// aResult.print(out);
cout << aResult;
delete pSuite;
}
exit(1);
}
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int main( int argc, char* argv[] )
#else
int _cdecl main( int argc, char* argv[] )
#endif
{
cppunitbased_test();
tslTestManager hMgr = 0;
/* show usage screen if too less parameters */
if ( argc < 3 )
usage();
#ifdef UNDER_WINDOWS_DEBUGGING
DebugBreak();
#endif
sal_uInt32 nCmdlinebitflags = createFlags( argc, argv );
hMgr = tsl_TestManager_create( argv, argc, nCmdlinebitflags );
tsl_TestManager_run( hMgr );
tsl_TestManager_destroy( hMgr );
return 0;
}
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: lla $ $Date: 2003-01-09 11:06:20 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..$/..
PRJINC=
PRJNAME=testshl2
TARGET=test_getopt
TARGETTYPE=CUI
ENABLE_EXCEPTIONS=TRUE
#USE_LDUMP2=TRUE
#LDUMP2=LDUMP3
# --- Settings -----------------------------------------------------
.INCLUDE : svpre.mk
.INCLUDE : settings.mk
.INCLUDE : sv.mk
# ------------------------------------------------------------------
#--------------------------------- Objectfiles ---------------------------------
OBJFILES=\
$(OBJ)$/getopt.obj \
$(OBJ)$/filehelper.obj \
$(OBJ)$/test_getopt.obj
#----------------------------- prog with *.lib file -----------------------------
APP1TARGET= $(TARGET)
APP1OBJS=$(OBJFILES)
APP1STDLIBS=$(SALLIB)
APP1DEPN= $(APP1OBJS)
APP1LIBS=
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
/*************************************************************************
*
* $RCSfile: test_getopt.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: lla $ $Date: 2003-01-09 11:06:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#ifdef SOLARIS
#include <sys/time.h>
#endif
#ifdef WNT
// #define UNDER_WINDOWS_DEBUGGING
// Nice feature, to debug under windows, install msdev locally and use DebugBreak() to stop a new process at a point you want.
#ifdef UNDER_WINDOWS_DEBUGGING
#include <tools/presys.h>
#include <windows.h>
#include <tools/postsys.h>
#define VCL_NEED_BASETSD
#endif /* UNDER_WINDOWS_DEBUGGING */
#endif /* WNT */
#include <iostream>
#include <vector>
#ifndef _RTL_STRING_HXX_
#include <rtl/string.hxx>
#endif
#include "filehelper.hxx"
#include "getopt.hxx"
// #include <osl/time.h>
using namespace std;
// -----------------------------------------------------------------------------
/**
* display usage screen
*/
void usage()
{
fprintf( stdout,
"USAGE: testshl shlname [-boom][-verbose][-log][-his][-msg]\n" );
exit(0);
}
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int main( int argc, char* argv[] )
#else
int _cdecl main( int argc, char* argv[] )
#endif
{
static char* optionSet[] = {
"-boom, stop near error position, exception only",
"-mode=s, the output mode, emacs, xml, old. Default is -mode old",
"-logPath=s, destination path for logging",
"-tc=s@, name(s) of testcase(s) to generate",
"-h:s, display help or help on option",
"-help:s, see -h",
NULL
};
GetOpt opt( argv, optionSet );
// someone indicates that he needs help
if ( opt.hasOpt( "-h" ) || opt.hasOpt( "-help" ) )
{
opt.showUsage();
// exit(0);
}
// get path for logging stuff..
rtl::OString logPth;
// ...if available
if ( opt.hasOpt( "-logPth" ))
{
logPth = opt.getOpt( "-logPth" );
}
rtl::OString param;
if ( ! opt.getParams().empty() ) {
param = opt.getFirstParam();
std::cout << "all non '-' Parameter values" << std::endl;
vector<rtl::OString>& aVec = opt.getParams();
for(vector<rtl::OString>::const_iterator it = aVec.begin();
it != aVec.end();
++it)
{
std::cout << (*it).getStr() << std::endl;
}
}
if ( opt.hasOpt("-tc"))
{
std::cout << "Parameter -tc" << std::endl;
vector<rtl::OString>& aVec = opt.getOptVec( "-tc" );
for(vector<rtl::OString>::const_iterator it = aVec.begin();
it != aVec.end();
++it)
{
std::cout << (*it).getStr() << std::endl;
}
}
return 0;
}
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: lla $ $Date: 2003-01-09 11:06:15 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..
PRJINC=
PRJNAME=testshl2
TARGET=test_autoptr
TARGETTYPE=CUI
ENABLE_EXCEPTIONS=TRUE
#USE_LDUMP2=TRUE
#LDUMP2=LDUMP3
# --- Settings -----------------------------------------------------
.INCLUDE : svpre.mk
.INCLUDE : settings.mk
.INCLUDE : sv.mk
# ------------------------------------------------------------------
#--------------------------------- Objectfiles ---------------------------------
OBJFILES=\
$(OBJ)$/test_autoptr.obj \
$(OBJ)$/test_ostringstream.obj
#----------------------------- prog with *.lib file -----------------------------
APP1TARGET= $(TARGET)
APP1OBJS=$(OBJ)$/test_autoptr.obj
APP1STDLIBS=$(SALLIB)
APP1DEPN= $(APP1OBJS)
APP1LIBS=
#-------------------------------------------------------------------------------
APP2TARGET= test_ostringstream
APP2OBJS=$(OBJ)$/test_ostringstream.obj
APP2STDLIBS=$(SALLIB)
APP2DEPN= $(APP1OBJS)
APP2LIBS=
#-------------------------------------------------------------------------------
APP3TARGET= test_filter
APP3OBJS=$(OBJ)$/test_filter.obj
APP3STDLIBS=$(SALLIB)
APP3DEPN= $(APP1OBJS)
APP3LIBS=
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
class OSingleton
{
public:
static OSingleton * GetSingleton();
virtual ~OSingleton(){}
protected :
OSingleton(){}
static OSingleton * m_pSingleton;
};
OSingleton * OSingleton::m_pSingleton = NULL;
OSingleton * OSingleton::GetSingleton()
{
if(m_pSingleton == NULL )
{
m_pSingleton = new OSingleton;
}
return m_pSingleton;
}
#include <stdlib.h>
#include <memory>
#include <iostream>
#include <stdio.h>
#include <rtl/string.hxx>
#include <rtl/ustring.hxx>
class AutoPtrTest
{
int m_nValue;
// NOCOPY
AutoPtrTest(AutoPtrTest const& );
AutoPtrTest& operator =(AutoPtrTest const& );
public:
AutoPtrTest(int _nValue = 1)
:m_nValue(_nValue)
{
std::cout << "build Value" << std::endl;
}
~AutoPtrTest()
{
std::cout << "release Value" << std::endl;
m_nValue = 0;
}
// int operator int() const {return m_nValue;}
int getValue() const {return m_nValue;}
};
std::auto_ptr<AutoPtrTest> getPtr()
{
return std::auto_ptr<AutoPtrTest>(new AutoPtrTest(2));
}
// auto_ptr get() gibt den Pointer ohne das ownership
// auto_ptr release()gibt den Pointer und (!) das ownership
void test_autoptr()
{
AutoPtrTest *pValuePtr;
std::cout << "start test" << std::endl;
{
std::auto_ptr<AutoPtrTest> pValue = getPtr();
std::cout << "Value with getValue() " << pValue->getValue() << std::endl;
// std::cout << "Value operator int() " << *pValue << std::endl;
// ownership weiterreichen
pValuePtr = pValue.release();
}
std::cout << "ValuePtr with getValue() " << pValuePtr->getValue() << std::endl;
// ownership an neuen Pointer uebergeben
std::auto_ptr<AutoPtrTest> pValue2(pValuePtr);
// AutoPtrTest *pStr = getPtr();
std::cout << "end test" << std::endl;
}
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int main( int argc, char* argv[] )
#else
int _cdecl main( int argc, char* argv[] )
#endif
{
test_autoptr();
return 0;
}
#include <vector>
#include <string>
#include <iostream>
#include <rtl/string.hxx>
typedef std::vector<std::string> StringList;
typedef std::vector<rtl::OString> OStringList;
void split( const rtl::OString& opt,
const rtl::OString& _sSeparator,
OStringList& optLine )
{
optLine.clear();
// const sal_Int32 cSetLen = cSet.getLength();
sal_Int32 index = 0;
sal_Int32 oldIndex = 0;
// sal_Int32 i;
// sal_Int32 j = 0;
while ( opt.getLength() > 0)
{
// for ( i = 0; i < cSetLen; i++ )
// {
index = opt.indexOf( _sSeparator, oldIndex);
if( index != -1 )
{
optLine.push_back( opt.copy( oldIndex, index - oldIndex ) );
oldIndex = index + _sSeparator.getLength();
}
// }
else // if (index == -1)
{
optLine.push_back( opt.copy( oldIndex ) );
break;
}
}
} ///< split
// -----------------------------------------------------------------------------
StringList splitNameAtDot(rtl::OString const& _sName)
{
StringList aList;
int nIndex = 0;
int nLastIndex = 0;
while ((nIndex = _sName.indexOf(".")) != -1)
{
rtl::OString nValue;
}
return aList;
}
// -----------------------------------------------------------------------------
/*
bool checkFilter(JobList m_aJobFilter, std::string const& _sNodeName, std::string const& _sName)
{
std::string sFilter = m_aJobFilter.m_aJobList.begin();
StringList aFilter;
aFilter.push_back("rtl_OUString");
aFilter.push_back("ctors");
aFilter.push_back("*");
StringList aMyName;
aMyName.push_back("rtl_OUString");
aMyName.push_back("ctors");
aMyName.push_back("ctor_001");
}
*/
void showList(OStringList const& _sList)
{
for(OStringList::const_iterator it = _sList.begin();
it != _sList.end();
++it)
{
rtl::OString aStr = *it;
std::cout << aStr.getStr() << std::endl;
}
}
bool match(OStringList const& _aFilter, OStringList const& _aName)
{
OStringList::const_iterator aFilterIter = _aFilter.begin();
OStringList::const_iterator aValueIter = _aName.begin();
bool bMatch = false;
while (aFilterIter != _aFilter.end() && aValueIter != _aName.end())
{
rtl::OString sFilter = *aFilterIter;
rtl::OString sName = *aValueIter;
if (sFilter == sName)
{
bMatch = true;
++aFilterIter;
++aValueIter;
}
else if (sFilter == "*")
{
bMatch = true;
break;
}
else
{
// Filter does not match
bMatch = false;
break;
}
}
return bMatch;
}
// -----------------------------------------------------------------------------
void test_normal_filter()
{
OStringList aFilter;
split("rtl_OUString.ctors.*", ".", aFilter);
showList(aFilter);
OStringList aName;
split("rtl_OUString.ctors.ctor_001", ".", aName);
showList(aName);
if (match(aFilter, aName))
{
std::cout << "Name matches filter." << std::endl;
}
}
void test_normal_filter_other_sep()
{
OStringList aFilter;
split("rtl_OUString::ctors::*", "::", aFilter);
showList(aFilter);
OStringList aName;
split("rtl_OUString::ctors::ctor_001", "::", aName);
showList(aName);
if (match(aFilter, aName))
{
std::cout << "Name matches filter." << std::endl;
}
}
void test_no_name()
{
OStringList aFilter;
split("rtl_OUString.*", ".", aFilter);
showList(aFilter);
OStringList aName;
split("", ".", aName);
showList(aName);
if (match(aFilter, aName))
{
std::cout << "Name matches filter." << std::endl;
}
}
void test_name_longer_filter()
{
OStringList aFilter;
split("rtl_OUString.*", ".", aFilter);
showList(aFilter);
OStringList aName;
split("rtl_OUString.ctor.ctor_001", ".", aName);
showList(aName);
if (match(aFilter, aName))
{
std::cout << "Name matches filter." << std::endl;
}
}
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int main( int argc, char* argv[] )
#else
int _cdecl main( int argc, char* argv[] )
#endif
{
test_normal_filter();
test_normal_filter_other_sep();
test_no_name();
test_name_longer_filter();
// split("rtl_OUString.*", ".", aFilter);
// showList(aFilter);
// test_autoptr();
return 0;
}
#include <stdlib.h>
#include <memory>
#include <sstream>
#include <iostream>
#include <bitset>
#include <sal/types.h>
class TestFactoryRegistry
{
public:
void checkFunc(char* foo);
void checkFunc2(char* foo);
void checkFunc3(char* foo);
};
void TestFactoryRegistry::checkFunc(char* foo)
{
static int serialNumber = 1;
std::ostringstream ost;
//! could this be the problem?
ost << "@Dummy@" << serialNumber++;
std::cout << ost.str() << std::endl;
}
void TestFactoryRegistry::checkFunc2(char* foo)
{
static int serialNumber = 1;
std::ostringstream ost;
//! could this be the problem?
ost << "@Dummy@" << serialNumber;
serialNumber++;
std::cout << ost.str() << std::endl;
}
void TestFactoryRegistry::checkFunc3(char* foo)
{
static int serialNumber = 1;
int nValue = serialNumber;
std::ostringstream ost;
//! could this be the problem?
ost << "@Dummy@" << nValue;
serialNumber++;
std::cout << ost.str() << std::endl;
}
static TestFactoryRegistry a;
static TestFactoryRegistry b;
static TestFactoryRegistry c;
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int main( int argc, char* argv[] )
#else
int _cdecl main( int argc, char* argv[] )
#endif
{
std::ostringstream ost;
sal_Int32 nValue = 1;
// ost << "@Dummy@" << nValue;
// ost << "dec: " << 15 << std::hex << " hex: " << 15 << std::endl;
// std::cout << ost.str() << std::endl;
char* cFoo = NULL;
a.checkFunc(cFoo);
a.checkFunc2(cFoo);
a.checkFunc3(cFoo);
b.checkFunc(cFoo);
b.checkFunc2(cFoo);
b.checkFunc3(cFoo);
c.checkFunc(cFoo);
c.checkFunc2(cFoo);
c.checkFunc3(cFoo);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment