From patchwork Wed May 13 17:08:58 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Marko X-Patchwork-Id: 88063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E4EFCD4F3D for ; Wed, 13 May 2026 17:10:46 +0000 (UTC) Received: from mta-64-225.siemens.flowmailer.net (mta-64-225.siemens.flowmailer.net [185.136.64.225]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.2455.1778692242232683247 for ; Wed, 13 May 2026 10:10:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=peter.marko@siemens.com header.s=fm1 header.b=C4CdhPfL; spf=pass (domain: rts-flowmailer.siemens.com, ip: 185.136.64.225, mailfrom: fm-256628-20260513171040fabe4cb25900020739-tl2ihx@rts-flowmailer.siemens.com) Received: by mta-64-225.siemens.flowmailer.net with ESMTPSA id 20260513171040fabe4cb25900020739 for ; Wed, 13 May 2026 19:10:40 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=peter.marko@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=/VW1PmQf6jiNeB0WHmBs/3wWQt3oQ/k6Rh68+gdrhXk=; b=C4CdhPfLivRs5f1w/Sc0u/XkDLQw+kr2FtfJ/uewblGbVccU/GI5/HJZTYHdICEM/kS4+H FrWy6t3ORaY5RWqoTNpfFsiofb94d2pAP7xGPp5bvjKZD1seAwfZ2ZRCLII0U2Gkb0Q9YZYO zUAX/aW1r2IH8+dkYhCBlItHZw5xbehPYSGEluSHWcWDjqCITfpXK58InpLkcZpOlRWOWplR W7QVB3SP2utJQS2MTQKraRgifxIWec9HY8SCS3gO6xA9dd2qZm+SKAOcCWhojs+BPd+wzWWE D+yENGBvwu9IGUVjkh3X6DapY/fmvl5S6+A2TrF6VIFkvpMXX07nUQEg==; From: Peter Marko To: yocto-patches@lists.yoctoproject.org Cc: peter.marko@siemens.com, jose.quaresma@foundries.io Subject: [meta-lts-mixins][scarthgap/go][PATCH 4/7] go: ptest: improvements and multiple fixes in golang ptest Date: Wed, 13 May 2026 19:08:58 +0200 Message-ID: <20260513170902.2468061-4-peter.marko@siemens.com> In-Reply-To: <20260513170902.2468061-1-peter.marko@siemens.com> References: <20260513170902.2468061-1-peter.marko@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-256628:519-21489:flowmailer List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 13 May 2026 17:10:46 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/3986 From: Pratik Farkase Summary of Changelog: - run-ptest permanently modified the installed GOROOT by symlinking src/ and copying files without cleanup, corrupting the Go installation - Sub-package skip regex used exact match (^pkg$) so subpackages like net/http/httptest and runtime/debug were not skipped and would fail - Test output was completely suppressed (>/dev/null 2>&1), making failures impossible to diagnose - go was missing from RDEPENDS, allowing ptest to be installed without the toolchain it needs - bash was in RDEPENDS despite the script using #!/bin/sh with no bash-isms - file://run-ptest was in the shared .inc, affecting go-cross and go-native which don't inherit ptest - cp pkg/include/* would fail if the directory was empty Fix by saving/restoring GOROOT/src, using (/|$) in the skip regex, printing output on failure, correcting RDEPENDS, moving run-ptest to the target .bb, and guarding the glob. Tested on qemux86-64: all tests pass, 0 failures (~63 min). Signed-off-by: Pratik Farkase Signed-off-by: Richard Purdie (From OE-Core rev: a359aed2a8b94ad395a259a2009347e97185cbbc) Signed-off-by: Peter Marko --- recipes-devtools/go/go-1.26.2.inc | 1 - recipes-devtools/go/go/run-ptest | 47 +++++++++++++++++++++++++------ recipes-devtools/go/go_1.26.2.bb | 8 ++++-- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/recipes-devtools/go/go-1.26.2.inc b/recipes-devtools/go/go-1.26.2.inc index c53e828..8bb10bc 100644 --- a/recipes-devtools/go/go-1.26.2.inc +++ b/recipes-devtools/go/go-1.26.2.inc @@ -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" diff --git a/recipes-devtools/go/go/run-ptest b/recipes-devtools/go/go/run-ptest index ac020de..b8a0805 100755 --- a/recipes-devtools/go/go/run-ptest +++ b/recipes-devtools/go/go/run-ptest @@ -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" diff --git a/recipes-devtools/go/go_1.26.2.bb b/recipes-devtools/go/go_1.26.2.bb index 35a14b8..2e18ce0 100644 --- a/recipes-devtools/go/go_1.26.2.bb +++ b/recipes-devtools/go/go_1.26.2.bb @@ -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"