summaryrefslogtreecommitdiffstats
path: root/test/TEST-62-SKIPCPIO/test.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 13:54:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 13:54:25 +0000
commit9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a (patch)
tree2efb72864cc69e174c9c5ee33efb88a5f1553b48 /test/TEST-62-SKIPCPIO/test.sh
parentInitial commit. (diff)
downloaddracut-9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a.tar.xz
dracut-9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a.zip
Adding upstream version 060+5.upstream/060+5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/TEST-62-SKIPCPIO/test.sh')
-rwxr-xr-xtest/TEST-62-SKIPCPIO/test.sh80
1 files changed, 80 insertions, 0 deletions
diff --git a/test/TEST-62-SKIPCPIO/test.sh b/test/TEST-62-SKIPCPIO/test.sh
new file mode 100755
index 0000000..2311da3
--- /dev/null
+++ b/test/TEST-62-SKIPCPIO/test.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+# This file is part of dracut.
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# shellcheck disable=SC2034
+TEST_DESCRIPTION="test skipcpio"
+
+test_check() {
+ cpio dd truncate find sort diff &> /dev/null
+}
+
+skipcpio_simple() {
+ mkdir -p "$CPIO_TESTDIR/skipcpio_simple/first_archive"
+ pushd "$CPIO_TESTDIR/skipcpio_simple/first_archive"
+
+ for ((i = 0; i < 3; i++)); do
+ echo "first archive file $i" >> ./"$i"
+ done
+ find . -print0 | sort -z \
+ | cpio -o --null -H newc --file "$CPIO_TESTDIR/skipcpio_simple.cpio"
+ popd
+
+ mkdir -p "$CPIO_TESTDIR/skipcpio_simple/second_archive"
+ pushd "$CPIO_TESTDIR/skipcpio_simple/second_archive"
+
+ for ((i = 10; i < 13; i++)); do
+ echo "second archive file $i" >> ./"$i"
+ done
+
+ find . -print0 | sort -z \
+ | cpio -o --null -H newc >> "$CPIO_TESTDIR/skipcpio_simple.cpio"
+ popd
+
+ cpio -i --list < "$CPIO_TESTDIR/skipcpio_simple.cpio" \
+ > "$CPIO_TESTDIR/skipcpio_simple.list"
+ cat << EOF | diff - "$CPIO_TESTDIR/skipcpio_simple.list"
+.
+0
+1
+2
+EOF
+
+ if [ "$PKGLIBDIR" = "$basedir" ]; then
+ skipcpio_path="${PKGLIBDIR}/src/skipcpio"
+ else
+ skipcpio_path="${PKGLIBDIR}"
+ fi
+ "$skipcpio_path"/skipcpio "$CPIO_TESTDIR/skipcpio_simple.cpio" \
+ | cpio -i --list > "$CPIO_TESTDIR/skipcpio_simple.list"
+ cat << EOF | diff - "$CPIO_TESTDIR/skipcpio_simple.list"
+.
+10
+11
+12
+EOF
+}
+
+test_run() {
+ set -x
+ set -e
+
+ skipcpio_simple
+
+ return 0
+}
+
+test_setup() {
+ CPIO_TESTDIR=$(mktemp --directory -p "$TESTDIR" cpio-test.XXXXXXXXXX) \
+ || return 1
+ export CPIO_TESTDIR
+ return 0
+}
+
+test_cleanup() {
+ [ -d "$CPIO_TESTDIR" ] && rm -rf "$CPIO_TESTDIR"
+ return 0
+}
+
+# shellcheck disable=SC1090
+. "$testdir"/test-functions