Skip to content

Commit ce87e8b

Browse files
committed
ci(TEST-62-SKIPCPIO): add simple skipcpio test
Signed-off-by: David Disseldorp <ddiss@suse.de> (cherry picked from commit 3a0f423)
1 parent 09c047c commit ce87e8b

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

test/TEST-62-SKIPCPIO/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-include ../Makefile.testdir

test/TEST-62-SKIPCPIO/test.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
# This file is part of dracut.
3+
# SPDX-License-Identifier: GPL-2.0-or-later
4+
5+
# shellcheck disable=SC2034
6+
TEST_DESCRIPTION="test skipcpio"
7+
8+
test_check() {
9+
which cpio dd truncate find sort diff &> /dev/null
10+
}
11+
12+
skipcpio_simple() {
13+
mkdir -p "$CPIO_TESTDIR/skipcpio_simple/first_archive"
14+
pushd "$CPIO_TESTDIR/skipcpio_simple/first_archive"
15+
16+
for ((i = 0; i < 3; i++)); do
17+
echo "first archive file $i" >> ./"$i"
18+
done
19+
find . -print0 | sort -z \
20+
| cpio -o --null -H newc --file "$CPIO_TESTDIR/skipcpio_simple.cpio"
21+
popd
22+
23+
mkdir -p "$CPIO_TESTDIR/skipcpio_simple/second_archive"
24+
pushd "$CPIO_TESTDIR/skipcpio_simple/second_archive"
25+
26+
for ((i = 10; i < 13; i++)); do
27+
echo "second archive file $i" >> ./"$i"
28+
done
29+
30+
find . -print0 | sort -z \
31+
| cpio -o --null -H newc >> "$CPIO_TESTDIR/skipcpio_simple.cpio"
32+
popd
33+
34+
cpio -i --list < "$CPIO_TESTDIR/skipcpio_simple.cpio" \
35+
> "$CPIO_TESTDIR/skipcpio_simple.list"
36+
cat << EOF | diff - "$CPIO_TESTDIR/skipcpio_simple.list"
37+
.
38+
0
39+
1
40+
2
41+
EOF
42+
43+
"$basedir"/src/skipcpio/skipcpio "$CPIO_TESTDIR/skipcpio_simple.cpio" \
44+
| cpio -i --list > "$CPIO_TESTDIR/skipcpio_simple.list"
45+
cat << EOF | diff - "$CPIO_TESTDIR/skipcpio_simple.list"
46+
.
47+
10
48+
11
49+
12
50+
EOF
51+
}
52+
53+
test_run() {
54+
set -x
55+
set -e
56+
57+
skipcpio_simple
58+
59+
return 0
60+
}
61+
62+
test_setup() {
63+
CPIO_TESTDIR=$(mktemp --directory -p "$TESTDIR" cpio-test.XXXXXXXXXX) \
64+
|| return 1
65+
export CPIO_TESTDIR
66+
return 0
67+
}
68+
69+
test_cleanup() {
70+
[ -d "$CPIO_TESTDIR" ] && rm -rf "$CPIO_TESTDIR"
71+
return 0
72+
}
73+
74+
# shellcheck disable=SC1090
75+
. "$testdir"/test-functions

0 commit comments

Comments
 (0)