From d4ca24fcf04f5c3356deb462bf69cb76b6cf85a8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Thu, 29 Jul 2021 09:53:48 +0200
Subject: [PATCH 1/5] run-aa-test: Fix call to csplit
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

New version of `csplit` from `rust-coreutils` fails with following error:
  $ csplit R1.13a.1_bluez-spp.expected -f /tmp/EXPECT -b "%d" "/^## alternative ##$/" {*}
  csplit: error: incorrect conversion specification in suffix

Replacing `%d` by `%0d` fixes it.

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 run-aa-test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/run-aa-test b/run-aa-test
index 2ed2147..b9b2eb3 100755
--- a/run-aa-test
+++ b/run-aa-test
@@ -143,7 +143,7 @@ echo "#---8<--- expected parsed apparmor output from journal"
 cat ${EXPECT_FILE} | sed 's/^/# /'
 echo "#--->8---"
 
-csplit ${EXPECT_FILE} -f ${TMP_DIR}/EXPECT -b "%d" "/^${ALTERNATIVE_SEPARATOR}$/" {*}
+csplit ${EXPECT_FILE} -f ${TMP_DIR}/EXPECT -b "%0d" "/^${ALTERNATIVE_SEPARATOR}$/" {*}
 
 # Old versions of csplit don't provide "--suppress-matched", strip separator separately
 for FILE in ${TMP_DIR}/EXPECT*; do
-- 
GitLab


From 0e868dac847d958523f457590386c824c5a5927f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Wed, 13 Oct 2021 09:21:56 +0200
Subject: [PATCH 2/5] update-test-path: Fix LD_LIBRARY_PATH setup
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This script fails when LD_LIBRARY_PATH is not set before calling it and
calling script has `nounset` option set.

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 update-test-path | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/update-test-path b/update-test-path
index 61174ff..5e0c115 100644
--- a/update-test-path
+++ b/update-test-path
@@ -12,5 +12,5 @@ aarch64) ARCHDIR=arm64 ;;
 esac
 
 PATH=${TESTPATH}/${ARCHDIR}/bin:$PATH
-export LD_LIBRARY_PATH=${TESTPATH}/${ARCHDIR}/lib:$LD_LIBRARY_PATH
+export LD_LIBRARY_PATH=${TESTPATH}/${ARCHDIR}/lib:${LD_LIBRARY_PATH:-}
 
-- 
GitLab


From 772611794160f95b094d172daaa1b580328069ff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Wed, 1 Dec 2021 12:30:51 +0100
Subject: [PATCH 3/5] common-subtree: Fix branch to use
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The `test/common` repository uses `apertis/v20*` branches, not `main` or
`master`.
`common-subtree.sh` is using the current branch from the working
test repo to infer which remote branch to import: if it's not in the
`apertis/*` form, retrieve the latest branch from the `test/common`
repository.

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 common-subtree.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/common-subtree.sh b/common-subtree.sh
index b757ed6..c99aa60 100755
--- a/common-subtree.sh
+++ b/common-subtree.sh
@@ -8,7 +8,16 @@ usage () {
 }
 
 branch="$(git symbolic-ref --short HEAD)"
-test -z "$branch" && branch="master"
+case "$branch" in
+	apertis/*)
+		;;
+	*)
+        # take the default remote branch if we're not on a apertis/* branch
+		branch=$(git ls-remote --symref git@gitlab.apertis.org:tests/common.git HEAD \
+		         | grep ^ref: \
+		         | sed 's,ref: refs/heads/\(.*\)\s\+HEAD,\1,')
+		;;
+esac
 
 case $1 in
 pull)
-- 
GitLab


From 7b8c353e16f94c7cb40fc812439afa8629fb4050 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Wed, 8 Dec 2021 17:00:21 +0100
Subject: [PATCH 4/5] Fix tmp dirs removal
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 run-aa-test         | 1 +
 run-test-in-systemd | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/run-aa-test b/run-aa-test
index b9b2eb3..1d7f486 100755
--- a/run-aa-test
+++ b/run-aa-test
@@ -71,6 +71,7 @@ fi
 
 # Create a temporary directory for files
 TMP_DIR=$(mktemp -d)
+trap "rm -rf $TMP_DIR; exit" EXIT
 
 # Log start time
 START_TIME=$(date +"%F %T")
diff --git a/run-test-in-systemd b/run-test-in-systemd
index ba2c3ad..6722f19 100755
--- a/run-test-in-systemd
+++ b/run-test-in-systemd
@@ -300,7 +300,7 @@ ${systemctl} stop ${service} || :
 
 debug "waiting for end-of-file on command output..."
 wait "$cat_fifo_pid" || result=fail
-rm -fr "${user_log_dir}" || result=fail
+${as_target_user} rm -fr "${user_log_dir}" || result=fail
 
 if [ -n "${lava_runes}" ]; then
     "lava-test-case" "${name}" --result "${result}"
-- 
GitLab


From 3e4dea3e74b1367a44a630dd2cb66ae61450aea4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Wed, 8 Dec 2021 17:03:04 +0100
Subject: [PATCH 5/5] Add architecture specific library name
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This will allow to create the architecture library path like
`/usr/lib/arm-linux-gnueabihf/`.

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 update-test-path | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/update-test-path b/update-test-path
index 5e0c115..57e17ce 100644
--- a/update-test-path
+++ b/update-test-path
@@ -6,9 +6,9 @@ PATH=${TESTPATH}/common:${TESTPATH}/bin:$PATH
 
 # Path for architecture specific binaries
 case `uname -m` in
-x86_64)  ARCHDIR=amd64 ;;
-armv7l)  ARCHDIR=armhf ;;
-aarch64) ARCHDIR=arm64 ;;
+x86_64)  ARCHDIR=amd64 ; ARCHLIBDIR=x86_64-linux-gnu ;;
+armv7l)  ARCHDIR=armhf ; ARCHLIBDIR=arm-linux-gnueabihf ;;
+aarch64) ARCHDIR=arm64 ; ARCHLIBDIR=aarch64-linux-gnu ;;
 esac
 
 PATH=${TESTPATH}/${ARCHDIR}/bin:$PATH
-- 
GitLab