Skip to content

Commit ebf70ab

Browse files
committed
ci: add more tests for wasm and baremetal
Run a range of tests in CI, to make sure browser wasm and baremetal don't regress too badly. I have intentionally filtered out tests, so that newly added tests to TEST_PACKAGES_FAST will be added here as well (and can be excluded if needed).
1 parent 226744a commit ebf70ab

File tree

3 files changed

+49
-13
lines changed

3 files changed

+49
-13
lines changed

.github/workflows/linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ jobs:
278278
run: make tinygo-test
279279
- run: make smoketest
280280
- run: make wasmtest
281-
- run: make tinygo-baremetal
281+
- run: make tinygo-test-baremetal
282282
build-linux-cross:
283283
# Build ARM Linux binaries, ready for release.
284284
# This intentionally uses an older Linux image, so that we compile against

GNUmakefile

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,45 @@ TEST_PACKAGES_WINDOWS := \
407407
text/template/parse \
408408
$(nil)
409409

410-
TEST_PACKAGES_WASM := \
411-
crypto/sha256
410+
411+
# These packages cannot be tested on wasm, mostly because these tests assume a
412+
# working filesystem. This could perhaps be fixed, by supporting filesystem
413+
# access when running inside Node.js.
414+
TEST_PACKAGES_WASM = $(filter-out $(TEST_PACKAGES_NONWASM), $(TEST_PACKAGES_FAST))
415+
TEST_PACKAGES_NONWASM = \
416+
compress/lzw \
417+
compress/zlib \
418+
crypto/ecdsa \
419+
debug/macho \
420+
embed/internal/embedtest \
421+
go/format \
422+
os \
423+
testing \
424+
$(nil)
425+
426+
# These packages cannot be tested on baremetal.
427+
#
428+
# Some reasons why the tests don't pass on baremetal:
429+
#
430+
# * No filesystem is available, so packages like compress/zlib can't be tested
431+
# (just like wasm).
432+
# * There is no RNG implemented (TODO, I think this is fixable).
433+
# * picolibc math functions apparently are less precise, the math package
434+
# fails on baremetal.
435+
# * Some packages fail or hang for an unknown reason, this should be
436+
# investigated and fixed.
437+
TEST_PACKAGES_BAREMETAL = $(filter-out $(TEST_PACKAGES_NONBAREMETAL), $(TEST_PACKAGES_FAST))
438+
TEST_PACKAGES_NONBAREMETAL = \
439+
$(TEST_PACKAGES_NONWASM) \
440+
crypto/elliptic \
441+
crypto/md5 \
442+
crypto/sha1 \
443+
math \
444+
reflect \
445+
encoding/asn1 \
446+
encoding/base32 \
447+
go/ast \
448+
$(nil)
412449

413450
# Report platforms on which each standard library package is known to pass tests
414451
jointmp := $(shell echo /tmp/join.$$$$)
@@ -489,6 +526,10 @@ tinygo-bench-wasip2:
489526
tinygo-bench-wasip2-fast:
490527
$(TINYGO) test -target wasip2 -bench . $(TEST_PACKAGES_FAST)
491528

529+
# Run tests on riscv-qemu since that one provides a large amount of memory.
530+
tinygo-test-baremetal:
531+
$(TINYGO) test -target riscv-qemu $(TEST_PACKAGES_BAREMETAL)
532+
492533
# Test external packages in a large corpus.
493534
test-corpus:
494535
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) test $(GOTESTFLAGS) -timeout=1h -buildmode exe -tags byollvm -run TestCorpus . -corpus=testdata/corpus.yaml
@@ -499,11 +540,6 @@ test-corpus-wasi: wasi-libc
499540
test-corpus-wasip2: wasi-libc
500541
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) test $(GOTESTFLAGS) -timeout=1h -buildmode exe -tags byollvm -run TestCorpus . -corpus=testdata/corpus.yaml -target=wasip2
501542

502-
tinygo-baremetal:
503-
# Regression tests that run on a baremetal target and don't fit in either main_test.go or smoketest.
504-
# regression test for #2666: e.g. encoding/hex must pass on baremetal
505-
$(TINYGO) test -target cortex-m-qemu encoding/hex
506-
507543
.PHONY: testchdir
508544
testchdir:
509545
# test 'build' command with{,out} -C argument

targets/riscv-qemu.ld

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11

22
/* Memory map:
33
* https://github.com/qemu/qemu/blob/master/hw/riscv/virt.c
4-
* RAM and flash are set to 1MB each. That should be enough for the foreseeable
5-
* future. QEMU does not seem to limit the flash/RAM size and in fact doesn't
6-
* seem to differentiate between it.
4+
* Looks like we can use any address starting from 0x80000000 (so 2GB of space).
5+
* However, using a large space slows down tests.
76
*/
87
MEMORY
98
{
10-
FLASH_TEXT (rw) : ORIGIN = 0x80000000, LENGTH = 0x100000
11-
RAM (xrw) : ORIGIN = 0x80100000, LENGTH = 0x100000
9+
RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 100M
1210
}
1311

12+
REGION_ALIAS("FLASH_TEXT", RAM)
13+
1414
_stack_size = 2K;
1515

1616
INCLUDE "targets/riscv.ld"

0 commit comments

Comments
 (0)