blob: b282ff737448234e32a1107ee201370a9769ef0c [file] [log] [blame]
Brad Bishop96ff1982019-08-19 13:50:42 -04001inherit 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
Patrick Williams213cb262021-08-07 19:21:33 -050053INSANE_SKIP:${PN}-ptest += "ldflags"
Brad Bishop96ff1982019-08-19 13:50:42 -040054