blob: ba20a423caf075560ea72d45e2d50738d3a5420b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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() {
(command -v cpio && command -v find && command -v 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
|