Add ptest infrastructure to test the Go standard library.

- Run 'go test -short std' via run-ptest script
- Install source tree and pkg/include headers
- Create VERSION file for architecture detection
- Exclude multi-arch binary testdata to avoid QA errors

Test results: 237/253 pass (93.7%) on qemux86-64.

Known issues:
- debug/elf, debug/pe, debug/plan9obj, internal/xcoff: missing binary testdata
- time: requires embedded timezone data
- net/http: requires unstripped go binary
- testing, go/types: minor edge cases

Signed-off-by: Pratik Farkase <[email protected]>
---
Changes in v2:
- Exclude .elf* files to fix QA arch errors on all architectures
- Exclude *-x86-64* files to fix additional arch-specific test binaries
- Tested on x86-64, x86, aarch64, and arm builds
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 meta/recipes-devtools/go/go-1.26.0.inc        |  1 +
 meta/recipes-devtools/go/go/run-ptest         | 23 ++++++++++++++++
 meta/recipes-devtools/go/go_1.26.0.bb         | 27 ++++++++++++++++++-
 4 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100755 meta/recipes-devtools/go/go/run-ptest

diff --git a/meta/conf/distro/include/ptest-packagelists.inc 
b/meta/conf/distro/include/ptest-packagelists.inc
index 1bb7458fc9..432f3965de 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -24,6 +24,7 @@ PTESTS_FAST = "\
     gdbm \
     gdk-pixbuf \
     glib-networking \
+    go \
     gzip \
     icu \
     json-c \
diff --git a/meta/recipes-devtools/go/go-1.26.0.inc 
b/meta/recipes-devtools/go/go-1.26.0.inc
index 7d8a68e3b2..611f00aaab 100644
--- a/meta/recipes-devtools/go/go-1.26.0.inc
+++ b/meta/recipes-devtools/go/go-1.26.0.inc
@@ -16,5 +16,6 @@ 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] = 
"c9132a8a1f6bd2aa4aad1d74b8231d95274950483a4950657ee6c56e6e817790"
diff --git a/meta/recipes-devtools/go/go/run-ptest 
b/meta/recipes-devtools/go/go/run-ptest
new file mode 100755
index 0000000000..86ff1bd1ae
--- /dev/null
+++ b/meta/recipes-devtools/go/go/run-ptest
@@ -0,0 +1,23 @@
+#!/bin/sh
+PTEST_DIR=/usr/lib/go/ptest
+GOROOT=/usr/lib/go
+
+export GOROOT
+export PATH=$GOROOT/bin:$PATH
+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
+
+cd $GOROOT
+
+go test -short std 2>&1 | while IFS= read -r line; do
+    case "$line" in
+        ok*) echo "PASS: $(echo "$line" | awk '{print $2}')" ;;
+        FAIL*) echo "FAIL: $(echo "$line" | awk '{print $2}')" ;;
+        \?*) ;;
+        *) echo "$line" ;;
+    esac
+done
diff --git a/meta/recipes-devtools/go/go_1.26.0.bb 
b/meta/recipes-devtools/go/go_1.26.0.bb
index 46f5fbc6be..35a14b8e8b 100644
--- a/meta/recipes-devtools/go/go_1.26.0.bb
+++ b/meta/recipes-devtools/go/go_1.26.0.bb
@@ -1,7 +1,7 @@
 require go-${PV}.inc
 require go-target.inc
 
-inherit linuxloader
+inherit linuxloader ptest
 
 CGO_LDFLAGS:append = " -no-pie"
 
@@ -16,3 +16,28 @@ python() {
         d.appendVar('INSANE_SKIP:%s' % d.getVar('PN'), " textrel")
 }
 
+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/
+    echo "go${PV}" > ${D}${PTEST_PATH}/VERSION
+
+    cd ${S}/src
+    find . -type d -exec install -d ${D}${PTEST_PATH}/src/{} \;
+    find . -type f \
+        ! -path "*/testdata/*.elf*" \
+        ! -path "*/testdata/*-x86-64*" \
+        ! -path "*/testdata/*.obj" \
+        ! -path "*/testdata/*.syso" \
+        ! -path "*/testdata/*.so" \
+        ! -path "*/testdata/*.so_" \
+        ! -path "*/testdata/*-exec" \
+        ! -path "*/testdata/test32*" \
+        ! -path "*/testdata/test64*" \
+        ! -path "*/race/*.syso" \
+        ! -path "*/boring/syso/*.syso" \
+        -exec install -m 0644 {} ${D}${PTEST_PATH}/src/{} \;
+}
+
+RDEPENDS:${PN}-ptest += "bash tzdata git packagegroup-core-buildessential"
-- 
2.43.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#232583): 
https://lists.openembedded.org/g/openembedded-core/message/232583
Mute This Topic: https://lists.openembedded.org/mt/118174533/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to