dryang / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
6f381c
From 21c281585983fe2efc2b74d712d98ff7e6c013b1 Mon Sep 17 00:00:00 2001
6f381c
From: Yu Watanabe <watanabe.yu+github@gmail.com>
6f381c
Date: Tue, 14 Jun 2022 09:11:00 +0900
6f381c
Subject: [PATCH] test: introduce inst_recursive() helper function
6f381c
6f381c
(cherry picked from commit da0465dc95388afc15598357452afef85035c639)
6f381c
6f381c
Related: #1866955
6f381c
---
6f381c
 test/test-functions | 14 ++++++++++++++
6f381c
 1 file changed, 14 insertions(+)
6f381c
6f381c
diff --git a/test/test-functions b/test/test-functions
6f381c
index 19363be858..9606a1b085 100644
6f381c
--- a/test/test-functions
6f381c
+++ b/test/test-functions
6f381c
@@ -1224,6 +1224,20 @@ inst_any() {
6f381c
     return 1
6f381c
 }
6f381c
 
6f381c
+inst_recursive() {
6f381c
+    local p item
6f381c
+
6f381c
+    for p in "$@"; do
6f381c
+        while read -r item; do
6f381c
+            if [[ -d "$item" ]]; then
6f381c
+                inst_dir "$item"
6f381c
+            elif [[ -f "$item" ]]; then
6f381c
+                inst_simple "$item"
6f381c
+            fi
6f381c
+        done < <(find "$p" 2>/dev/null)
6f381c
+    done
6f381c
+}
6f381c
+
6f381c
 # dracut_install [-o ] <file> [<file> ... ]
6f381c
 # Install <file> to the initramfs image
6f381c
 # -o optionally install the <file> and don't fail, if it is not there