From b409d7b15789998b9ec0dcefa858d4ed2aae0012 Mon Sep 17 00:00:00 2001
From: Simon McVittie <simon.mcvittie@collabora.co.uk>
Date: Wed, 6 Jul 2016 19:39:28 +0100
Subject: [PATCH] libreoffice: work in a directory that LibreOffice can
 legitimately write

This means we don't have to worry about whether the ${TESTDIR}
is allowed by its AppArmor profile (it shouldn't really be).

Reviewed-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D3632
---
 libreoffice/automated/run-test.sh | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libreoffice/automated/run-test.sh b/libreoffice/automated/run-test.sh
index 4de4cb9..507b496 100755
--- a/libreoffice/automated/run-test.sh
+++ b/libreoffice/automated/run-test.sh
@@ -16,6 +16,11 @@ UNOCONV="${TESTLIBDIR}/unoconv.py"
 
 check_not_root
 
+# Chosen to be something that the AppArmor profile for LibreOffice
+# should normally allow
+docsdir="$(mktemp -d ~/Documents/apertis-tests-libreoffice.XXXXXX)"
+cp -a "${MEDIA_RESOURCE_DIR}/documents/"*.od[pst] "${docsdir}/"
+
 setup_success
 
 ###########
@@ -34,15 +39,15 @@ _to_pdf() {
 }
 
 ods_to_pdf() {
-    _to_pdf "${MEDIA_RESOURCE_DIR}/documents/"*.ods "${WORKDIR}/test-$RANDOM.pdf"
+    _to_pdf "${docsdir}/"*.ods "${docsdir}/test-$RANDOM.pdf"
 }
 
 odp_to_pdf() {
-    _to_pdf "${MEDIA_RESOURCE_DIR}/documents/"*.odp "${WORKDIR}/test-$RANDOM.pdf"
+    _to_pdf "${docsdir}/"*.odp "${docsdir}/test-$RANDOM.pdf"
 }
 
 odt_to_pdf() {
-    _to_pdf "${MEDIA_RESOURCE_DIR}/documents/"*.odt "${WORKDIR}/test-$RANDOM.pdf"
+    _to_pdf "${docsdir}/"*.odt "${docsdir}/test-$RANDOM.pdf"
 }
 
 trap "test_failure" ERR
@@ -53,4 +58,5 @@ odp_to_pdf
 odt_to_pdf
 EOF
 
+rm -fr "${docsdir}"
 test_success
-- 
GitLab