Kaydet (Commit) ddaf31f1 authored tarafından Michael Meeks's avatar Michael Meeks

liblibo: install test library by itself and install it.

Also fix debugging with threads, find fundamentalrc correctly,
make it headless, finally loads a document then exits.

Change-Id: I2017075bf3b3c7198bde53b9fe85585089e5ab6c
üst 08b6643e
...@@ -45,6 +45,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \ ...@@ -45,6 +45,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \
gsicheck \ gsicheck \
helpex \ helpex \
idxdict \ idxdict \
libtest \
lngconvex \ lngconvex \
localize \ localize \
makedepend \ makedepend \
......
...@@ -17,6 +17,7 @@ $(eval $(call gb_Library_set_include,libreoffice,\ ...@@ -17,6 +17,7 @@ $(eval $(call gb_Library_set_include,libreoffice,\
$(eval $(call gb_Library_add_libs,libreoffice,\ $(eval $(call gb_Library_add_libs,libreoffice,\
$(if $(filter $(OS),LINUX), \ $(if $(filter $(OS),LINUX), \
-ldl \ -ldl \
-lpthread \
) \ ) \
)) ))
......
...@@ -33,7 +33,6 @@ $(eval $(call gb_Module_add_targets,desktop,\ ...@@ -33,7 +33,6 @@ $(eval $(call gb_Module_add_targets,desktop,\
AllLangResTarget_dkt \ AllLangResTarget_dkt \
Library_deployment \ Library_deployment \
Library_deploymentmisc \ Library_deploymentmisc \
Library_libreoffice \
Library_offacc \ Library_offacc \
Library_sofficeapp \ Library_sofficeapp \
Library_spl \ Library_spl \
...@@ -43,6 +42,12 @@ $(eval $(call gb_Module_add_targets,desktop,\ ...@@ -43,6 +42,12 @@ $(eval $(call gb_Module_add_targets,desktop,\
Zip_brand_dev \ Zip_brand_dev \
)) ))
ifeq ($(OS),LINUX)
$(eval $(call gb_Module_add_targets,desktop,\
Library_libreoffice \
))
endif
ifneq (,$(filter DESKTOP,$(BUILD_TYPE))) ifneq (,$(filter DESKTOP,$(BUILD_TYPE)))
$(eval $(call gb_Module_add_targets,desktop,\ $(eval $(call gb_Module_add_targets,desktop,\
Executable_unopkg.bin \ Executable_unopkg.bin \
......
...@@ -87,8 +87,20 @@ aBasicErrorFunc( const OUString &rErr, const OUString &rAction ) ...@@ -87,8 +87,20 @@ aBasicErrorFunc( const OUString &rErr, const OUString &rAction )
} }
static void static void
initialize_uno( const rtl::OUString &aUserProfileURL ) initialize_uno( const rtl::OUString &aAppURL )
{ {
rtl::Bootstrap::setIniFilename( aAppURL + "/fundamentalrc" );
OUString aValue;
rtl::Bootstrap::set( "CONFIGURATION_LAYERS",
"xcsxcu:${BRAND_BASE_DIR}/share/registry "
"res:${BRAND_BASE_DIR}/share/registry "
// "bundledext:${${BRAND_BASE_DIR}/program/unorc:BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini " );
// "sharedext:${${BRAND_BASE_DIR}/program/unorc:SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
// "userext:${${BRAND_BASE_DIR}/program/unorc:UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
// "user:${$BRAND_BASE_DIR/program/bootstraprc:UserInstallation}/user/registrymodifications.xcu"
);
xContext = cppu::defaultBootstrap_InitialComponentContext(); xContext = cppu::defaultBootstrap_InitialComponentContext();
fprintf( stderr, "Uno initialized %d\n", xContext.is() ); fprintf( stderr, "Uno initialized %d\n", xContext.is() );
xFactory = xContext->getServiceManager(); xFactory = xContext->getServiceManager();
...@@ -96,8 +108,9 @@ initialize_uno( const rtl::OUString &aUserProfileURL ) ...@@ -96,8 +108,9 @@ initialize_uno( const rtl::OUString &aUserProfileURL )
comphelper::setProcessServiceFactory(xSFactory); comphelper::setProcessServiceFactory(xSFactory);
// set UserInstallation to user profile dir in test/user-template // set UserInstallation to user profile dir in test/user-template
rtl::Bootstrap aDefaultVars; // rtl::Bootstrap aDefaultVars;
aDefaultVars.set(rtl::OUString("UserInstallation"), aUserProfileURL ); // aDefaultVars.set(rtl::OUString("UserInstallation"), aAppURL + "../registry" );
// configmgr setup ?
} }
bool bool
...@@ -117,15 +130,17 @@ LibLibreOffice_Impl::initialize( const char *app_path ) ...@@ -117,15 +130,17 @@ LibLibreOffice_Impl::initialize( const char *app_path )
return false; return false;
try { try {
initialize_uno( aAppURL + "../registry" ); initialize_uno( aAppURL );
force_c_locale(); force_c_locale();
// Force headless
rtl::Bootstrap::set( "SAL_USE_VCLPLUGIN", "svp" );
InitVCL(); InitVCL();
if (Application::IsHeadlessModeRequested()) Application::EnableHeadlessMode(true);
Application::EnableHeadlessMode(true);
ErrorHandler::RegisterDisplay( aBasicErrorFunc ); ErrorHandler::RegisterDisplay( aBasicErrorFunc );
fprintf (stderr, "do nothing yet"); fprintf( stderr, "initialized\n" );
bInitialized = true; bInitialized = true;
} catch (css::uno::Exception & e) { } catch (css::uno::Exception & e) {
fprintf( stderr, "bootstrapping exception '%s'\n", fprintf( stderr, "bootstrapping exception '%s'\n",
......
...@@ -7,16 +7,24 @@ ...@@ -7,16 +7,24 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# #
$(eval $(call gb_CppunitTest_CppunitTest,liblibreoffice)) $(eval $(call gb_Executable_Executable,libtest))
$(eval $(call gb_CppunitTest_abort_on_assertion,liblibreoffice)) $(eval $(call gb_Executable_set_include,libtest,\
$$(INCLUDE) \
$(eval $(call gb_CppunitTest_add_exception_objects,liblibreoffice,\ -I$(SRCDIR)/desktop/inc \
smoketest/libtest \
)) ))
$(eval $(call gb_CppunitTest_use_libraries,liblibreoffice,\ $(eval $(call gb_Executable_use_libraries,libtest,\
libreoffice \ libreoffice \
$(gb_UWINAPI) \
))
$(eval $(call gb_Executable_add_libs,libtest,\
-pthread \
))
$(eval $(call gb_Executable_add_exception_objects,libtest,\
smoketest/libtest \
)) ))
ifeq ($(OS),MACOSX) ifeq ($(OS),MACOSX)
...@@ -24,10 +32,16 @@ liblibreoffice_SOFFICE_INST := $(DEVINSTALLDIR)/opt/LibreOffice.app/Contents/Mac ...@@ -24,10 +32,16 @@ liblibreoffice_SOFFICE_INST := $(DEVINSTALLDIR)/opt/LibreOffice.app/Contents/Mac
else else
liblibreoffice_SOFFICE_INST := $(DEVINSTALLDIR)/opt/program liblibreoffice_SOFFICE_INST := $(DEVINSTALLDIR)/opt/program
endif endif
liblibreoffice_OWN_LD_PATH_DIR := $(liblibreoffice_SOFFICE_INST)/libolib
liblibreoffice_OWN_LD_SO := $(liblibreoffice_OWN_LD_PATH_DIR)/$(call gb_Library_get_linktargetname,libreoffice)
$(eval $(call gb_CppunitTest_add_arguments,liblibreoffice,\ $(liblibreoffice_OWN_LD_SO) : $(call gb_Library_get_target,libreoffice)
-env:arg-soffice=$(liblibreoffice_SOFFICE_INST) \ mkdir -p $(liblibreoffice_OWN_LD_PATH_DIR)/Library
-env:arg-testarg.smoketest.doc=$(OUTDIR)/bin/smoketestdoc.sxw \ cp -a $(call gb_Library_get_target,libreoffice) $(liblibreoffice_OWN_LD_SO)
))
run_libtest: $(liblibreoffice_OWN_LD_SO)
$(gb_Helper_LIBRARY_PATH_VAR)=$${$(gb_Helper_LIBRARY_PATH_VAR):+$$$(gb_Helper_LIBRARY_PATH_VAR):}":$(liblibreoffice_OWN_LD_PATH_DIR)/Library" \
$(call gb_LinkTarget_get_target,Executable/libtest) \
$(liblibreoffice_SOFFICE_INST) $(OUTDIR)/bin/smoketestdoc.sxw \
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
...@@ -42,9 +42,11 @@ $(eval $(call gb_Module_add_targets,smoketest,\ ...@@ -42,9 +42,11 @@ $(eval $(call gb_Module_add_targets,smoketest,\
)) ))
endif endif
ifeq ($(OS),LINUX)
$(eval $(call gb_Module_add_check_targets,smoketest,\ $(eval $(call gb_Module_add_check_targets,smoketest,\
CppunitTest_liblibreoffice \ Executable_libtest \
)) ))
endif
$(eval $(call gb_Module_add_subsequentcheck_targets,smoketest,\ $(eval $(call gb_Module_add_subsequentcheck_targets,smoketest,\
CppunitTest_smoketest \ CppunitTest_smoketest \
......
...@@ -7,60 +7,32 @@ ...@@ -7,60 +7,32 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
// yuck / FIXME ... #include <stdio.h>
#include "../desktop/inc/liblibreoffice.hxx"
#include <assert.h> #include <assert.h>
#include <liblibreoffice.hxx>
#include <sal/types.h> int main (int argc, char **argv)
#include <rtl/ustring.hxx>
#include <rtl/bootstrap.hxx>
#include "cppunit/TestAssert.h"
#include "cppunit/TestFixture.h"
#include "cppunit/extensions/HelperMacros.h"
#include "cppunit/plugin/TestPlugIn.h"
class Test: public CppUnit::TestFixture {
public:
virtual void setUp();
virtual void tearDown();
private:
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(test);
CPPUNIT_TEST_SUITE_END();
void test();
};
void Test::setUp()
{
}
void Test::tearDown()
{
}
void Test::test()
{ {
rtl::OUString aArgSoffice; if( argc < 2 )
rtl::Bootstrap::get( rtl::OUString( "arg-soffice" ), aArgSoffice ); return -1;
OString aInstall = OUStringToOString( aArgSoffice, RTL_TEXTENCODING_UTF8 ); LibLibreOffice *pOffice = lo_init( argv[1] );
fprintf( stderr, "liblibreoffice test: '%s'\n", aInstall.getStr() ); if( !pOffice )
LibLibreOffice *pOffice = lo_init( aInstall.getStr() ); return -1;
CPPUNIT_ASSERT( pOffice != NULL ); // This separate init is lame I think.
if( !pOffice->initialize( argv[1] ) )
bool bInited = pOffice->initialize( aInstall.getStr() ); {
CPPUNIT_ASSERT( bInited ); fprintf( stderr, "failed to initialize\n" );
return -1;
rtl::OUString aArgDoc; }
rtl::Bootstrap::get( rtl::OUString( "arg-testarg.smoketest.doc" ), aArgDoc ); fprintf( stderr, "start to load document '%s'\n", argv[2] );
OString aDoc = OUStringToOString ( aArgDoc, RTL_TEXTENCODING_UTF8 ); LODocument *pDocument = pOffice->documentLoad( argv[2] );
fprintf ( stderr, "liblibreoffice doc arg: '%s'\n", aDoc.getStr() ); if( !pDocument )
pOffice->documentLoad ( aDoc.getStr() ); {
fprintf( stderr, "failed to load document '%s'\n", argv[2] );
return -1;
}
fprintf( stderr, "all tests passed." );
return 0;
} }
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -330,9 +330,8 @@ public: ...@@ -330,9 +330,8 @@ public:
static const Link& GetFilterHdl(); static const Link& GetFilterHdl();
static void EnableHeadlessMode( bool dialogsAreFatal ); static void EnableHeadlessMode( bool dialogsAreFatal );
static sal_Bool IsHeadlessModeEnabled(); static sal_Bool IsHeadlessModeEnabled();
static bool IsHeadlessModeRequested();
static bool IsHeadlessModeRequested();
///< check command line arguments for --headless ///< check command line arguments for --headless
static void ShowNativeErrorBox(const String& sTitle , static void ShowNativeErrorBox(const String& sTitle ,
......
...@@ -1760,7 +1760,7 @@ bool Application::IsHeadlessModeRequested() ...@@ -1760,7 +1760,7 @@ bool Application::IsHeadlessModeRequested()
for (sal_uInt32 i = 0; i < n; ++i) { for (sal_uInt32 i = 0; i < n; ++i) {
rtl::OUString arg; rtl::OUString arg;
rtl_getAppCommandArg(i, &arg.pData); rtl_getAppCommandArg(i, &arg.pData);
if ( arg == "--headless" ) { if ( arg == "--headless" || arg == "-headless" ) {
return true; return true;
} }
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "osl/process.h" #include "osl/process.h"
#include "rtl/ustrbuf.hxx" #include "rtl/ustrbuf.hxx"
#include "rtl/bootstrap.hxx"
#include "salinst.hxx" #include "salinst.hxx"
#include "generic/gensys.h" #include "generic/gensys.h"
...@@ -198,31 +199,22 @@ static SalInstance* autodetect_plugin() ...@@ -198,31 +199,22 @@ static SalInstance* autodetect_plugin()
return pInst; return pInst;
} }
static SalInstance* check_headless_plugin()
{
int nParams = osl_getCommandArgCount();
OUString aParam;
for( int i = 0; i < nParams; i++ )
{
osl_getCommandArg( i, &aParam.pData );
if( aParam == "-headless" || aParam == "--headless" )
{
return tryInstance("svp");
}
}
return NULL;
}
SalInstance *CreateSalInstance() SalInstance *CreateSalInstance()
{ {
SalInstance* pInst = NULL; SalInstance *pInst = NULL;
OUString aUsePlugin;
static const char* pUsePlugin = getenv( "SAL_USE_VCLPLUGIN" ); static const char* pUsePlugin = getenv( "SAL_USE_VCLPLUGIN" );
if( pUsePlugin )
aUsePlugin = OUString::createFromAscii( pUsePlugin );
else
rtl::Bootstrap::get( "SAL_USE_VCLPLUGIN", aUsePlugin );
pInst = check_headless_plugin(); if( Application::IsHeadlessModeRequested() )
aUsePlugin = "svp";
if( !pInst && pUsePlugin && *pUsePlugin ) if( !aUsePlugin.isEmpty() )
pInst = tryInstance( OUString::createFromAscii( pUsePlugin ), true ); pInst = tryInstance( aUsePlugin );
if( ! pInst ) if( ! pInst )
pInst = autodetect_plugin(); pInst = autodetect_plugin();
......
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