@@ -30,21 +30,17 @@ class GoCompileTest(OESDKTestCase):
if not self.tc.hasHostPackage("go-cross-canadian-%s" % translated_target_arch):
raise unittest.SkipTest("GoCompileTest class: SDK doesn't contain a Go cross-canadian toolchain")
- # Additional runtime check for go command availability
- try:
- self._run('which go')
- except Exception as e:
- raise unittest.SkipTest("GoCompileTest class: go command not available: %s" % str(e))
+ self.go = self.ensure_sdk_binary(("go", "${TARGET_PREFIX}go"))
def test_go_build(self):
"""Test Go build command (native compilation)"""
- self._run('cd %s; go build -o test test.go' % self.tc.sdk_dir)
+ self._run('cd %s; %s build -o test test.go' % (self.tc.sdk_dir, self.go))
def test_go_module(self):
"""Test Go module creation and building"""
# Create a simple Go module
- self._run('cd %s; go mod init hello-go' % self.tc.sdk_dir)
- self._run('cd %s; go build -o hello-go' % self.tc.sdk_dir)
+ self._run('cd %s; %s mod init hello-go' % (self.tc.sdk_dir, self.go))
+ self._run('cd %s; %s build -buildvcs=false -o hello-go' % (self.tc.sdk_dir, self.go))
@classmethod
def tearDownClass(self):
@@ -68,11 +64,7 @@ class GoHostCompileTest(OESDKTestCase):
if not self.tc.hasHostPackage("go-cross-canadian-%s" % translated_target_arch):
raise unittest.SkipTest("GoHostCompileTest class: SDK doesn't contain a Go cross-canadian toolchain")
- # Additional runtime check for go command availability
- try:
- self._run('which go')
- except Exception as e:
- raise unittest.SkipTest("GoHostCompileTest class: go command not available: %s" % str(e))
+ self.go = self.ensure_sdk_binary(("go", "${TARGET_PREFIX}go"))
def _get_go_arch(self):
"""Get Go architecture from SDK_SYS"""
@@ -85,13 +77,13 @@ class GoHostCompileTest(OESDKTestCase):
def test_go_cross_compile(self):
"""Test Go cross-compilation for target"""
goarch = self._get_go_arch()
- self._run('cd %s; GOOS=linux GOARCH=%s go build -o test-%s test.go' % (self.tc.sdk_dir, goarch, goarch))
+ self._run('cd %s; GOOS=linux GOARCH=%s %s build -o test-%s test.go' % (self.tc.sdk_dir, goarch, self.go, goarch))
def test_go_module_cross_compile(self):
"""Test Go module cross-compilation"""
goarch = self._get_go_arch()
- self._run('cd %s; go mod init hello-go' % self.tc.sdk_dir)
- self._run('cd %s; GOOS=linux GOARCH=%s go build -o hello-go-%s' % (self.tc.sdk_dir, goarch, goarch))
+ self._run('cd %s; %s mod init hello-go' % (self.tc.sdk_dir, self.go))
+ self._run('cd %s; GOOS=linux GOARCH=%s %s build -buildvcs=false -o hello-go-%s' % (self.tc.sdk_dir, goarch, self.go, goarch))
@classmethod
def tearDownClass(self):
The Go cases confirm go-cross-canadian is in the SDK and then guard on "which go", which cannot succeed: the recipe installs ${TARGET_PREFIX}go and leaves the unprefixed binary in its own libdir, off PATH. So the cases skip on an SDK that does contain Go. Ask for either name and run what the SDK provides. Running them for the first time shows the module cases also need -buildvcs=false, as they build inside a git tree and Go fails stamping VCS information into the binary. AI-Generated: codex/claude-opus 5 (xhigh) Signed-off-by: Trevor Woerner <twoerner@gmail.com> --- meta/lib/oeqa/sdk/cases/go.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)