1 |
Signed-off-by: Michał Górny <mgorny@g.o> |
2 |
--- |
3 |
eclass/tests/unpacker.sh | 105 +++++++++++++++++++++++++++++++++++++++ |
4 |
1 file changed, 105 insertions(+) |
5 |
|
6 |
diff --git a/eclass/tests/unpacker.sh b/eclass/tests/unpacker.sh |
7 |
index ea9e64d0a4c7..ef17e724a851 100755 |
8 |
--- a/eclass/tests/unpacker.sh |
9 |
+++ b/eclass/tests/unpacker.sh |
10 |
@@ -223,6 +223,67 @@ test_reject_junk() { |
11 |
rm -f "${archive}" || die |
12 |
} |
13 |
|
14 |
+test_online() { |
15 |
+ local url=${1} |
16 |
+ local b2sum=${2} |
17 |
+ local unpacked=${3} |
18 |
+ local unp_b2sum=${4} |
19 |
+ |
20 |
+ local filename=${url##*/} |
21 |
+ local archive=${DISTDIR}/${filename} |
22 |
+ |
23 |
+ if [[ ! -f ${archive} ]]; then |
24 |
+ if [[ ${UNPACKER_TESTS_ONLINE} != 1 ]]; then |
25 |
+ ewarn "Skipping ${filename} test, distfile not found" |
26 |
+ return |
27 |
+ fi |
28 |
+ |
29 |
+ if ! wget -O "${archive}" "${url}"; then |
30 |
+ die "Fetching ${archive} failed" |
31 |
+ fi |
32 |
+ fi |
33 |
+ |
34 |
+ local real_sum=$(b2sum "${archive}" | cut -d' ' -f1) |
35 |
+ if [[ ${real_sum} != ${b2sum} ]]; then |
36 |
+ eerror "Incorrect b2sum on ${filename}" |
37 |
+ eerror " expected: ${b2sum}" |
38 |
+ eerror " found: ${real_sum}" |
39 |
+ die "Incorrect b2sum on ${filename}" |
40 |
+ fi |
41 |
+ |
42 |
+ rm -rf testdir || die |
43 |
+ mkdir -p testdir || die |
44 |
+ |
45 |
+ tbegin "unpacking ${filename}" |
46 |
+ cd testdir || die |
47 |
+ |
48 |
+ ln -s "${archive}" "${filename}" || die |
49 |
+ |
50 |
+ local out |
51 |
+ out=$( |
52 |
+ _unpacker "${archive}" 2>&1 |
53 |
+ ) |
54 |
+ ret=$? |
55 |
+ if [[ ${ret} -eq 0 ]]; then |
56 |
+ if [[ ! -f ${unpacked} ]]; then |
57 |
+ eerror "${unpacked} not found after unpacking" |
58 |
+ ret=1 |
59 |
+ else |
60 |
+ real_sum=$(b2sum "${unpacked}" | cut -d' ' -f1) |
61 |
+ if [[ ${real_sum} != ${unp_b2sum} ]]; then |
62 |
+ eerror "Incorrect b2sum on unpacked file ${unpacked}" |
63 |
+ eerror " expected: ${unp_b2sum}" |
64 |
+ eerror " found: ${real_sum}" |
65 |
+ ret=1 |
66 |
+ fi |
67 |
+ fi |
68 |
+ fi |
69 |
+ [[ ${ret} -ne 0 ]] && echo "${out}" >&2 |
70 |
+ tend ${ret} |
71 |
+ |
72 |
+ cd .. || die |
73 |
+} |
74 |
+ |
75 |
test_compressed_file .bz2 bzip2 |
76 |
test_compressed_file .Z compress |
77 |
test_compressed_file .gz gzip |
78 |
@@ -322,4 +383,48 @@ test_reject_junk .rar |
79 |
test_reject_junk .lha |
80 |
test_reject_junk .lzh |
81 |
|
82 |
+DISTDIR=$(portageq envvar DISTDIR) |
83 |
+if [[ -n ${DISTDIR} ]]; then |
84 |
+ einfo "Using DISTDIR: ${DISTDIR}" |
85 |
+ if [[ ${UNPACKER_TESTS_ONLINE} != 1 ]]; then |
86 |
+ ewarn "Online tests will be skipped if distfiles are not found already." |
87 |
+ ewarn "Set UNPACKER_TESTS_ONLINE=1 to enable fetching." |
88 |
+ fi |
89 |
+ |
90 |
+ # NB: a good idea to list the last file in the archive (to avoid |
91 |
+ # passing on partial unpack) |
92 |
+ |
93 |
+ # TODO: find test cases for makeself 2.0/2.0.1, 2.1.1, 2.1.2, 2.1.3 |
94 |
+ |
95 |
+ # makeself 1.5.4, gzip |
96 |
+ test_online \ |
97 |
+ http://updates.lokigames.com/sof/sof-1.06a-cdrom-x86.run \ |
98 |
+ f76f605af08a19b77548455c0101e03aca7cae69462914e47911da2fadd6d4f3b766e1069556ead0d06c757b179ae2e8105e76ea37852f17796b47b4712aec87 \ |
99 |
+ update.sh \ |
100 |
+ ba7a3f8fa79bbed8ca3a34ead957aeaa308c6e6d6aedd603098aa9867ca745983ff98c83d65572e507f2c3c4e0778ae4984f8b69d2b8279741b06064253c5788 |
101 |
+ |
102 |
+ # makeself 1.6.0-nv*, xz |
103 |
+ test_online \ |
104 |
+ https://download.nvidia.com/XFree86/Linux-x86/390.154/NVIDIA-Linux-x86-390.154.run \ |
105 |
+ 083d9dd234a37ec39a703ef7e0eb6ec165c24d2fcb5e92ca987c33df643d0604319eb65ef152c861acacd5a41858ab6b82c45c2c8ff270efc62b07727666daae \ |
106 |
+ libEGL_nvidia.so.390.154 \ |
107 |
+ 6665804947e71fb583dc7d5cc3a6f4514f612503000b0a9dbd8da5c362d3c2dcb2895d8cbbf5700a6f0e24cca9b0dd9c2cf5763d6fbb037f55257ac5af7d6084 |
108 |
+ |
109 |
+ # makeself 2.3.0, gzip |
110 |
+ test_online \ |
111 |
+ http://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.07.1.run \ |
112 |
+ 059d9a5fbd14c0e7ecb969cd3e5afe8e3f42896175b443bdaa9f9108302a1c9ef5ad9769e62f824465611d74f67191fff71cc6dbe297e399e5b2f6824c650112 \ |
113 |
+ i686/sdrplay_apiService \ |
114 |
+ 806393c310d7e60dca7b8afee225bcc50c0d5771bdd04c3fa575eda2e687dc5c888279a7404316438b633fb91565a49899cf634194d43981151a12c6c284a162 |
115 |
+ |
116 |
+ # makeself 2.4.0, gzip |
117 |
+ test_online \ |
118 |
+ http://www.sdrplay.com/software/SDRplay_RSP_API-Linux-2.13.1.run \ |
119 |
+ 7eff1aa35190db1ead5b1d96994d24ae2301e3a765d6701756c6304a1719aa32125fedacf6a6859d89b89db5dd6956ec0e8c7e814dbd6242db5614a53e89efb3 \ |
120 |
+ sdrplay_license.txt \ |
121 |
+ 041edb26ffb75b6b59e7a3514c6f81b05b06e0efe61cc56117d24f59733a6a6b1bca73a57dd11e0774ec443740ca55e6938cf6594a032ab4f14b23f2e732a3f2 |
122 |
+else |
123 |
+ ewarn "Unable to obtain DISTDIR from portageq, skipping online tests" |
124 |
+fi |
125 |
+ |
126 |
texit |
127 |
-- |
128 |
2.37.3 |