Add a simple build test for the golang toolchain which is produced into a SDK.

Signed-off-by: Peter Morrow <pemor...@linux.microsoft.com>
---
 meta/lib/oeqa/sdk/cases/go.py   | 34 ++++++++++++++++++++++++++++++++++
 meta/lib/oeqa/sdk/files/test.go |  7 +++++++
 2 files changed, 41 insertions(+)
 create mode 100644 meta/lib/oeqa/sdk/cases/go.py
 create mode 100644 meta/lib/oeqa/sdk/files/test.go

diff --git a/meta/lib/oeqa/sdk/cases/go.py b/meta/lib/oeqa/sdk/cases/go.py
new file mode 100644
index 0000000..1af5516
--- /dev/null
+++ b/meta/lib/oeqa/sdk/cases/go.py
@@ -0,0 +1,34 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+import os
+import shutil
+import unittest
+
+from oeqa.core.utils.path import remove_safe
+from oeqa.sdk.case import OESDKTestCase
+
+from oeqa.utils.subprocesstweak import errors_have_output
+errors_have_output()
+
+class GoCompileTest(OESDKTestCase):
+    @classmethod
+    def setUpClass(self):
+        files = {'test.go' : self.tc.files_dir}
+        for f in files:
+            shutil.copyfile(os.path.join(files[f], f),
+                    os.path.join(self.tc.sdk_dir, f))
+
+    def setUp(self):
+        if not self.tc.hasHostPackage("^nativesdk-go", regex=True):
+            raise unittest.SkipTest("GoCompileTest class: SDK doesn't contain 
a golang toolchain")
+
+    def test_go_compile(self):
+        self._run('go build -o %s/test %s/test.go' % (self.tc.sdk_dir, 
self.tc.sdk_dir))
+
+    @classmethod
+    def tearDownClass(self):
+        files = [os.path.join(self.tc.sdk_dir, f) for f in ['test.go', 'test']]
+        for f in files:
+            remove_safe(f)
diff --git a/meta/lib/oeqa/sdk/files/test.go b/meta/lib/oeqa/sdk/files/test.go
new file mode 100644
index 0000000..089f721
--- /dev/null
+++ b/meta/lib/oeqa/sdk/files/test.go
@@ -0,0 +1,7 @@
+package main
+
+import "fmt"
+
+func main() {
+    fmt.Println("hello world!")
+}
-- 
1.8.3.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#152032): 
https://lists.openembedded.org/g/openembedded-core/message/152032
Mute This Topic: https://lists.openembedded.org/mt/82910985/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to