diff mbox series

[v2] go: add ptest support

Message ID 20260306172416.23307-1-pratik.farkase@est.tech
State Changes Requested
Headers show
Series [v2] go: add ptest support | expand

Commit Message

Pratik Farkase March 6, 2026, 5:24 p.m. UTC
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 <pratik.farkase@est.tech>
---
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

Comments

Jose Quaresma March 6, 2026, 6:55 p.m. UTC | #1
Hi Pratik,

Pratik Farkase via lists.openembedded.org <pratik.farkase=
est.tech@lists.openembedded.org> escreveu (sexta, 6/03/2026 à(s) 17:24):

> 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 <pratik.farkase@est.tech>
> ---
> 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
>

Having the golang ptest running on x86 and arm is a great improvement for
the project.
Thank you very much for this patch.

Jose


> ---
>  .../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/5052612
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> quaresma.jose@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Mathieu Dubois-Briand March 8, 2026, 4:09 p.m. UTC | #2
On Fri Mar 6, 2026 at 6:24 PM CET, Pratik Farkase wrote:
> 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 <pratik.farkase@est.tech>
> ---

Hi Pratik,

Thanks for the new version.

On the autobuilder, the OOM killer is triggered on most tests:

[  314.773868] Tasks state (memory values in pages):
[  314.774517] [  pid  ]   uid  tgid total_vm      rss rss_anon rss_file rss_shmem pgtables_bytes swapents oom_score_adj name
[  314.780755] [    138]     0   138     2490      268      235       33         0    49152        0         -1000 udevd
[  314.782773] [    322]     0   322     2379      335      250       85         0    53248        0         -1000 sshd
[  314.801338] [    328]     0   328     1015       53        0       53         0    40960        0             0 syslogd
[  314.811001] [    331]     0   331     1015       53        0       53         0    40960        0             0 klogd
[  314.819041] [    337]     0   337     1029      126       64       62         0    36864        0             0 start_getty
[  314.820980] [    338]     0   338     1029      126       64       62         0    45056        0             0 start_getty
[  314.823947] [    339]     0   339     1015       32        0       32         0    45056        0             0 getty
[  314.826345] [    342]     0   342     1072      153       96       57         0    45056        0             0 sh
[  314.835899] [    343]     0   343     1015       83       32       51         0    40960        0             0 getty
[  314.837471] [    388]     0   388     2619      335      288       47         0    57344        0             0 sshd-session
[  314.849074] [    390]     0   390     2684      454      353      101         0    61440        0             0 sshd-session
[  314.850742] [    391]     0   391      639       73        0       73         0    40960        0             0 ptest-runner
[  314.863046] [    392]     0   392     1028      105       64       41         0    45056        0             0 run-ptest
[  314.868775] [    397]     0   397   335448    14669    14640       29         0   245760        0             0 go
[  314.881173] [    398]     0   398     1028       97       39       58         0    45056        0             0 run-ptest
[  314.882869] [    798]     0   798   371933    60075    60023       20        32   630784        0             0 compile
[  314.893578] [   1230]     0  1230   371846    55334    55248       54        32   589824        0             0 compile
[  314.895156] [   1381]     0  1381   371669    48968    48879       57        32   540672        0             0 compile
[  314.904257] [   1445]     0  1445   371821    50116    50067       17        32   552960        0             0 compile
[  314.907744] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/,task=compile,pid=798,uid=0
[  314.910323] Out of memory: Killed process 798 (compile) total-vm:1487732kB, anon-rss:240092kB, file-rss:408kB, shmem-rss:128kB, UID:0 pgtables:616kB oom_score_adj:0

https://autobuilder.yoctoproject.org/valkyrie/#/builders/73/builds/3229
https://autobuilder.yoctoproject.org/valkyrie/#/builders/61/builds/3201
https://autobuilder.yoctoproject.org/valkyrie/#/builders/56/builds/1196

We might need to increase QEMU memory size. Did you had similar issues
on your side?

Thanks,
Mathieu
Pratik Farkase March 8, 2026, 4:58 p.m. UTC | #3
Hi Mathieu,

Thanks for testing!

Yes, Go ptest requires significant RAM due to on-the-fly compilation during testing.
On my setup (qemux86-64 with 4GB RAM), tests complete successfully in ~45 minutes.

The minimum RAM requirement appears to be ~2GB. With less RAM, the OOM killer
terminates compile processes as you've seen.

Options:
1. Increase QB_MEM for go-ptest in the recipe

This is similar to other resource-intensive ptests like gcc or llvm.

What would be the preferred approach for OpenEmbedded-Core?

Thanks,
Pratik
diff mbox series

Patch

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"