Blob Blame History Raw
From 0fb55aa3fbf96a77ac86651cf9649843e0faa831 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Mon, 21 Dec 2020 04:26:02 -0500
Subject: [PATCH 2/4] Only run native Linux tests on their own GOARCH.

We don't have the cross-compiled C libraries to do this. Even 386 builds
on koji do not work for this because it does not support multilib.

Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
 Makefile     |  2 ++
 main_test.go | 27 ++++++++++++++++++---------
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index 5de97014..64d68e2b 100644
--- a/Makefile
+++ b/Makefile
@@ -479,7 +479,9 @@ endif
 	@$(MD5SUM) test.nro
 	$(TINYGO) build -size short -o test.hex -target=pca10040 -opt=0     ./testdata/stdlib.go
 	@$(MD5SUM) test.hex
+ifeq ($(shell uname -p), aarch64)
 	GOOS=linux GOARCH=arm $(TINYGO) build -size short -o test.elf       ./testdata/cgo
+endif
 	GOOS=windows GOARCH=amd64 $(TINYGO) build         -o test.exe       ./testdata/cgo
 ifneq ($(OS),Windows_NT)
 	# TODO: this does not yet work on Windows. Somehow, unused functions are
diff --git a/main_test.go b/main_test.go
index d74e0d67..1946ee1b 100644
--- a/main_test.go
+++ b/main_test.go
@@ -132,15 +132,24 @@ func TestCompiler(t *testing.T) {
 	})
 
 	if runtime.GOOS == "linux" {
-		t.Run("X86Linux", func(t *testing.T) {
-			runPlatTests(optionsFromOSARCH("linux/386"), tests, t)
-		})
-		t.Run("ARMLinux", func(t *testing.T) {
-			runPlatTests(optionsFromOSARCH("linux/arm/6"), tests, t)
-		})
-		t.Run("ARM64Linux", func(t *testing.T) {
-			runPlatTests(optionsFromOSARCH("linux/arm64"), tests, t)
-		})
+		switch runtime.GOARCH {
+		case "386":
+			t.Run("X86Linux", func(t *testing.T) {
+				runPlatTests(optionsFromOSARCH("linux/386"), tests, t)
+			})
+		case "amd64":
+			t.Run("AMD64Linux", func(t *testing.T) {
+				runPlatTests(optionsFromOSARCH("linux/amd64"), tests, t)
+			})
+		case "arm":
+			t.Run("ARMLinux", func(t *testing.T) {
+				runPlatTests(optionsFromOSARCH("linux/arm/6"), tests, t)
+			})
+		case "arm64":
+			t.Run("ARM64Linux", func(t *testing.T) {
+				runPlatTests(optionsFromOSARCH("linux/arm64"), tests, t)
+			})
+		}
 		t.Run("WebAssembly", func(t *testing.T) {
 			runPlatTests(optionsFromTarget("wasm"), tests, t)
 		})
-- 
2.31.1