diff mbox series

[meta-lts-mixins,scarthgap/go,3/7] go: add ptest support

Message ID 20260513170902.2468061-3-peter.marko@siemens.com
State New
Headers show
Series [meta-lts-mixins,scarthgap/go,1/7] go-helloworld: upgrade to latest revision | expand

Commit Message

Peter Marko May 13, 2026, 5:08 p.m. UTC
From: Pratik Farkase <pratik.farkase@est.tech>

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

Signed-off-by: Pratik Farkase <pratik.farkase@est.tech>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
(From OE-Core rev: 9ca41405e6bca276468a3b6f67eaa328b8016485)
Signed-off-by: Peter Marko <peter.marko@siemens.com>
---
 conf/layer.conf                               |  2 ++
 recipes-core/images/core-image-ptest.bbappend |  6 ++++
 recipes-devtools/go/go-1.26.2.inc             |  1 +
 recipes-devtools/go/go/run-ptest              | 32 +++++++++++++++++++
 recipes-devtools/go/go_1.26.2.bb              | 27 +++++++++++++++-
 5 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100644 recipes-core/images/core-image-ptest.bbappend
 create mode 100755 recipes-devtools/go/go/run-ptest
diff mbox series

Patch

diff --git a/conf/layer.conf b/conf/layer.conf
index 6dd3c62..f621052 100644
--- a/conf/layer.conf
+++ b/conf/layer.conf
@@ -15,3 +15,5 @@  LAYERDEPENDS_lts-go-mixin = " \
 "
 
 GOVERSION = "1.26%"
+
+PTESTS_SLOW:append = " go"
diff --git a/recipes-core/images/core-image-ptest.bbappend b/recipes-core/images/core-image-ptest.bbappend
new file mode 100644
index 0000000..835487c
--- /dev/null
+++ b/recipes-core/images/core-image-ptest.bbappend
@@ -0,0 +1,6 @@ 
+PTEST_RUNNER_TIMEOUT:virtclass-mcextend-go = "4800"
+
+# golang go-ptest requires extra space
+IMAGE_ROOTFS_EXTRA_SPACE:virtclass-mcextend-go = "1524288"
+
+QB_MEM:virtclass-mcextend-go = "-m 4096"
diff --git a/recipes-devtools/go/go-1.26.2.inc b/recipes-devtools/go/go-1.26.2.inc
index 8bb10bc..c53e828 100644
--- a/recipes-devtools/go/go-1.26.2.inc
+++ b/recipes-devtools/go/go-1.26.2.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] = "2e91ebb6947a96e9436fb2b3926a8802efe63a6d375dffec4f82aa9dbd6fd43b"
diff --git a/recipes-devtools/go/go/run-ptest b/recipes-devtools/go/go/run-ptest
new file mode 100755
index 0000000..ac020de
--- /dev/null
+++ b/recipes-devtools/go/go/run-ptest
@@ -0,0 +1,32 @@ 
+#!/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
+
+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
+        echo "SKIP: $pkg"
+        continue
+    fi
+
+    if go test -short "$pkg" >/dev/null 2>&1; then
+        echo "PASS: $pkg"
+    else
+        echo "FAIL: $pkg"
+    fi
+done
diff --git a/recipes-devtools/go/go_1.26.2.bb b/recipes-devtools/go/go_1.26.2.bb
index 46f5fbc..35a14b8 100644
--- a/recipes-devtools/go/go_1.26.2.bb
+++ b/recipes-devtools/go/go_1.26.2.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"