diff options
-rw-r--r-- | meta/classes/go-ptest.bbclass | 54 | ||||
-rw-r--r-- | meta/classes/go.bbclass | 52 |
2 files changed, 55 insertions, 51 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 @@ | |||
1 | inherit go ptest | ||
2 | |||
3 | do_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 | |||
15 | do_compile_ptest_base[dirs] =+ "${GOTMPDIR}" | ||
16 | |||
17 | go_make_ptest_wrapper() { | ||
18 | cat >${D}${PTEST_PATH}/run-ptest <<EOF | ||
19 | #!/bin/sh | ||
20 | RC=0 | ||
21 | run_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 \$?) | ||
25 | EOF | ||
26 | |||
27 | } | ||
28 | |||
29 | do_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 | |||
53 | INSANE_SKIP_${PN}-ptest += "ldflags" | ||
54 | |||
diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass index e05a5c641c..f303a15eaf 100644 --- a/meta/classes/go.bbclass +++ b/meta/classes/go.bbclass | |||
@@ -1,4 +1,4 @@ | |||
1 | inherit goarch ptest | 1 | inherit goarch |
2 | 2 | ||
3 | GO_PARALLEL_BUILD ?= "${@oe.utils.parallel_make_argument(d, '-p %d')}" | 3 | GO_PARALLEL_BUILD ?= "${@oe.utils.parallel_make_argument(d, '-p %d')}" |
4 | 4 | ||
@@ -114,19 +114,6 @@ go_do_compile() { | |||
114 | do_compile[dirs] =+ "${GOTMPDIR}" | 114 | do_compile[dirs] =+ "${GOTMPDIR}" |
115 | do_compile[cleandirs] = "${B}/bin ${B}/pkg" | 115 | do_compile[cleandirs] = "${B}/bin ${B}/pkg" |
116 | 116 | ||
117 | do_compile_ptest_base() { | ||
118 | export TMPDIR="${GOTMPDIR}" | ||
119 | rm -f ${B}/.go_compiled_tests.list | ||
120 | go_list_package_tests | while read pkg; do | ||
121 | cd ${B}/src/$pkg | ||
122 | ${GO} test ${GOPTESTBUILDFLAGS} $pkg | ||
123 | find . -mindepth 1 -maxdepth 1 -type f -name '*.test' -exec echo $pkg/{} \; | \ | ||
124 | sed -e's,/\./,/,'>> ${B}/.go_compiled_tests.list | ||
125 | done | ||
126 | do_compile_ptest | ||
127 | } | ||
128 | do_compile_ptest_base[dirs] =+ "${GOTMPDIR}" | ||
129 | |||
130 | go_do_install() { | 117 | go_do_install() { |
131 | install -d ${D}${libdir}/go/src/${GO_IMPORT} | 118 | install -d ${D}${libdir}/go/src/${GO_IMPORT} |
132 | tar -C ${S}/src/${GO_IMPORT} -cf - --exclude-vcs --exclude '*.test' --exclude 'testdata' . | \ | 119 | tar -C ${S}/src/${GO_IMPORT} -cf - --exclude-vcs --exclude '*.test' --exclude 'testdata' . | \ |
@@ -139,18 +126,6 @@ go_do_install() { | |||
139 | fi | 126 | fi |
140 | } | 127 | } |
141 | 128 | ||
142 | go_make_ptest_wrapper() { | ||
143 | cat >${D}${PTEST_PATH}/run-ptest <<EOF | ||
144 | #!/bin/sh | ||
145 | RC=0 | ||
146 | run_test() ( | ||
147 | cd "\$1" | ||
148 | ((((./\$2 ${GOPTESTFLAGS}; echo \$? >&3) | sed -r -e"s,^(PASS|SKIP|FAIL)\$,\\1: \$1/\$2," >&4) 3>&1) | (read rc; exit \$rc)) 4>&1 | ||
149 | exit \$?) | ||
150 | EOF | ||
151 | |||
152 | } | ||
153 | |||
154 | go_stage_testdata() { | 129 | go_stage_testdata() { |
155 | oldwd="$PWD" | 130 | oldwd="$PWD" |
156 | cd ${S}/src | 131 | cd ${S}/src |
@@ -165,37 +140,12 @@ go_stage_testdata() { | |||
165 | cd "$oldwd" | 140 | cd "$oldwd" |
166 | } | 141 | } |
167 | 142 | ||
168 | do_install_ptest_base() { | ||
169 | test -f "${B}/.go_compiled_tests.list" || exit 0 | ||
170 | install -d ${D}${PTEST_PATH} | ||
171 | go_stage_testdata | ||
172 | go_make_ptest_wrapper | ||
173 | havetests="" | ||
174 | while read test; do | ||
175 | testdir=`dirname $test` | ||
176 | testprog=`basename $test` | ||
177 | install -d ${D}${PTEST_PATH}/$testdir | ||
178 | install -m 0755 ${B}/src/$test ${D}${PTEST_PATH}/$test | ||
179 | echo "run_test $testdir $testprog || RC=1" >> ${D}${PTEST_PATH}/run-ptest | ||
180 | havetests="yes" | ||
181 | done < ${B}/.go_compiled_tests.list | ||
182 | if [ -n "$havetests" ]; then | ||
183 | echo "exit \$RC" >> ${D}${PTEST_PATH}/run-ptest | ||
184 | chmod +x ${D}${PTEST_PATH}/run-ptest | ||
185 | else | ||
186 | rm -rf ${D}${PTEST_PATH} | ||
187 | fi | ||
188 | do_install_ptest | ||
189 | chown -R root:root ${D}${PTEST_PATH} | ||
190 | } | ||
191 | |||
192 | EXPORT_FUNCTIONS do_unpack do_configure do_compile do_install | 143 | EXPORT_FUNCTIONS do_unpack do_configure do_compile do_install |
193 | 144 | ||
194 | FILES_${PN}-dev = "${libdir}/go/src" | 145 | FILES_${PN}-dev = "${libdir}/go/src" |
195 | FILES_${PN}-staticdev = "${libdir}/go/pkg" | 146 | FILES_${PN}-staticdev = "${libdir}/go/pkg" |
196 | 147 | ||
197 | INSANE_SKIP_${PN} += "ldflags" | 148 | INSANE_SKIP_${PN} += "ldflags" |
198 | INSANE_SKIP_${PN}-ptest += "ldflags" | ||
199 | 149 | ||
200 | # Add -buildmode=pie to GOBUILDFLAGS to satisfy "textrel" QA checking, but mips | 150 | # Add -buildmode=pie to GOBUILDFLAGS to satisfy "textrel" QA checking, but mips |
201 | # doesn't support -buildmode=pie, so skip the QA checking for mips and its | 151 | # doesn't support -buildmode=pie, so skip the QA checking for mips and its |