summaryrefslogtreecommitdiffstats
path: root/meta/classes/go-ptest.bbclass
diff options
context:
space:
mode:
authorMingli Yu <mingli.yu@windriver.com>2019-07-05 02:00:23 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-07-09 23:30:44 +0100
commit70a862a367beea2c92ec0fb1bcaba41b942c78ac (patch)
tree1f368925362a93e96b1f577541de4612581c0939 /meta/classes/go-ptest.bbclass
parent8073a9862e95947755861879ea19782316db5bc5 (diff)
downloadpoky-70a862a367beea2c92ec0fb1bcaba41b942c78ac.tar.gz
go.bbclass: separate the ptest logic to go-ptest class
The current go class includes ptest logic by default and will make the recipe which inherits go class to support ptest automatically though maybe the recipe which inherits go class doesn't plan to support the ptest. So separate the ptest logic to another specified class go-ptest to make the recipe which needs to inherit go class more flexible with regards to ptest support. (From OE-Core rev: 099a2a212fed61a24643da63c74c09cef3ba4030) Signed-off-by: Mingli Yu <mingli.yu@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/go-ptest.bbclass')
-rw-r--r--meta/classes/go-ptest.bbclass54
1 files changed, 54 insertions, 0 deletions
diff --git a/meta/classes/go-ptest.bbclass b/meta/classes/go-ptest.bbclass
new file mode 100644
index 0000000000..e230a80587
--- /dev/null
+++ b/meta/classes/go-ptest.bbclass
@@ -0,0 +1,54 @@
1inherit go ptest
2
3do_compile_ptest_base() {
4 export TMPDIR="${GOTMPDIR}"
5 rm -f ${B}/.go_compiled_tests.list
6 go_list_package_tests | while read pkg; do
7 cd ${B}/src/$pkg
8 ${GO} test ${GOPTESTBUILDFLAGS} $pkg
9 find . -mindepth 1 -maxdepth 1 -type f -name '*.test' -exec echo $pkg/{} \; | \
10 sed -e's,/\./,/,'>> ${B}/.go_compiled_tests.list
11 done
12 do_compile_ptest
13}
14
15do_compile_ptest_base[dirs] =+ "${GOTMPDIR}"
16
17go_make_ptest_wrapper() {
18 cat >${D}${PTEST_PATH}/run-ptest <<EOF
19#!/bin/sh
20RC=0
21run_test() (
22 cd "\$1"
23 ((((./\$2 ${GOPTESTFLAGS}; echo \$? >&3) | sed -r -e"s,^(PASS|SKIP|FAIL)\$,\\1: \$1/\$2," >&4) 3>&1) | (read rc; exit \$rc)) 4>&1
24 exit \$?)
25EOF
26
27}
28
29do_install_ptest_base() {
30 test -f "${B}/.go_compiled_tests.list" || exit 0
31 install -d ${D}${PTEST_PATH}
32 go_stage_testdata
33 go_make_ptest_wrapper
34 havetests=""
35 while read test; do
36 testdir=`dirname $test`
37 testprog=`basename $test`
38 install -d ${D}${PTEST_PATH}/$testdir
39 install -m 0755 ${B}/src/$test ${D}${PTEST_PATH}/$test
40 echo "run_test $testdir $testprog || RC=1" >> ${D}${PTEST_PATH}/run-ptest
41 havetests="yes"
42 done < ${B}/.go_compiled_tests.list
43 if [ -n "$havetests" ]; then
44 echo "exit \$RC" >> ${D}${PTEST_PATH}/run-ptest
45 chmod +x ${D}${PTEST_PATH}/run-ptest
46 else
47 rm -rf ${D}${PTEST_PATH}
48 fi
49 do_install_ptest
50 chown -R root:root ${D}${PTEST_PATH}
51}
52
53INSANE_SKIP_${PN}-ptest += "ldflags"
54