@@ -16,6 +16,5 @@ SRC_URI += "\
file://0009-go-Filter-build-paths-on-staticly-linked-arches.patch \
file://0010-cmd-go-clear-GOROOT-for-func-ldShared-when-trimpath-.patch \
file://0011-cmd-link-stop-forcing-binutils-gold-dependency-on-aa.patch \
- file://run-ptest \
"
SRC_URI[main.sha256sum] = "2e91ebb6947a96e9436fb2b3926a8802efe63a6d375dffec4f82aa9dbd6fd43b"
@@ -1,32 +1,63 @@
#!/bin/sh
+# SPDX-License-Identifier: MIT
-PTEST_DIR=/usr/lib/go/ptest
+PTEST_DIR=$(cd "$(dirname "$0")" && pwd)
GOROOT=/usr/lib/go
export GOROOT
export PATH=$GOROOT/bin:$PATH
+export GOCACHE=$(mktemp -d)
export ZONEINFO=/usr/share/zoneinfo
-ln -sf $PTEST_DIR/src $GOROOT/src
-mkdir -p $GOROOT/pkg/include
-cp $PTEST_DIR/pkg/include/* $GOROOT/pkg/include/
-cp $PTEST_DIR/VERSION $GOROOT/VERSION
+# Link ptest source tree into GOROOT for testing.
+# Save and restore any existing src directory.
+if [ -d "$GOROOT/src" ] && [ ! -L "$GOROOT/src" ]; then
+ mv "$GOROOT/src" "$GOROOT/src.orig"
+fi
+ln -sf "$PTEST_DIR/src" "$GOROOT/src"
-cd $GOROOT
+if [ -f "$PTEST_DIR/VERSION" ]; then
+ cp "$PTEST_DIR/VERSION" "$GOROOT/VERSION"
+fi
+if ls "$PTEST_DIR/pkg/include/"* >/dev/null 2>&1; then
+ mkdir -p "$GOROOT/pkg/include"
+ cp "$PTEST_DIR/pkg/include/"* "$GOROOT/pkg/include/"
+fi
+cd "$GOROOT" || exit 1
+
+# Packages skipped due to known issues in the ptest environment:
+# debug/dwarf, debug/elf, debug/pe, debug/plan9obj, internal/xcoff:
+# require binary testdata files excluded to avoid QA errors
+# go/types: extremely slow, exceeds ptest timeout
+# net/http: requires network access unavailable in qemu
+# runtime: requires cgo rebuild and race detector setup
+# testing: circular dependency when testing the test framework
+# time: requires writable GOROOT for timezone data
SKIP_PKGS="debug/dwarf debug/elf debug/pe debug/plan9obj go/types internal/xcoff net/http runtime testing time"
SKIP_REGEX=$(echo "$SKIP_PKGS" | sed 's/ /|/g')
for pkg in $(go list std); do
- if echo "$pkg" | grep -qE "^($SKIP_REGEX)$"; then
+ # Skip package and all its subpackages
+ if echo "$pkg" | grep -qE "^($SKIP_REGEX)(/|$)"; then
echo "SKIP: $pkg"
continue
fi
- if go test -short "$pkg" >/dev/null 2>&1; then
+ output=$(go test -short "$pkg" 2>&1)
+ ret=$?
+ if [ $ret -eq 0 ]; then
echo "PASS: $pkg"
else
echo "FAIL: $pkg"
+ echo "$output"
fi
done
+
+# Cleanup: restore original src directory
+rm -f "$GOROOT/src"
+if [ -d "$GOROOT/src.orig" ]; then
+ mv "$GOROOT/src.orig" "$GOROOT/src"
+fi
+rm -rf "$GOCACHE"
@@ -3,6 +3,8 @@ require go-target.inc
inherit linuxloader ptest
+SRC_URI += "file://run-ptest"
+
CGO_LDFLAGS:append = " -no-pie"
export GO_LDSO = "${@get_linuxloader(d)}"
@@ -20,7 +22,9 @@ do_install_ptest() {
install -d ${D}${PTEST_PATH}/src
install -d ${D}${PTEST_PATH}/pkg/include
- cp ${S}/pkg/include/* ${D}${PTEST_PATH}/pkg/include/
+ if ls ${S}/pkg/include/* >/dev/null 2>&1; then
+ cp ${S}/pkg/include/* ${D}${PTEST_PATH}/pkg/include/
+ fi
echo "go${PV}" > ${D}${PTEST_PATH}/VERSION
cd ${S}/src
@@ -40,4 +44,4 @@ do_install_ptest() {
-exec install -m 0644 {} ${D}${PTEST_PATH}/src/{} \;
}
-RDEPENDS:${PN}-ptest += "bash tzdata git packagegroup-core-buildessential"
+RDEPENDS:${PN}-ptest += "go tzdata git packagegroup-core-buildessential"