forked from dracutdevs/dracut
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(TEST-62-SKIPCPIO): add simple skipcpio test
Signed-off-by: David Disseldorp <[email protected]> (cherry picked from commit 3a0f423)
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-include ../Makefile.testdir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |