dryang / rpms / systemd

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