[dunfell] go-helloworld: test at runtime

Message ID 20211202112116.1133149-1-alex@linutronix.de
State New, archived
Headers show
Series [dunfell] go-helloworld: test at runtime | expand

Commit Message

Alexander Kanavin Dec. 2, 2021, 11:21 a.m. UTC
From: Alexander Kanavin <alex.kanavin@gmail.com>

This adds a smoke check for whether the Go toolchain actually
produces working executables across a range of architectures.

(From OE-Core rev: 2819bb2cf22c6cfcaeaee79f0280097ec9cb9327)

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/testimage.bbclass                |  2 +-
 meta/lib/oeqa/runtime/cases/go.py             | 19 +++++++++++++++++++
 .../packagegroup-core-tools-testapps.bb       |  7 +++++++
 3 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 meta/lib/oeqa/runtime/cases/go.py

Comments

Steve Sakoman Dec. 2, 2021, 8:01 p.m. UTC | #1
On Thu, Dec 2, 2021 at 1:21 AM Alexander Kanavin <alex.kanavin@gmail.com> wrote:
>
> From: Alexander Kanavin <alex.kanavin@gmail.com>
>
> This adds a smoke check for whether the Go toolchain actually
> produces working executables across a range of architectures.

I'm getting a failure during autobuilder testing (qemuarm64-ptest):

DEBUG: Executing shell function do_configure
# Building C bootstrap tool.
cmd/dist
go tool dist: unknown architecture: aarch64
WARNING: exit code 1 from a shell command.
ERROR: Execution of
'TOPDIR/tmp/work/aarch64-linux/go-native/1.14.15-r0/temp/run.do_configure.318086'
failed with exit code 1

https://autobuilder.yoctoproject.org/typhoon/#/builders/82/builds/2609

Steve

