diff options
Diffstat (limited to 'sal/test')
-rw-r--r-- | sal/test/bootstrap | 82 | ||||
-rwxr-xr-x | sal/test/bootstrap.bat | 79 | ||||
-rw-r--r-- | sal/test/bootstrap.pl | 251 | ||||
-rw-r--r-- | sal/test/bootstraptest.ini | 28 | ||||
-rw-r--r-- | sal/test/makefile.mk | 145 | ||||
-rw-r--r-- | sal/test/test_salmain.cxx | 31 | ||||
-rw-r--r-- | sal/test/test_salmainwithargs.cxx | 31 | ||||
-rw-r--r-- | sal/test/testbootstrap.cxx | 116 | ||||
-rw-r--r-- | sal/test/testbootstrap.ini | 4 |
9 files changed, 767 insertions, 0 deletions
diff --git a/sal/test/bootstrap b/sal/test/bootstrap new file mode 100644 index 0000000000..c12ef19222 --- /dev/null +++ b/sal/test/bootstrap @@ -0,0 +1,82 @@ +#/bin/tcsh +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . +# + +setenv MYBOOTSTRAPTESTVALUE 0 +echo 1 +./testbootstrap 1 -env:MYBOOTSTRAPTESTVALUE=1 + +echo 2 +./testbootstrap.bin file + +echo 3 +./testbootstrap.Bin file + +echo 4 +./testbootstrap.exe file + +echo 5 +./testbootstrap.Exe file + +echo 6 +./testbootstrap 0 -env:INIFILENAME= + +unsetenv MYBOOTSTRAPTESTVALUE +echo 7 +./testbootstrap default -env:INIFILENAME= + +echo 8 +./testbootstrap default -env:MYBOOTSTRAPTESTVALUE2=1 -env:INIFILENAME= + +echo +echo "macro tests" +echo + +# simple macro expansion +echo 9 +./testbootstrap _first_second_third_ -env:FIRST=first -env:SECOND=second -env:THIRD=third -env:MYBOOTSTRAPTESTVALUE='_${FIRST}_${SECOND}_${THIRD}_' + +# simple quoting +echo 10 +./testbootstrap '_${FIRST}_${SECOND}_${THIRD}_' -env:FIRST=first -env:SECOND=second -env:THIRD=third -env:MYBOOTSTRAPTESTVALUE='_\$\{FIRST\}_\$\{SECOND\}_\$\{THIRD\}_' + +# simple ini access +echo 11 +./testbootstrap TheKeysValue -env:'MYBOOTSTRAPTESTVALUE=${./bootstraptest.ini:TheSection:TheKey}' + +# ini access with simple macro expansion +echo 12 +./testbootstrap TheKeysValue -env:ININAME=./bootstraptest.ini -env:SECTIONNAME=TheSection -env:KEYNAME=TheKey \ + -env:'MYBOOTSTRAPTESTVALUE=${$ININAME:$SECTIONNAME:$KEYNAME}' + +# ini access with complex macro expansion +echo 13 +./testbootstrap TheKeysValue -env:ININAME=./bootstraptest.ini \ + -env:'MYBOOTSTRAPTESTVALUE=${$ININAME:${$ININAME:SecondSection:IndirectSection}:${$ININAME:SecondSection:IndirectKey}}' + +# test no infinite recursion +echo 14 +./testbootstrap "***RECURSION DETECTED***" -env:'MYBOOTSTRAPTESTVALUE=$MYBOOTSTRAPTESTVALUE' + +# test unicode +echo 15 +./testbootstrap AAABBBCCC000 -env:'MYBOOTSTRAPTESTVALUE=\u0041\u0041\u0041\u0042\u0042\u0042\u0043\u0043\u0043\u0030\u0030\u0030' + +echo +echo "bootstrap test finished" +echo diff --git a/sal/test/bootstrap.bat b/sal/test/bootstrap.bat new file mode 100755 index 0000000000..f94696ba91 --- /dev/null +++ b/sal/test/bootstrap.bat @@ -0,0 +1,79 @@ +rem +rem This file is part of the LibreOffice project. +rem +rem This Source Code Form is subject to the terms of the Mozilla Public +rem License, v. 2.0. If a copy of the MPL was not distributed with this +rem file, You can obtain one at http://mozilla.org/MPL/2.0/. +rem +rem This file incorporates work covered by the following license notice: +rem +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed +rem with this work for additional information regarding copyright +rem ownership. The ASF licenses this file to you under the Apache +rem License, Version 2.0 (the "License"); you may not use this file +rem except in compliance with the License. You may obtain a copy of +rem the License at http://www.apache.org/licenses/LICENSE-2.0 . +rem +@echo off +set MYBOOTSTRAPTESTVALUE=0 +echo 1 +.\testbootstrap 1 -env:MYBOOTSTRAPTESTVALUE=1 + +echo 2 +.\testbootstrap.exe file + +echo 3 +.\testbootstrap.Exe file + +echo 4 +.\testbootstrap.bin file + +echo 5 +.\testbootstrap.Bin file + +echo 6 +.\testbootstrap 0 -env:INIFILENAME= + +echo 7 +set MYBOOTSTRAPTESTVALUE= +rem simply ignore the file... +.\testbootstrap default -env:INIFILENAME= + +echo 8 +.\testbootstrap default -env:MYBOOTSTRAPTESTVALUE2=1 -env:INIFILENAME= + +echo +echo "macro tests" +echo + +rem simple macro expansion +echo 9 +.\testbootstrap _first_second_third_ -env:FIRST=first -env:SECOND=second -env:THIRD=third -env:MYBOOTSTRAPTESTVALUE=_${FIRST}_${SECOND}_${THIRD}_ + +rem simple quoting +echo 10 +.\testbootstrap _${FIRST}_${SECOND}_${THIRD}_ -env:FIRST=first -env:SECOND=second -env:THIRD=third -env:MYBOOTSTRAPTESTVALUE=_\$\{FIRST\}_\$\{SECOND\}_\$\{THIRD\}_ + +rem simple ini access +echo 11 +.\testbootstrap TheKeysValue -env:MYBOOTSTRAPTESTVALUE=${./bootstraptest.ini:TheSection:TheKey} + +rem ini access with simple macro expansion +echo 12 +.\testbootstrap TheKeysValue -env:ININAME=./bootstraptest.ini -env:SECTIONNAME=TheSection -env:KEYNAME=TheKey -env:MYBOOTSTRAPTESTVALUE=${$ININAME:$SECTIONNAME:$KEYNAME} + +rem ini access with complex macro expansion +echo 13 +.\testbootstrap TheKeysValue -env:ININAME=./bootstraptest.ini -env:MYBOOTSTRAPTESTVALUE=${$ININAME:${$ININAME:SecondSection:IndirectSection}:${$ININAME:SecondSection:IndirectKey}} + +rem test no infinite recursion +echo 14 +.\testbootstrap "***RECURSION DETECTED***" -env:MYBOOTSTRAPTESTVALUE=$MYBOOTSTRAPTESTVALUE + +rem test unicode +echo 15 +.\testbootstrap AAABBBCCC000 -env:MYBOOTSTRAPTESTVALUE=\u0041\u0041\u0041\u0042\u0042\u0042\u0043\u0043\u0043\u0030\u0030\u0030 + + +@echo bootstrap test finished diff --git a/sal/test/bootstrap.pl b/sal/test/bootstrap.pl new file mode 100644 index 0000000000..5dde94f801 --- /dev/null +++ b/sal/test/bootstrap.pl @@ -0,0 +1,251 @@ +: +eval 'exec perl -wS $0 ${1+"$@"}' + if 0; +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . +# + + +my $rc; +my $state = 1; +my $comment = ""; + +$ENV{MYBOOTSTRAPTESTVALUE}=0; + +$rc = system "./testbootstrap", 1, "-env:MYBOOTSTRAPTESTVALUE=1"; +if (!$rc) { + $comment = $comment . "commandline over environment test not passed\n"; + $state = 0; +} + +$rc = system "./testbootstrap", "0", "-env:INIFILENAME="; +if (!$rc) { + $comment = $comment . "exe custom ini test not passed\n"; + $state = 0; +} + +delete $ENV{MYBOOTSTRAPTESTVALUE}; + +$rc = system "./testbootstrap.bin", "file"; +if (!$rc) { + $comment = $comment . "extensions cut test not passed with .bin\n"; + $state = 0; +} + +$rc = system "./testbootstrap.Bin", "file"; +if (!$rc) { + $comment = $comment . "extensions cut test not passed with .Bin\n"; + $state = 0; +} + +$rc = system "./testbootstrap.exe", "file"; +if (!$rc) { + $comment = $comment . "extensions cut test not passed with .exe\n"; + $state = 0; +} + +$rc = system "./testbootstrap.Exe", "file"; +if (!$rc) { + $comment = $comment . "extensions cut test not passed with .Exe\n"; + $state = 0; +} + +if ($ENV{OS} eq "WNT") { + $rc = system "./testbootstrap", "auxaux", "-env:iniName=ini.ini", '-env:MYBOOTSTRAPTESTVALUE=$CUSTOMINIVALUE'; +} +else { + $rc = system "./testbootstrap", "auxaux", "-env:iniName=inirc", '-env:MYBOOTSTRAPTESTVALUE=$CUSTOMINIVALUE'; +} +if (!$rc) { + $comment = $comment . "custom ini test not passed\n"; + $state = 0; +} + +if ($ENV{OS} eq "WNT") { + $comment = $comment . '$SYSUSERHOME not testable under windows' . "\n"; +} +else { + $rc = system "./testbootstrap", "file://$ENV{HOME}", '-env:MYBOOTSTRAPTESTVALUE=$SYSUSERHOME'; + if (!$rc) { + $comment = $comment . '$SYSUSERHOME test not passed' . "\n"; + $state = 0; + } +} + +if ($ENV{OS} eq "WNT") { + $comment = $comment . '$SYSUSERCONFIG' . " not testable under windows\n"; +} +else { + $rc = system "./testbootstrap", "file://$ENV{HOME}", '-env:MYBOOTSTRAPTESTVALUE=$SYSUSERCONFIG'; + if (!$rc) { + $comment = $comment . '$SYSUSERCONFIG test not passed' . "\n"; + $state = 0; + } +} + +if ($ENV{OS} eq "WNT") { + $comment = $comment . '$SYSBINDIR' . " not testable under windows\n"; +} +else { + $rc = system "./testbootstrap", "file://$ENV{PWD}", '-env:MYBOOTSTRAPTESTVALUE=$SYSBINDIR'; + if (!$rc) { + $comment = $comment . '$SYSBINDIR test not passed' . "\n"; + $state = 0; + } +} + +if ($ENV{OS} eq "WNT") { + $rc = system "./testbootstrap", "inherited_value", '-env:MYBOOTSTRAPTESTVALUE=$INHERITED_VALUE', "-env:iniName=ini.ini"; +} +else { + $rc = system "./testbootstrap", "inherited_value", '-env:MYBOOTSTRAPTESTVALUE=$INHERITED_VALUE', "-env:iniName=inirc"; +} +if (!$rc) { + $comment = $comment . "inherited value not passed\n"; + $state = 0; +} + +if ($ENV{OS} eq "WNT") { + $rc = system "./testbootstrap", "not_overwritten", '-env:MYBOOTSTRAPTESTVALUE=$INHERITED_OVERWRITTEN_VALUE', "-env:iniName=ini.ini"; +} +else { + $rc = system "./testbootstrap", "not_overwritten", '-env:MYBOOTSTRAPTESTVALUE=$INHERITED_OVERWRITTEN_VALUE', "-env:iniName=inirc"; +} +if (!$rc) { + $comment = $comment . "inherited overwritten value not passed\n"; + $state = 0; +} + + +$rc = system "./testbootstrap", "defaultvalue", "-env:INIFILENAME=", "-env:Default=defaultvalue", "-env:USEDEFAULT=1"; +if (!$rc) { + $comment = $comment . "default test from parameter not passed\n"; + $state = 0; +} + +if ($ENV{OS} eq "WNT") { + $rc = system "./testbootstrap", "defaultValue", "-env:iniName=default.ini", "-env:INIFILENAME=", "-env:USEDEFAULT=1"; +} +else { + $rc = system "./testbootstrap", "defaultValue", "-env:iniName=defaultrc", "-env:INIFILENAME=", "-env:USEDEFAULT=1"; +} +if (!$rc) { + $comment = $comment . "default test from custom ini not passed\n"; + $state = 0; +} + +# simple macro expansion +$rc = system "./testbootstrap", + "_first_second_third_", + "-env:FIRST=first", + "-env:SECOND=second", + "-env:THIRD=third", + '-env:MYBOOTSTRAPTESTVALUE=_${FIRST}_${SECOND}_${THIRD}_'; +if (!$rc) { + $comment = $comment . "simple macro expansion test not passed\n"; + $state = 0; +} + +# simple quoting +$rc = system "./testbootstrap", + '_${FIRST}_${SECOND}_${THIRD}_', + "-env:FIRST=first", + "-env:SECOND=second", + "-env:THIRD=third", + '-env:MYBOOTSTRAPTESTVALUE=_\$\{FIRST\}_\$\{SECOND\}_\$\{THIRD\}_'; +if (!$rc) { + $comment = $comment . "simple macro quoting test not passed\n"; + $state = 0; +} + +# simple ini access +$rc = system "./testbootstrap", + "TheIniKeysValue", + '-env:MYBOOTSTRAPTESTVALUE=${./bootstraptest.ini:TheIniKey}'; +if (!$rc) { + $comment = $comment . "simple macro ini access test not passed\n"; + $state = 0; +} + +# simple profile access +$rc = system "./testbootstrap", + "TheKeysValue", + '-env:MYBOOTSTRAPTESTVALUE=${./bootstraptest.ini:TheSection:TheKey}'; +if (!$rc) { + $comment = $comment . "simple macro profile access test not passed\n"; + $state = 0; +} + +# profile access with simple macro expansion +$rc = system "./testbootstrap", + "TheKeysValue", + "-env:ININAME=./bootstraptest.ini", + "-env:SECTIONNAME=TheSection", + "-env:KEYNAME=TheKey", + '-env:MYBOOTSTRAPTESTVALUE=${$ININAME:$SECTIONNAME:$KEYNAME}'; +if (!$rc) { + $comment = $comment . "profile access with simple macro expansion test not passed\n"; + $state = 0; +} + +# profile access with complex macro expansion +$rc = system "./testbootstrap", + "TheKeysValue", + "-env:ININAME=./bootstraptest.ini", + '-env:MYBOOTSTRAPTESTVALUE=${$ININAME:${$ININAME:SecondSection:IndirectSection}:${$ININAME:SecondSection:IndirectKey}}'; +if (!$rc) { + $comment = $comment . "profile access with complex macro expansion test not passed\n"; + $state = 0; +} + +# test no infinite recursion +if ($ENV{OS} eq "WNT") { + $rc = system "./testbootstrap", + '"***RECURSION DETECTED***"', + '-env:MYBOOTSTRAPTESTVALUE=$MYBOOTSTRAPTESTVALUE'; +} +else { + $rc = system "./testbootstrap", + '***RECURSION DETECTED***', + '-env:MYBOOTSTRAPTESTVALUE=$MYBOOTSTRAPTESTVALUE'; +} +if (!$rc) { + $comment = $comment . "no infinite recursion test not passed\n"; + $state = 0; +} + +# test unicode +$rc = system "./testbootstrap", + "AAABBBCCC000", + '-env:MYBOOTSTRAPTESTVALUE=\u0041\u0041\u0041\u0042\u0042\u0042\u0043\u0043\u0043\u0030\u0030\u0030'; +if (!$rc) { + $comment = $comment . "unicode not passed\n"; + $state = 0; +} + +print "**************************\n"; +if($state) { + print "****** tests passed ******\n"; +} +else { + print "**** tests NOT passed ****\n"; + print "Comment:\n", $comment, "\n"; +} +print "**************************\n"; + + + diff --git a/sal/test/bootstraptest.ini b/sal/test/bootstraptest.ini new file mode 100644 index 0000000000..6be9615e2e --- /dev/null +++ b/sal/test/bootstraptest.ini @@ -0,0 +1,28 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . +# + +TheIniKey=TheIniKeysValue + +[TheSection] +TheKey=TheKeysValue + +[SecondSection] +IndirectSection=TheSection +IndirectKey=TheKey + + diff --git a/sal/test/makefile.mk b/sal/test/makefile.mk new file mode 100644 index 0000000000..25aa5dd5fa --- /dev/null +++ b/sal/test/makefile.mk @@ -0,0 +1,145 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . +# + +PRJ=.. + +PRJNAME=sal +TARGET=saltest +TARGETTYPE=CUI +LIBTARGET=NO +USE_LDUMP2=TRUE +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +CFLAGS+= $(LFS_CFLAGS) +CXXFLAGS+= $(LFS_CFLAGS) + +# ------------------------------------------------------------------ + +.IF "$(OS)"=="WNT" +BOOTSTRAPSCRIPT=bootstrap.bat +BOOTSTRAPINI=testbootstrap.ini +MY_SCRIPTCAT=cat +.ELSE +BOOTSTRAPSCRIPT=bootstrap +BOOTSTRAPINI=testbootstraprc +MY_SCRIPTCAT=tr -d "\015" < +.ENDIF + +APP2OBJS = $(OBJ)$/testbootstrap.obj + +OBJFILES= \ + $(APP2OBJS) + +APP2TARGET = testbootstrap +APP2STDLIBS = $(SALLIB) + +APP3OBJS = $(OBJ)$/test_salmain.obj +APP3TARGET = test_salmain +APP3STDLIBS = $(SALLIB) + +APP4OBJS = $(OBJ)$/test_salmainwithargs.obj +APP4TARGET = test_salmainwithargs +APP4STDLIBS = $(SALLIB) + + +# --- Targets ------------------------------------------------------ + +.IF "$(depend)" == "" +ALL : ALLTAR \ + $(BIN)$/$(BOOTSTRAPSCRIPT) \ + $(BIN)$/$(BOOTSTRAPINI) \ + $(BIN)$/bootstraptest.ini \ + $(BIN)$/$(APP2TARGET).bin \ + $(BIN)$/$(APP2TARGET).Bin \ + $(BIN)$/$(APP2TARGET).Exe \ + $(BIN)$/bootstrap.pl + + +.IF "$(OS)"!="WNT" +ALL: $(BIN)$/$(APP2TARGET).exe \ + $(BIN)$/inirc \ + $(BIN)$/defaultrc + +$(BIN)$/$(APP2TARGET).exe : $(APP2TARGETN) + cp $(APP2TARGETN) $@ + +$(BIN)$/inirc: + echo "CUSTOMINIVALUE=auxaux" > $@ + echo "INHERITED_OVERWRITTEN_VALUE=inherited_overwritten_value" >> $@ + +$(BIN)$/defaultrc: + echo "Default=defaultValue" > $@ + +.ELSE + +ALL: $(BIN)$/ini.ini \ + $(BIN)$/default.ini + +$(BIN)$/ini.ini: + echo CUSTOMINIVALUE=auxaux > $@ + echo INHERITED_OVERWRITTEN_VALUE=inherited_overwritten_value >> $@ + + +$(BIN)$/default.ini: + echo Default=defaultValue > $@ + +.ENDIF + +$(BIN)$/bootstrap.pl: + cp bootstrap.pl $@ + +$(BIN)$/$(APP2TARGET).bin : $(APP2TARGETN) + cp $(APP2TARGETN) $@ + +$(BIN)$/$(APP2TARGET).Bin : $(APP2TARGETN) + cp $(APP2TARGETN) $@ + +$(BIN)$/$(APP2TARGET).Exe : $(APP2TARGETN) + cp $(APP2TARGETN) $@ + +.ELSE +ALL: ALLDEP +.ENDIF + +.INCLUDE : target.mk + + +$(BIN)$/$(BOOTSTRAPSCRIPT) : $(BOOTSTRAPSCRIPT) + $(MY_SCRIPTCAT) $(BOOTSTRAPSCRIPT) > $@ +.IF "$(OS)"!="WNT" + chmod ug+x $@ +.ENDIF + +$(BIN)$/$(BOOTSTRAPINI) : $(APP2TARGET).ini + $(MY_SCRIPTCAT) $(APP2TARGET).ini > $@ + +$(BIN)$/bootstraptest.ini : bootstraptest.ini + $(MY_SCRIPTCAT) bootstraptest.ini > $@ + + +# --- SO2-Filter-Datei --- + +$(MISC)$/tsl$(DLLPOSTFIX).flt: + @echo ------------------------------ + @echo Making: $@ + @echo WEP>$@ + @echo LIBMAIN>>$@ + @echo LibMain>>$@ diff --git a/sal/test/test_salmain.cxx b/sal/test/test_salmain.cxx new file mode 100644 index 0000000000..93984e582c --- /dev/null +++ b/sal/test/test_salmain.cxx @@ -0,0 +1,31 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#include "sal/main.h" + +#include <stdio.h> + +SAL_IMPLEMENT_MAIN() +{ + fprintf(stderr, "success!\n"); + + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/test/test_salmainwithargs.cxx b/sal/test/test_salmainwithargs.cxx new file mode 100644 index 0000000000..405cd91c24 --- /dev/null +++ b/sal/test/test_salmainwithargs.cxx @@ -0,0 +1,31 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#include "sal/main.h" + +#include <stdio.h> + +SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) +{ + fprintf(stderr, "argc: %i argv: %p - success!\n", argc, argv); + + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/test/testbootstrap.cxx b/sal/test/testbootstrap.cxx new file mode 100644 index 0000000000..9ae34f78c5 --- /dev/null +++ b/sal/test/testbootstrap.cxx @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#include <stdio.h> + +#include <rtl/process.h> +#include <rtl/bootstrap.hxx> +#include <rtl/string.hxx> +#include <rtl/byteseq.hxx> + +#include <osl/process.h> +#include <sal/log.hxx> + +int main( int argc, char *argv[] ) +{ + osl_setCommandArgs (argc, argv); + + sal_Int32 nCount = rtl_getAppCommandArgCount(); + +#if OSL_DEBUG_LEVEL > 0 + OUStringBuffer debugBuff; + debugBuff.append("rtl-commandargs (").append(nCount).append(")real args: ").append(argc); + for( sal_Int32 i = 0 ; i < nCount ; i ++ ) + { + OUString data; + rtl_getAppCommandArg( i , &(data.pData) ); + OString o = OUStringToOString( data, RTL_TEXTENCODING_ASCII_US ); + debugBuff.append(" ").append(o); + } + SAL_INFO("sal.test", debugBuff.toString()); +#endif + + if( nCount == 0 ) + { + printf( "usage : testbootstrap <checkedValueOfMyBootstrapValue>\n" ); + exit( 1 ); + } + + OUString iniName; + Bootstrap::get(OUString("iniName"), iniName, OUString()); + + SAL_INFO_IF(!iniName.isEmpty(), "sal.test", "using ini: " << iniName); + + Bootstrap bootstrap(iniName); + + OUString name( "MYBOOTSTRAPTESTVALUE" ); + OUString myDefault("$Default"); + + OUString value; + sal_Bool useDefault; + + OUString aDummy; + useDefault = bootstrap.getFrom(OUString("USEDEFAULT"), aDummy); + + sal_Bool result = sal_False; + sal_Bool found = sal_True; + + if(useDefault) + bootstrap.getFrom(name, value, myDefault); + + else + found = bootstrap.getFrom(name, value); + + if(found) + { + OUString para(OUString::createFromAscii( argv[1] )); + + result = para == value; + + if(!result) + { + OString para_tmp = OUStringToOString(para, RTL_TEXTENCODING_ASCII_US); + OString value_tmp = OUStringToOString(value, RTL_TEXTENCODING_ASCII_US); + + fprintf(stderr, "para(%s) != value(%s)\n", para_tmp.getStr(), value_tmp.getStr()); + } + } + else + fprintf(stderr, "bootstrap parameter couldn't be found\n"); + + // test the default case + name = "no_one_has_set_this_name"; + OSL_ASSERT( ! bootstrap.getFrom( name, value ) ); + result = result && !bootstrap.getFrom( name, value ); + + myDefault = "1"; + OUString myDefault2 = "2"; + + bootstrap.getFrom( name, value, myDefault ); + OSL_ASSERT( value == myDefault ); + result = result && (value == myDefault); + + bootstrap.getFrom( name, value, myDefault2 ); + OSL_ASSERT( value == myDefault2 ); + result = result && (value == myDefault2); + + return result; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/test/testbootstrap.ini b/sal/test/testbootstrap.ini new file mode 100644 index 0000000000..2cf7b667cd --- /dev/null +++ b/sal/test/testbootstrap.ini @@ -0,0 +1,4 @@ +MYBOOTSTRAPTESTVALUE=file +INHERITED_VALUE=inherited_value +INHERITED_OVERWRITTEN_VALUE=not_overwritten + |