Skip to content

Commit

Permalink
ci(TEST-62-SKIPCPIO): add simple skipcpio test
Browse files Browse the repository at this point in the history
Signed-off-by: David Disseldorp <[email protected]>
(cherry picked from commit 3a0f423)
  • Loading branch information
ddiss committed Dec 6, 2021
1 parent 09c047c commit ce87e8b
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/TEST-62-SKIPCPIO/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-include ../Makefile.testdir
75 changes: 75 additions & 0 deletions test/TEST-62-SKIPCPIO/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/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() {
which 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

"$basedir"/src/skipcpio/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

0 comments on commit ce87e8b

Please sign in to comment.