> (From OE-Core rev: 2819bb2cf22c6cfcaeaee79f0280097ec9cb9327)
>
> Signed-off-by: Alexander Kanavin <alex@linutronix.de>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/classes/testimage.bbclass                |  2 +-
>  meta/lib/oeqa/runtime/cases/go.py             | 19 +++++++++++++++++++
>  .../packagegroup-core-tools-testapps.bb       |  7 +++++++
>  3 files changed, 27 insertions(+), 1 deletion(-)
>  create mode 100644 meta/lib/oeqa/runtime/cases/go.py
>
> diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
> index b1aef626f7..80c19b1e60 100644
> --- a/meta/classes/testimage.bbclass
> +++ b/meta/classes/testimage.bbclass
> @@ -58,7 +58,7 @@ BASICTESTSUITE = "\
>      ping date df ssh scp python perl gi ptest parselogs \
>      logrotate connman systemd oe_syslog pam stap ldd xorg \
>      kernelmodule gcc buildcpio buildlzip buildgalculator \
> -    dnf rpm opkg apt weston"
> +    dnf rpm opkg apt weston go"
>
>  DEFAULT_TEST_SUITES = "${BASICTESTSUITE}"
>
> diff --git a/meta/lib/oeqa/runtime/cases/go.py b/meta/lib/oeqa/runtime/cases/go.py
> new file mode 100644
> index 0000000000..89ba2c3ecb
> --- /dev/null
> +++ b/meta/lib/oeqa/runtime/cases/go.py
> @@ -0,0 +1,19 @@
> +#
> +# SPDX-License-Identifier: MIT
> +#
> +
> +from oeqa.runtime.case import OERuntimeTestCase
> +from oeqa.core.decorator.depends import OETestDepends
> +from oeqa.runtime.decorator.package import OEHasPackage
> +
> +class GoHelloworldTest(OERuntimeTestCase):
> +    @OETestDepends(['ssh.SSHTest.test_ssh'])
> +    @OEHasPackage(['go-helloworld'])
> +    def test_gohelloworld(self):
> +        cmd = "go-helloworld"
> +        status, output = self.target.run(cmd)
> +        msg = 'Exit status was not 0. Output: %s' % output
> +        self.assertEqual(status, 0, msg=msg)
> +
> +        msg = 'Incorrect output: %s' % output
> +        self.assertEqual(output, "Hello, Go examples!", msg=msg)
> diff --git a/meta/recipes-core/packagegroups/packagegroup-core-tools-testapps.bb b/meta/recipes-core/packagegroups/packagegroup-core-tools-testapps.bb
> index a5fc152859..3c946c57ef 100644
> --- a/meta/recipes-core/packagegroups/packagegroup-core-tools-testapps.bb
> +++ b/meta/recipes-core/packagegroups/packagegroup-core-tools-testapps.bb
> @@ -17,6 +17,12 @@ KEXECTOOLS_microblaze ?= ""
>  KEXECTOOLS_nios2 ?= ""
>  KEXECTOOLS_riscv64 ?= ""
>
> +# go does not support ppc32, only ppc64
> +# https://github.com/golang/go/issues/22885
> +# gccgo may do better
> +GOTOOLS ?= "go-helloworld"
> +GOTOOLS:powerpc ?= ""
> +
>  GSTEXAMPLES ?= "gst-examples"
>  GSTEXAMPLES_riscv64 = ""
>
> @@ -48,4 +54,5 @@ RDEPENDS_${PN} = "\
>      ${@bb.utils.contains('DISTRO_FEATURES', 'x11', "${X11TOOLS}", "", d)} \
>      ${@bb.utils.contains('DISTRO_FEATURES', 'x11 opengl', "${X11GLTOOLS}", "", d)} \
>      ${@bb.utils.contains('DISTRO_FEATURES', '3g', "${3GTOOLS}", "", d)} \
> +    ${GOTOOLS} \
>      "
> --
> 2.20.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#159086): https://lists.openembedded.org/g/openembedded-core/message/159086
> Mute This Topic: https://lists.openembedded.org/mt/87450623/3620601
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [steve@sakoman.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>

Patch

diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index b1aef626f7..80c19b1e60 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -58,7 +58,7 @@  BASICTESTSUITE = "\
     ping date df ssh scp python perl gi ptest parselogs \
     logrotate connman systemd oe_syslog pam stap ldd xorg \
     kernelmodule gcc buildcpio buildlzip buildgalculator \
-    dnf rpm opkg apt weston"
+    dnf rpm opkg apt weston go"
 
 DEFAULT_TEST_SUITES = "${BASICTESTSUITE}"
 
diff --git a/meta/lib/oeqa/runtime/cases/go.py b/meta/lib/oeqa/runtime/cases/go.py
new file mode 100644
index 0000000000..89ba2c3ecb
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/go.py
@@ -0,0 +1,19 @@ 
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class GoHelloworldTest(OERuntimeTestCase):
+    @OETestDepends(['ssh.SSHTest.test_ssh'])
+    @OEHasPackage(['go-helloworld'])
+    def test_gohelloworld(self):
+        cmd = "go-helloworld"
+        status, output = self.target.run(cmd)
+        msg = 'Exit status was not 0. Output: %s' % output
+        self.assertEqual(status, 0, msg=msg)
+
+        msg = 'Incorrect output: %s' % output
+        self.assertEqual(output, "Hello, Go examples!", msg=msg)
diff --git a/meta/recipes-core/packagegroups/packagegroup-core-tools-testapps.bb b/meta/recipes-core/packagegroups/packagegroup-core-tools-testapps.bb
index a5fc152859..3c946c57ef 100644
--- a/meta/recipes-core/packagegroups/packagegroup-core-tools-testapps.bb
+++ b/meta/recipes-core/packagegroups/packagegroup-core-tools-testapps.bb
@@ -17,6 +17,12 @@  KEXECTOOLS_microblaze ?= ""
 KEXECTOOLS_nios2 ?= ""
 KEXECTOOLS_riscv64 ?= ""
 
+# go does not support ppc32, only ppc64
+# https://github.com/golang/go/issues/22885
+# gccgo may do better
+GOTOOLS ?= "go-helloworld"
+GOTOOLS:powerpc ?= ""
+
 GSTEXAMPLES ?= "gst-examples"
 GSTEXAMPLES_riscv64 = ""
 
@@ -48,4 +54,5 @@  RDEPENDS_${PN} = "\
     ${@bb.utils.contains('DISTRO_FEATURES', 'x11', "${X11TOOLS}", "", d)} \
     ${@bb.utils.contains('DISTRO_FEATURES', 'x11 opengl', "${X11GLTOOLS}", "", d)} \
     ${@bb.utils.contains('DISTRO_FEATURES', '3g', "${3GTOOLS}", "", d)} \
+    ${GOTOOLS} \
     "