Gentoo Archives: gentoo-commits

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