ac3a84
From 3be1c0fa543f024319a03e89decedc6106cb4e02 Mon Sep 17 00:00:00 2001
ac3a84
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
ac3a84
Date: Mon, 5 Dec 2022 13:52:28 +0100
ac3a84
Subject: [PATCH] TEST-65: check cat-config operation in chroot
ac3a84
ac3a84
This verifies the fix in 2075b6dd394e09a0f203b9cc7e3253908397f933.
ac3a84
ac3a84
(cherry picked from commit a7eed3eca3d7bc022d870258deb2f738b9527c6d)
ac3a84
ac3a84
Related: #2138081
ac3a84
---
ac3a84
 test/test-functions        |  1 +
ac3a84
 test/units/testsuite-65.sh | 10 ++++++++++
ac3a84
 2 files changed, 11 insertions(+)
ac3a84
ac3a84
diff --git a/test/test-functions b/test/test-functions
ac3a84
index 194cd682bb..94e11a686a 100644
ac3a84
--- a/test/test-functions
ac3a84
+++ b/test/test-functions
ac3a84
@@ -158,6 +158,7 @@ BASICTOOLS=(
ac3a84
     cat
ac3a84
     chmod
ac3a84
     chown
ac3a84
+    chroot
ac3a84
     cmp
ac3a84
     cryptsetup
ac3a84
     cut
ac3a84
diff --git a/test/units/testsuite-65.sh b/test/units/testsuite-65.sh
ac3a84
index 1f34308b44..ebe1f57b52 100755
ac3a84
--- a/test/units/testsuite-65.sh
ac3a84
+++ b/test/units/testsuite-65.sh
ac3a84
@@ -139,6 +139,16 @@ systemd-analyze cat-config systemd/system.conf systemd/journald.conf >/dev/null
ac3a84
 systemd-analyze cat-config systemd/system.conf foo/bar systemd/journald.conf >/dev/null
ac3a84
 systemd-analyze cat-config foo/bar
ac3a84
 
ac3a84
+if [[ ! -v ASAN_OPTIONS ]]; then
ac3a84
+    # check that systemd-analyze cat-config paths work in a chroot
ac3a84
+    mkdir -p /tmp/root
ac3a84
+    mount --bind / /tmp/root
ac3a84
+    systemd-analyze cat-config systemd/system-preset >/tmp/out1
ac3a84
+    chroot /tmp/root systemd-analyze cat-config systemd/system-preset >/tmp/out2
ac3a84
+    diff /tmp/out{1,2}
ac3a84
+fi
ac3a84
+
ac3a84
+# verify
ac3a84
 mkdir -p /tmp/img/usr/lib/systemd/system/
ac3a84
 mkdir -p /tmp/img/opt/
ac3a84