summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe/go-ptest.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-08-10 14:35:29 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-08-12 15:27:17 +0100
commitfd1517e2b51a170f2427122c6b95396db251d827 (patch)
treedabfe3e631339c2fc99a9ee7febb0f9c128e325e /meta/classes-recipe/go-ptest.bbclass
parent10317912ee319ccf7f83605d438b5cbf9663f296 (diff)
downloadpoky-fd1517e2b51a170f2427122c6b95396db251d827.tar.gz
classes: Update classes to match new bitbake class scope functionality
Move classes to classes-global or classes-recipe as appropriate to take advantage of new bitbake functionality to check class scope/usage. (From OE-Core rev: f5c128008365e141082c129417eb72d2751e8045) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/go-ptest.bbclass')
-rw-r--r--meta/classes-recipe/go-ptest.bbclass60
1 files changed, 60 insertions, 0 deletions
diff --git a/meta/classes-recipe/go-ptest.bbclass b/meta/classes-recipe/go-ptest.bbclass
new file mode 100644
index 0000000000..54fcbb535d
--- /dev/null
+++ b/meta/classes-recipe/go-ptest.bbclass
@@ -0,0 +1,60 @@
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7inherit go ptest
8
9do_compile_ptest_base() {
10 export TMPDIR="${GOTMPDIR}"
11 rm -f ${B}/.go_compiled_tests.list
12 go_list_package_tests | while read pkg; do
13 cd ${B}/src/$pkg
14 ${GO} test ${GOPTESTBUILDFLAGS} $pkg
15 find . -mindepth 1 -maxdepth 1 -type f -name '*.test' -exec echo $pkg/{} \; | \
16 sed -e's,/\./,/,'>> ${B}/.go_compiled_tests.list
17 done
18 do_compile_ptest
19}
20
21do_compile_ptest_base[dirs] =+ "${GOTMPDIR}"
22
23go_make_ptest_wrapper() {
24 cat >${D}${PTEST_PATH}/run-ptest <<EOF
25#!/bin/sh
26RC=0
27run_test() (
28 cd "\$1"
29 ((((./\$2 ${GOPTESTFLAGS}; echo \$? >&3) | sed -r -e"s,^(PASS|SKIP|FAIL)\$,\\1: \$1/\$2," >&4) 3>&1) | (read rc; exit \$rc)) 4>&1
30 exit \$?)
31EOF
32
33}
34
35do_install_ptest_base() {
36 test -f "${B}/.go_compiled_tests.list" || exit 0
37 install -d ${D}${PTEST_PATH}
38 go_stage_testdata
39 go_make_ptest_wrapper
40 havetests=""
41 while read test; do
42 testdir=`dirname $test`
43 testprog=`basename $test`
44 install -d ${D}${PTEST_PATH}/$testdir
45 install -m 0755 ${B}/src/$test ${D}${PTEST_PATH}/$test
46 echo "run_test $testdir $testprog || RC=1" >> ${D}${PTEST_PATH}/run-ptest
47 havetests="yes"
48 done < ${B}/.go_compiled_tests.list
49 if [ -n "$havetests" ]; then
50 echo "exit \$RC" >> ${D}${PTEST_PATH}/run-ptest
51 chmod +x ${D}${PTEST_PATH}/run-ptest
52 else
53 rm -rf ${D}${PTEST_PATH}
54 fi
55 do_install_ptest
56 chown -R root:root ${D}${PTEST_PATH}
57}
58
59INSANE_SKIP:${PN}-ptest += "ldflags"
60