*/*: [QA] Fix trivial cases of MissingTestRestrict
[gentoo.git] / sys-power / iasl / iasl-20190703.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit toolchain-funcs flag-o-matic
7
8 MY_PN=acpica-unix
9 MY_P="${MY_PN}-${PV}"
10 MY_TESTS_P="${MY_PN/ca/tests}-${PV}"
11 DESCRIPTION="Intel ACPI Source Language (ASL) compiler"
12 HOMEPAGE="https://www.acpica.org/downloads/"
13 SRC_URI="http://www.acpica.org/sites/acpica/files/${MY_P}.tar.gz
14         test? ( http://www.acpica.org/sites/acpica/files/${MY_TESTS_P}.tar.gz )"
15
16 LICENSE="iASL"
17 SLOT="0"
18 KEYWORDS="amd64 ~arm64 ppc x86"
19 IUSE="test"
20 RESTRICT="!test? ( test )"
21
22 DEPEND="sys-devel/bison
23         sys-devel/flex"
24 RDEPEND=""
25
26 S="${WORKDIR}/${MY_P}"
27
28 pkg_setup() {
29         if use test && has test ${FEATURES}; then
30                 ewarn 'You have selected USE="test". This will install the test results'
31                 ewarn "into /usr/share/${PF}/, compressed as a tarball."
32                 ewarn 'The tests themselves will only rarely die, but the test results'
33                 ewarn 'are interesting for arch testing. The tests may take quite some'
34                 ewarn 'time to complete.'
35         fi
36 }
37
38 PATCHES=(
39         "${FILESDIR}/${PN}-20140828-locale.patch"
40         "${FILESDIR}/${PN}-20140214-nostrip.patch"
41 )
42
43 src_prepare() {
44         default
45
46         find "${S}" -type f -name 'Makefile*' -print0 | \
47                 xargs -0 -I '{}' \
48                 sed -r -e 's:-\<Werror\>::g' -e "s:/usr:${EPREFIX}/usr:g" \
49                 -i '{}' \
50                 || die
51
52         # BITS is tied to ARCH - please set appropriately if you add new keywords
53         if [[ $ARCH == @(amd64|amd64-fbsd) ]] ; then
54                 export BITS=64
55         else
56                 export BITS=32
57         fi
58 }
59
60 src_configure() {
61         :
62 }
63
64 src_compile() {
65         cd generate/unix || die
66         emake BITS=${BITS}
67 }
68
69 src_test() {
70         aslts_test
71         #The aapits test currently fails, missing include probably.
72         #aapits_test
73 }
74
75 src_install() {
76         cd generate/unix || die
77         emake install DESTDIR="${D}" BITS=${BITS}
78         default
79         #local bin
80         #for bin in $(<"${T}"/binlist) ; do
81         #       dobin "${T}"/${bin}
82         #done
83         dodoc "${S}"/changes.txt
84         newdoc "${S}"/source/compiler/readme.txt compiler-readme.txt
85         newdoc "${S}"/generate/unix/readme.txt unix-readme.txt
86         newdoc "${S}"/generate/lint/readme.txt lint-readme.txt
87         newdoc "${S}"/source/compiler/new_table.txt compiler-new_table.txt
88
89         if use test && has test ${FEATURES}; then
90                 tb="${T}"/testresults.tar.bz2
91                 export ASLTSDIR="$(<"${T}"/asltdir)"
92                 ebegin "Creating Test Tarball"
93                 tar -cjf "${tb}" -C "${ASLTSDIR}"/tmp/RESULTS .  || die "tar failed"
94                 eend $?
95                 dodir /usr/share/${PF}
96                 insinto /usr/share/${PF}
97                 doins ${tb}
98         fi
99
100 }
101
102 aslts_test() {
103         export  ASL="${S}"/generate/unix/bin/iasl \
104                 acpibin="${S}"/generate/unix/bin/acpibin \
105                 acpiexec="${S}"/generate/unix/bin/acpiexec \
106                 ASLTSDIR="${WORKDIR}/${MY_TESTS_P}"/tests/aslts
107         export  PATH="${PATH}:${ASLTSDIR}/bin"
108         echo "$ASLTSDIR" >"${T}"/asltdir
109         cd "${ASLTSDIR}" || die
110         edos2unix $(find . -type 'f')
111         make install || die "make install aslts test failed"
112         chmod +x $(find bin/ ! -regex 'ERROR_OPCODES|HOW_TO_USE|README' ) || die "chmod bin +x failed"
113
114         #The below Do commands runs the tests twice and then dies if the results aren't
115         #Identical.
116         Do 1 || die "failed Do 1"
117         Do 2 || die "failed Do 2"
118 }
119
120 aapits_test() {
121         mv "${WORKDIR}/${MY_TESTS_P}/tests/aapits" "${S}/tools/" || die "mv failed"
122         cd "${S}/tools/aapits" || die "cannot find ${S}/tools/aapits"
123         edos2unix $(find . -type 'f')
124         chmod +x $(find bin/ | sed  -r -e '/\/[A-Z_]+$/d') || die "chmod bin +x failed"
125         make || die "make in aapits failed"
126         cd asl || die "cd asl failed"
127         make || die "make in asl failed"
128         cd ../bin || die
129         ./aapitsrun || die "aapitsrun failed"
130 }