loolwsd/Makefile.am | 22 ++++++++++++++ loolwsd/README | 66 ++++++++++++++++++++++++++------------------ loolwsd/configure.ac | 14 ++++++++- loolwsd/test/.gitignore | 2 + loolwsd/test/Makefile.am | 30 +++----------------- loolwsd/test/data/hello.odt |binary loolwsd/test/run_test.sh.in | 33 ++++++++++++++++++++++ loolwsd/test/run_unit.sh | 25 ---------------- loolwsd/test/run_unit.sh.in | 32 +++++++++++++++++++++ 9 files changed, 145 insertions(+), 79 deletions(-)
New commits: commit ea1e2493bf64a8ec4ac5b5791d10c9ea896a01a7 Author: Michael Meeks <[email protected]> Date: Mon Apr 11 18:21:16 2016 +0100 Re-factor tests, move jails & systemplate up a level into loolwsd. Also generate the test scripts with config.status containing absolute paths to make them easier to run, and enable the older unit tests. diff --git a/loolwsd/Makefile.am b/loolwsd/Makefile.am index c35b39c..0a336fe 100644 --- a/loolwsd/Makefile.am +++ b/loolwsd/Makefile.am @@ -86,6 +86,26 @@ EXTRA_DIST = discovery.xml \ loolwsd.service \ sysconfig.loolwsd +if HAVE_LO_PATH + +@SYSTEMPLATE_PATH@/system_stamp : + if test "z@SYSTEMPLATE_PATH@" != "z"; then rm -rf "@SYSTEMPLATE_PATH@"; fi + ${top_srcdir}/loolwsd-systemplate-setup "@SYSTEMPLATE_PATH@" "@LO_PATH@" && touch $@ + +@JAILS_PATH@ : + mkdir -p $@ + +clean-local: + if test "z@JAILS_PATH@" != "z"; then rm -rf "@JAILS_PATH@"; fi + if test "z@SYSTEMPLATE_PATH@" != "z"; then rm -rf "@SYSTEMPLATE_PATH@"; fi + +run: @JAILS_PATH@ @SYSTEMPLATE_PATH@/system_stamp + @echo "Launching loolwsd - launch this in your browser:" + @echo " https://localhost:9980/loleaflet/dist/loleaflet.html?file_path=file://$(abs_top_srcdir)/test/data/hello.odt&host=wss://localhost:9980" + ./loolwsd --systemplate="@SYSTEMPLATE_PATH@" --lotemplate="@LO_PATH@" \ + --childroot="@JAILS_PATH@" --allowlocalstorage +endif + clean-cache: # Intentionally don't use "*" below... Avoid risk of accidentally running rm -rf /* test -n "@LOOLWSD_CACHEDIR@" && rm -rf "@LOOLWSD_CACHEDIR@"/[0-9a-f] @@ -96,7 +116,7 @@ clean-cache: # capabilities won't survive packaging anyway. Instead, handle it when # installing the RPM or Debian package. -all-local: loolforkit certificates +all-local: loolforkit certificates @JAILS_PATH@ @SYSTEMPLATE_PATH@/system_stamp if test "$$BUILDING_FROM_RPMBUILD" != yes; then \ sudo @SETCAP@ cap_fowner,cap_mknod,cap_sys_chroot=ep loolforkit; \ sudo @SETCAP@ cap_sys_admin=ep loolmount; \ diff --git a/loolwsd/README b/loolwsd/README index 7034b9d..618fe6c 100644 --- a/loolwsd/README +++ b/loolwsd/README @@ -36,7 +36,8 @@ possibly iterating several times... and then - ./configure --enable-silent-rules --with-lokit-path=${MASTER}/include + ./configure --enable-silent-rules --with-lokit-path=${MASTER}/include \ + --with-lo-path=${MASTER}/instdir --enable-debug make @@ -44,7 +45,7 @@ where ${MASTER} is the location of the LibreOffice source tree. When building from a tarball less magic is needed. -Run 'make check' after each commit. Requires loolwsd to be running. +Run 'make check' after each commit. Note that the loolforkit program needs the CAP_SYS_CHROOT capability, thus you will be asked the root password when running make as it @@ -79,7 +80,22 @@ If you're using the defaults you'll need to: sudo mkdir -p /usr/local/var/cache/loolwsd sudo chown `whoami` /usr/local/var/cache/loolwsd -Now you need to set up a minimal chroot system, and directory for the jails: +Now you can just do: + + make run + +and follow the link that recommends (see loleaflet/README for more info). + +Again, ${MASTER} is location of the LibreOffice source tree with a built +LibreOffice. This is work in progress, and consequently needs the latest +LibreOffice master. + + +Running manually +---------------- + +If you want to do the 'make run' yourself, you need to set up a minimal +chroot system, and directory for the jails: SYSTEMPLATE=`pwd`/systemplate # or tweak for your system ROOTFORJAILS=`pwd`/jails # or tweak for your system @@ -93,12 +109,6 @@ now do: ./loolwsd --systemplate=${SYSTEMPLATE} --lotemplate=${MASTER}/instdir --childroot=${ROOTFORJAILS} -and connect loleaflet to that (see loleaflet/README for more info). - -Again, ${MASTER} is location of the LibreOffice source tree with a built -LibreOffice. This is work in progress, and consequently needs the latest -LibreOffice master. - The ${SYSTEMPLATE} is a directory tree set up using the loolwsd-systemplate-setup script here. (It should not exist before running the script.) It will contain the runtime environment needed by @@ -114,24 +124,26 @@ ${SYSTEMPLATE} and the ${MASTER}/instdir directories into each chroot jail, ${SYSTEMPLATE} and ${MASTER}/instdir need to be on the same file system as ${ROOTFORJAILS}. -Leaflet files are served itself by loolwsd internal file server. You can specify the -root of this fileserver using the --fileserverroot flag in loolwsd commandline. -By default, if you do not specify this flag, the parent directory of loolwsd/ -is assumed to be the fileserverroot. So, for development purposes, you can access -the leaflet files (using /loleaflet/), but it is advised to explicitly set the -fileserverroot to prevent any unwanted files from reading, especially when lool -is deployed for normal public usage on servers. - -Please note that it is necessary that all the leaflet files that are meant to be -served is under a directory named 'loleaflet'. Since, the loleaflet files, in -lool git repo, are itself in a directory named 'loleaflet', this would work out of -the box for development purposes. - -loolwsd only runs on HTTPS which means you would have to set up your own private -key and certificate (in PEM format only). Currently, loolwsd assumes files with -name cert.pem, and key.pem to be certificate and private key respectively. -Dummy self-signed cert.pem and key.pem are already included, but it is better -to replace those with your own files. +Leaflet files are served itself by loolwsd internal file server. You +can specify the root of this fileserver using the --fileserverroot +flag in loolwsd commandline. By default, if you do not specify this +flag, the parent directory of loolwsd/ is assumed to be the +fileserverroot. So, for development purposes, you can access the +leaflet files (using /loleaflet/), but it is advised to explicitly set +the fileserverroot to prevent any unwanted files from reading, +especially when lool is deployed for normal public usage on servers. + +Please note that it is necessary that all the leaflet files that are +meant to be served is under a directory named 'loleaflet'. Since, the +loleaflet files, in lool git repo, are itself in a directory named +'loleaflet', this would work out of the box for development purposes. + +loolwsd only runs on HTTPS which means you would have to set up your +own private key and certificate (in PEM format only). Currently, +loolwsd assumes files with name cert.pem, and key.pem to be +certificate and private key respectively. Dummy self-signed cert.pem +and key.pem are already included, but it is better to replace those +with your own files. If you plan to hack on loolwsd, you probably want to familiarize yourself with loolwsd's --test and --numprespawns switches, and the diff --git a/loolwsd/configure.ac b/loolwsd/configure.ac index 5434980..bd33091 100644 --- a/loolwsd/configure.ac +++ b/loolwsd/configure.ac @@ -78,7 +78,7 @@ AS_IF([test "$enable_debug" = yes -a -n "$with_poco_libs"], [POCO_DEBUG_SUFFIX=]) AS_IF([test "$enable_debug" = yes], - [AC_DEFINE([ENABLE_DEBUG],1,[Whether to compile in some extra debugging support code])]) + [AC_DEFINE([ENABLE_DEBUG],1,[Whether to compile in some extra debugging support code and disable some security pieces ])]) # Test for build environment @@ -97,12 +97,16 @@ dnl dnl lo_path is not required; but useful for testing. dnl LO_PATH= +JAIL_PATH=not-set +SYSTEMPLATE_PATH=not-set have_lo_path=false AC_MSG_CHECKING([whether to run tests against a LibreOffice]) if test -n "$with_lo_path"; then version_file="$with_lo_path/program/versionrc" if test -f $version_file; then LO_PATH="$with_lo_path" + JAILS_PATH="\${abs_top_builddir}/jails" + SYSTEMPLATE_PATH="\${abs_top_builddir}/systemplate" have_lo_path=true lo_msg="test against $LO_PATH" AC_MSG_RESULT([yes]) @@ -114,6 +118,8 @@ else AC_MSG_RESULT([no]) fi AC_SUBST(LO_PATH) +AC_SUBST(JAILS_PATH) +AC_SUBST(SYSTEMPLATE_PATH) AM_CONDITIONAL(HAVE_LO_PATH,[test "$have_lo_path" = "true"]) AS_IF([test -n "$with_poco_includes"], @@ -209,6 +215,9 @@ AC_SUBST(LOOLWSD_CONFIGDIR) AC_CONFIG_FILES([Makefile test/Makefile loolwsd.spec]) +AC_CONFIG_FILES([test/run_unit.sh],[chmod +x test/run_unit.sh]) +AC_CONFIG_FILES([test/run_test.sh],[chmod +x test/run_test.sh]) + AC_OUTPUT AC_LANG_POP @@ -220,6 +229,9 @@ Configuration: LOKit path ${lokit_msg} LO integration tests ${lo_msg} SSL support ${enable_ssl} + + Systemplate path ${systemplate_msg} + Jail path ${jail_msg} " dnl vim:set shiftwidth=4 softtabstop=4 expandtab: diff --git a/loolwsd/test/.gitignore b/loolwsd/test/.gitignore index 2016409..908d52e 100644 --- a/loolwsd/test/.gitignore +++ b/loolwsd/test/.gitignore @@ -9,3 +9,5 @@ Makefile.in *.lo *.o test +run_unit.sh +run_test.sh diff --git a/loolwsd/test/Makefile.am b/loolwsd/test/Makefile.am index f0a9c21..49c2567 100644 --- a/loolwsd/test/Makefile.am +++ b/loolwsd/test/Makefile.am @@ -1,9 +1,6 @@ # variables for tests jails=${top_builddir}/test/jails systemplate=${top_builddir}/test/systemplate -export jails -export systemplate -export LO_PATH AUTOMAKE_OPTION = serial-tests @@ -16,10 +13,8 @@ lib_LTLIBRARIES = unit-timeout.la unit-prefork.la unit-storage.la AM_CPPFLAGS = -pthread -I$(top_srcdir) test_CPPFLAGS = -DTDOC=\"$(top_srcdir)/test/data\" - -test_LDADD = $(CPPUNIT_LIBS) - test_SOURCES = httpposttest.cpp httpwstest.cpp test.cpp ../LOOLProtocol.cpp +test_LDADD = $(CPPUNIT_LIBS) # unit test modules: unit_timeout_la_SOURCES = UnitTimeout.cpp @@ -29,34 +24,19 @@ unit_prefork_la_LDFLAGS = -module unit_storage_la_SOURCES = UnitStorage.cpp unit_storage_la_LDFLAGS = -module -${systemplate}/system_stamp : - rm -rf ${systemplate} - ${top_srcdir}/loolwsd-systemplate-setup ${systemplate} ${LO_PATH} && touch ${systemplate}/system_stamp - -${jails} : - mkdir -p ${jails} - ${top_builddir}/test/run_unit.sh.log ${top_builddir}/test/run_unit.sh.trs : \ - ${systemplate}/system_stamp ${jails} \ + ${systemplate}/system_stamp @JAILS_PATH@ \ ${top_srcdir}/test/run_unit.sh \ - ${top_builddir}/loolwsd \ - ${top_builddir}/loolforkit \ - unit-timeout.la unit-prefork.la unit-storage.la + ${top_builddir}/loolwsd ${top_builddir}/loolforkit \ + $(wildcard *.la) if ${top_srcdir}/test/run_unit.sh; then \ touch ${top_builddir}/test/run_unit.sh.log; \ fi if HAVE_LO_PATH -TESTS = ${top_builddir}/test/run_unit.sh ${top_builddir}/test/test - -clean-local: - rm -rf ${top_builddir}/test/jails - rm -rf ${systemplate} - rm -f ${top_builddir}/test/unit_stamp; +TESTS = ${top_srcdir}/test/run_unit.sh ${top_srcdir}/test/run_test.sh else TESTS = ${top_builddir}/test/test endif EXTRA_DIST = data/hello.odt data/hello.txt $(test_SOURCES) run_unit.sh - - diff --git a/loolwsd/test/data/hello.odt b/loolwsd/test/data/hello.odt index 8340bfb..9624a1c 100644 Binary files a/loolwsd/test/data/hello.odt and b/loolwsd/test/data/hello.odt differ diff --git a/loolwsd/test/run_test.sh.in b/loolwsd/test/run_test.sh.in new file mode 100755 index 0000000..84d907b --- /dev/null +++ b/loolwsd/test/run_test.sh.in @@ -0,0 +1,33 @@ +#!/bin/sh +# +# DO NOT EDIT - this file is generated from run_test.sh.in. +# + +abs_top_builddir="@abs_top_builddir@" +test_build="${abs_top_builddir}/test" +test_output="$test_build/run_test.sh.trs" +test_log_output="$test_build/test_output" + +mkdir -p $test_log_output + +# result logging +echo > $test_output + +${abs_top_builddir}/loolwsd --systemplate="@SYSTEMPLATE_PATH@" --lotemplate="@LO_PATH@" \ + --childroot="@JAILS_PATH@" --allowlocalstorage 2>$test_log_output/run_test.log & + +sleep 1 # sad - need to add a wait to the start of test.cpp ... + +cd $test_build +if ./test; then + echo "Test run_test.sh passed." + echo ":test-result: PASS run_test.sh" >> $test_output +else + cat $test_log_output/run_test.log + echo "=============================================================" + echo "Test failed on unit:" + echo "=============================================================" + echo ":test-result: FAIL run_test.sh" >> $test_output +fi + +kill $! diff --git a/loolwsd/test/run_unit.sh b/loolwsd/test/run_unit.sh.in similarity index 56% rename from loolwsd/test/run_unit.sh rename to loolwsd/test/run_unit.sh.in index a86fb70..b9bc830 100755 --- a/loolwsd/test/run_unit.sh +++ b/loolwsd/test/run_unit.sh.in @@ -1,7 +1,12 @@ #!/bin/sh +# +# DO NOT EDIT - this file is generated from run_unit.sh.in. +# export LOOL_LOGLEVEL=trace +abs_top_builddir="@abs_top_builddir@" + mkdir -p test_output # result logging @@ -10,14 +15,16 @@ echo > run_unit.sh.trs for tst in timeout storage prefork; do tst_log="test_output/$tst.log" echo "Running test: $tst | $tst_log ..."; - if ../loolwsd --systemplate=${systemplate} --lotemplate="${LO_PATH}" --childroot="${jails}" --unitlib=".libs/unit-$tst.so" 2> "$tst_log"; then + if ../loolwsd --systemplate="@SYSTEMPLATE_PATH@" --lotemplate="@LO_PATH@" \ + --childroot="@JAILS_PATH@" --unitlib=".libs/unit-$tst.so" 2> "$tst_log"; then echo "Test $tst passed." echo ":test-result: PASS $tst" >> run_unit.sh.trs else cat "$tst_log" echo "=============================================================" echo "Test failed on unit: $tst re-run with:" - echo " $ gdb --args ../loolwsd --systemplate=${systemplate} --lotemplate=\"${LO_PATH}\" --childroot=\"${jails}\" --unitlib=\".libs/unit-$tst.so\"" + echo " $ gdb --args ../loolwsd --systemplate=\"@SYSTEMPLATE_PATH@\" --lotemplate=\"@LO_PATH@\" \\" + echo " --childroot=\"@JAILS_PATH@\" --unitlib=\".libs/unit-$tst.so\"" echo "=============================================================" echo ":test-result: FAIL $tst" >> run_unit.sh.trs fi _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
