Makefile.am | 11 ++++- configure.ac | 2 test/Makefile.am | 109 +++++++++++++++++++++++----------------------------- test/run_unit.sh.in | 2 wsd/LOOLWSD.cpp | 16 +++++++ wsd/LOOLWSD.hpp | 1 6 files changed, 76 insertions(+), 65 deletions(-)
New commits: commit 9a427524d11908e2b8c475e7c6328563f300f076 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> AuthorDate: Sun Jun 28 11:30:22 2020 -0400 Commit: Ashod Nakashian <ashnak...@gmail.com> CommitDate: Wed Jul 1 06:14:39 2020 +0200 wsd: support --cleanup in loolwsd Leaving behind jails with bind-mount entries makes build-workspace removal complicated, and jenkins builds start failing. The cleanup stage is integrated in Makefiles and should be transparent. In the event that manual cleanup is necessary, 'loolwsd --cleanup' can be invoked. Change-Id: Ia4b99b0c66e56dfa2d50e79b0ba98f714cf32886 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97470 Tested-by: Jenkins Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/Makefile.am b/Makefile.am index d3f18e6a3..0eba81cf5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -321,6 +321,8 @@ EXTRA_DIST = discovery.xml \ scripts/unocommands.py \ $(man_MANS) +CLEANUP_COMMAND=if test -s ./loolwsd; then echo "Cleaning up..." && ./loolwsd --cleanup --o:logging.level=trace; fi + if HAVE_LO_PATH SYSTEM_STAMP = @SYSTEMPLATE_PATH@/system_stamp @@ -328,13 +330,16 @@ CAPABILITIES = $(if @ENABLE_SETCAP@,true,false) RUN_GDB = $(if $(GDB_FRONTEND),$(GDB_FRONTEND),gdb --tui --args) $(SYSTEM_STAMP) : ${top_srcdir}/loolwsd-systemplate-setup + if test -s ./loolwsd; then ./loolwsd --cleanup; fi 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 $@ + $(CLEANUP_COMMAND) clean-local: + $(CLEANUP_COMMAND) if test "z@JAILS_PATH@" != "z"; then rm -rf "@JAILS_PATH@"; fi if test "z@SYSTEMPLATE_PATH@" != "z"; then rm -rf "@SYSTEMPLATE_PATH@"; fi rm -f $(abs_srcdir)/compile_commands.json @@ -457,8 +462,9 @@ endif # installing. When building for packaging, no need for this, as the # capabilities won't survive packaging anyway. Instead, handle it when # installing the RPM or Debian package. +.PHONY: caps_bins -all-local: loolforkit loolmount @JAILS_PATH@ $(SYSTEM_STAMP) +caps_bins: loolforkit loolmount if ENABLE_SETCAP sudo @SETCAP@ cap_fowner,cap_mknod,cap_sys_chroot=ep loolforkit sudo @SETCAP@ cap_sys_admin=ep loolmount @@ -466,6 +472,9 @@ else echo "Skipping capability setting" endif +all-local: loolwsd caps_bins @JAILS_PATH@ $(SYSTEM_STAMP) + $(CLEANUP_COMMAND) + # just run the build without any tests build-nocheck: all-am diff --git a/configure.ac b/configure.ac index 740dc2e3c..7a8177e91 100644 --- a/configure.ac +++ b/configure.ac @@ -1140,7 +1140,7 @@ if test "$enable_androidapp" = "yes"; then $srcdir/android/lib/src/main/cpp/CMakeLists.txt:android/lib/src/main/cpp/CMakeLists.txt.in]) fi -AC_CONFIG_FILES([test/run_unit.sh:test/run_unit.sh.in],[chmod +x test/run_unit.sh]) +AC_CONFIG_FILES([test/run_unit.sh],[chmod +x test/run_unit.sh]) AC_OUTPUT diff --git a/test/Makefile.am b/test/Makefile.am index 275a214c2..ad48899a1 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -189,8 +189,11 @@ else SYSTEM_STAMP = endif +CLEANUP_COMMAND=if test -s ../loolwsd; then echo "Cleaning up..." && ../loolwsd --cleanup --o:logging.level=trace; fi + if HAVE_LO_PATH check-local: + $(CLEANUP_COMMAND) ./fakesockettest @fc-cache "@LO_PATH@"/share/fonts/truetype @@ -228,71 +231,57 @@ TESTS = \ # Start forced grouping of tests using stamp files -# unit-base.log -unit-tiletest.log : unit-base.log -unit-integration.log : unit-base.log -unit-httpws.log : unit-base.log -unit-crash.log : unit-base.log - -group1.log: unit-httpws.log unit-crash.log unit-tiletest.log unit-integration.log - touch $@ - -unit-typing.log : group1.log -unit-convert.log : group1.log -unit-tilecache.log : group1.log -unit-timeout.log : group1.log - -group1a.log: unit-typing.log unit-convert.log unit-tilecache.log unit-timeout.log - touch $@ - # isolate this one - it's not a happy test. -unit-copy-paste.log : group1a.log - -group2.log: unit-copy-paste.log - touch $@ - -unit-prefork.log : group2.log -unit-oauth.log : group2.log -unit-wopi.log : group2.log -unit-wopi-saveas.log : group2.log -unit-wopi-ownertermination.log : group2.log -unit-wopi-versionrestore.log : group2.log -unit-wopi-documentconflict.log : group2.log -unit_wopi_renamefile.log : group2.log -unit_wopi_watermark.log : group2.log - -group3.log: unit-oauth.log unit-wopi.log unit-wopi-saveas.log unit-wopi-ownertermination.log unit-wopi-versionrestore.log unit-wopi-documentconflict.log unit_wopi_renamefile.log unit_wopi_watermark.log +group0.log: unit-copy-paste.log touch $@ -unit-http.log : group3.log -unit-tiff-load.log : group3.log -unit-large-paste.log : group3.log -unit-paste.log : group3.log -unit-load-torture.log : group3.log -unit-rendering-options.log : group3.log -unit-password-protected.log : group3.log -unit-render-shape.log : group3.log -unit-each-view.log : group3.log - -group4.log: unit-http.log unit-tiff-load.log unit-large-paste.log unit-paste.log unit-load-torture.log unit-rendering-options.log unit-password-protected.log unit-render-shape.log unit-each-view.log +# group1.log +unit-crash.log : group0.log +unit-tiletest.log : group0.log +unit-insert-delete.log : group0.log +unit-each-view.log : group0.log +unit-httpws.log : group0.log +unit-close.log : group0.log +unit-wopi-documentconflict.log : group0.log +unit-prefork.log : group0.log +unit-wopi-versionrestore.log : group0.log +unit-wopi-temp.log : group0.log +unit_wopi_renamefile.log : group0.log +unit_wopi_watermark.log : group0.log +unit-wopi.log : group0.log +unit-wopi-ownertermination.log : group0.log +unit-load-torture.log : group0.log + +unit-wopi-saveas.log : group0.log +unit-password-protected.log : group0.log +unit-http.log : group0.log +unit-tiff-load.log : group0.log +unit-render-shape.log : group0.log +unit-oauth.log : group0.log +unit-large-paste.log : group0.log +unit-paste.log : group0.log +unit-rendering-options.log : group0.log + +unit-session.log : group0.log +unit-uno-command.log : group0.log +unit-load.log : group0.log +unit-cursor.log : group0.log +unit-calc.log : group0.log +unit-bad-doc-load.log : group0.log +unit-hosting.log : group0.log +unit-wopi-loadencoded.log : group0.log + +unit-integration.log : group0.log +unit-convert.log : group0.log +unit-typing.log : group0.log +unit-tilecache.log : group0.log +unit-timeout.log : group0.log +unit-base.log: group0.log + +group1.log: unit-crash.log unit-tiletest.log unit-insert-delete.log unit-each-view.log unit-httpws.log unit-close.log unit-wopi-documentconflict.log unit-prefork.log unit-wopi-versionrestore.log unit-wopi-temp.log unit_wopi_renamefile.log unit_wopi_watermark.log unit-wopi.log unit-wopi-ownertermination.log unit-load-torture.log unit-wopi-saveas.log unit-password-protected.log unit-http.log unit-tiff-load.log unit-render-shape.log unit-oauth.log unit-large-paste.log unit-paste.log unit-rendering-options.log unit-session.log unit-uno-command.log unit-load.log unit-cursor.log unit-calc.log unit-bad-doc-load.log unit-hosting.log unit-wopi-loadencoded.log unit-integration.log unit-convert.log unit-typing.log unit-tilecache.log unit-timeout.log unit-base.log + $(CLEANUP_COMMAND) touch $@ -unit-session.log : group4.log -unit-uno-command.log : group4.log -unit-load.log : group4.log -unit-cursor.log : group4.log -unit-calc.log : group4.log -unit-insert-delete.log : group4.log - -group5.log: unit-session.log unit-uno-command.log unit-load.log unit-cursor.log unit-calc.log unit-insert-delete.log - touch $@ - -unit-close.log : group5.log -unit-bad-doc-load.log : group5.log -unit-hosting.log : group5.log -unit-wopi-loadencoded.log : group5.log -unit-wopi-temp.log : group5.log - # end forced grouping endif diff --git a/test/run_unit.sh.in b/test/run_unit.sh.in index 6fbfc15e7..4b893f23c 100755 --- a/test/run_unit.sh.in +++ b/test/run_unit.sh.in @@ -74,7 +74,6 @@ echo "Running $tst | $tst_log ..."; if ${trace} \ ${abs_top_builddir}/loolwsd --o:sys_template_path="$systemplate_path" \ --o:child_root_path="$jails_path" \ - --o:mount_jail_tree=false \ --o:storage.filesystem[@allow]=true \ --o:logging.level=trace \ --o:ssl.key_file_path="${abs_top_builddir}/etc/key.pem" \ @@ -91,7 +90,6 @@ else echo "Test failed on unit: $tst re-run with:" echo " $ gdb --args ${abs_top_builddir}/loolwsd --o:sys_template_path=\"$systemplate_path\" \\" echo " --o:child_root_path=\"$jails_path\" \\" - echo " --o:mount_jail_tree=false \\" echo " --o:storage.filesystem[@allow]=true \\" echo " --o:storage.ssl.enable=false \\" echo " --o:logging.level=trace \\" diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 7b99e16f4..6b1900443 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -731,6 +731,7 @@ std::string LOOLWSD::LogLevel = "trace"; std::string LOOLWSD::UserInterface = "classic"; bool LOOLWSD::AnonymizeUserData = false; bool LOOLWSD::CheckLoolUser = true; +bool LOOLWSD::CleanupOnly = false; //< If we should cleanup and exit. bool LOOLWSD::IsProxyPrefixEnabled = false; #if ENABLE_SSL Util::RuntimeConstant<bool> LOOLWSD::SSLEnabled; @@ -1188,6 +1189,13 @@ void LOOLWSD::initialize(Application& self) } else { + if (CleanupOnly) + { + // Cleanup and exit. + JailUtil::cleanupJails(ChildRoot); + std::exit(EX_OK); + } + if (ChildRoot[ChildRoot.size() - 1] != '/') ChildRoot += '/'; @@ -1475,7 +1483,7 @@ void LOOLWSD::defineOptions(OptionSet& optionSet) .required(false) .repeatable(false)); - optionSet.addOption(Option("version-hash", "", "Display product version-hash information.") + optionSet.addOption(Option("version-hash", "", "Display product version-hash information and exit.") .required(false) .repeatable(false)); @@ -1483,6 +1491,10 @@ void LOOLWSD::defineOptions(OptionSet& optionSet) .required(false) .repeatable(false)); + optionSet.addOption(Option("cleanup", "", "Cleanup jails and other temporary data and exit.") + .required(false) + .repeatable(false)); + optionSet.addOption(Option("port", "", "Port number to listen to (default: " + std::to_string(DEFAULT_CLIENT_PORT_NUMBER) + "),") .required(false) @@ -1565,6 +1577,8 @@ void LOOLWSD::handleOption(const std::string& optionName, } else if (optionName == "version") DisplayVersion = true; + else if (optionName == "cleanup") + CleanupOnly = true; // Flag for later as we need the config. else if (optionName == "port") ClientPortNumber = std::stoi(value); else if (optionName == "disable-ssl") diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp index bbc6bc430..654546d30 100644 --- a/wsd/LOOLWSD.hpp +++ b/wsd/LOOLWSD.hpp @@ -245,6 +245,7 @@ public: static std::string LogLevel; static bool AnonymizeUserData; static bool CheckLoolUser; + static bool CleanupOnly; static bool IsProxyPrefixEnabled; static std::atomic<unsigned> NumConnections; static std::unique_ptr<TraceFileWriter> TraceDumper; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits