Skip to content

Commit fc42024

Browse files
committed
riscv: run tests in QEMU
Not everything is supported right now, but these tests should make sure that things that work now won't break in the future.
1 parent dad1c0e commit fc42024

4 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎.circleci/config.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ commands:
265265
ln -s $PWD/llvm-build/bin/clang-9 /usr/local/bin/clang-9
266266
- run:
267267
name: "Test TinyGo"
268-
command: make test
268+
command: |
269+
make gen-device-sifive # needed for testing
270+
make test
269271
- run:
270272
name: "Build TinyGo release"
271273
command: |

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ tinygo:
139139
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) build -o build/tinygo$(EXE) -tags byollvm .
140140

141141
test:
142-
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) test -v -tags byollvm ./cgo ./compileopts ./interp ./transform .
142+
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) test -v -tags byollvm .
143143

144144
tinygo-test:
145145
cd tests/tinygotest && tinygo test

‎azure-pipelines.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
script: |
5353
export PATH="/c/Go1.13/bin:$PATH:./llvm-build/bin:/c/Program Files/qemu"
5454
unset GOROOT
55+
make gen-device-sifive # needed for testing
5556
make test
5657
- task: Bash@3
5758
displayName: Build TinyGo release tarball

‎main_test.go‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ func TestCompiler(t *testing.T) {
5353
runPlatTests("cortex-m-qemu", matches, t)
5454
})
5555

56+
if runtime.GOOS != "linux" {
57+
// Linux distros often have an old QEMU version.
58+
// QEMU 4.0 or higher is required for this to work (released in
59+
// 2019-04).
60+
t.Run("EmulatedHiFive1", func(t *testing.T) {
61+
runPlatTests("hifive1-qemu", matches, t)
62+
})
63+
}
64+
5665
if runtime.GOOS == "linux" {
5766
t.Run("ARMLinux", func(t *testing.T) {
5867
runPlatTests("arm--linux-gnueabihf", matches, t)
@@ -78,6 +87,15 @@ func runPlatTests(target string, matches []string, t *testing.T) {
7887
// run all tests on host
7988
case target == "cortex-m-qemu":
8089
// all tests are supported
90+
case target == "hifive1-qemu":
91+
if path == filepath.Join("testdata", "coroutines.go") || path == filepath.Join("testdata", "channel.go") || path == filepath.Join("testdata", "interface.go") {
92+
// time.Sleep does not work yet in QEMU?
93+
continue
94+
}
95+
if path == filepath.Join("testdata", "cgo")+string(filepath.Separator) {
96+
// CGo doesn't work yet for some reason.
97+
continue
98+
}
8199
default:
82100
// cross-compilation of cgo is not yet supported
83101
if path == filepath.Join("testdata", "cgo")+string(filepath.Separator) {

0 commit comments

Comments
 (0)