.githooks/
compiler/
kernel/
lib/
scripts/
seed/
sublime/
test/
boot/
bootstrap/
compiler/
cycles/
dispatch/
format/
host/
integration/
kernel/
loader/
manifests/
mmio/
native/
packages/
runtime/
scheduling/
shared/
slots/
smp/
std/
sync/
termination/
tests/
trap/
verify/
Makefile
9.2 KiB
kernel.rad
776 B
runner.rad
11.6 KiB
vim/
.gitignore
333 B
.gitsigners
224 B
AGENTS.md
8.3 KiB
CONTRIBUTING
2.1 KiB
LICENSE
1.1 KiB
Makefile
2.5 KiB
README
3.4 KiB
STYLE
3.2 KiB
std.lib
2.1 KiB
std.lib.test
1.1 KiB
test/Makefile
raw
| 1 | # Test suites and machine fixture matrix. Run from the repository root. |
| 2 | # JOBS controls workers in the integration driver. |
| 3 | JOBS ?= 8 |
| 4 | TEST_HARTS := 1 2 8 |
| 5 | SMP_TESTS := $(addprefix smp-test-,$(TEST_HARTS)) |
| 6 | CYCLES_TESTS := $(addprefix cycles-test-,$(TEST_HARTS)) |
| 7 | TESTS := \ |
| 8 | seed-test \ |
| 9 | std-test \ |
| 10 | fmt-test \ |
| 11 | host-test \ |
| 12 | bin-test \ |
| 13 | module-test \ |
| 14 | package-test \ |
| 15 | native-test \ |
| 16 | shared-test \ |
| 17 | sync-test \ |
| 18 | verify-test \ |
| 19 | kernel-test \ |
| 20 | kernel-boot-test \ |
| 21 | trap-test loader-test \ |
| 22 | dispatch-test \ |
| 23 | smp-test \ |
| 24 | termination-test \ |
| 25 | runtime-test \ |
| 26 | bootstrap-test \ |
| 27 | scheduling-test \ |
| 28 | mmio-test \ |
| 29 | cycles-test |
| 30 | |
| 31 | test: $(TESTS) |
| 32 | |
| 33 | # Hosted test tools share one compiler recipe. |
| 34 | # Runner binary: the lowering IL checker. |
| 35 | TEST_TOOL_SRC := test/runner.rad test/native/build.rad \ |
| 36 | test/shared/build.rad test/sync/build.rad test/loader/hostile.rad \ |
| 37 | test/verify/check.rad test/host/child.rad |
| 38 | TEST_TOOLS := $(TEST_TOOL_SRC:.rad=.rv64) |
| 39 | |
| 40 | $(TEST_TOOLS): %.rv64: %.rad $(STD_LIB) $(STD_MANIFEST) $(RAD_BIN) test/Makefile |
| 41 | @$(RADIANCE) -name tool $< -o $@ |
| 42 | |
| 43 | # The integration driver runs the checks that start other programs: the |
| 44 | # compiler, the test tools and the emulator. Each of its commands works in |
| 45 | # bin/test/NAME. |
| 46 | INTEGRATION := test/integration.rv64 |
| 47 | INTEGRATION_SRC := $(sort $(wildcard test/integration/*.rad)) |
| 48 | INTEGRATION_FIXTURES := $(wildcard test/integration/fixtures/*/*) |
| 49 | INTEGRATION_OPTS := -compiler $(RAD_BIN) -jobs $(JOBS) |
| 50 | # Run the driver command $(1) with the arguments $(2). |
| 51 | integration = $(HOSTED) $(INTEGRATION) $(1) $(INTEGRATION_OPTS) $(2) |
| 52 | |
| 53 | $(INTEGRATION): $(INTEGRATION_FIXTURES) $(INTEGRATION_SRC) $(STD_LIB) $(STD_MANIFEST) \ |
| 54 | test/integration/integration.manifest $(RAD_BIN) test/Makefile |
| 55 | @$(RADIANCE) test/integration -o $@ |
| 56 | |
| 57 | seed-test: $(INTEGRATION) |
| 58 | @$(call integration,seed) |
| 59 | |
| 60 | # std::process against the emulator. |
| 61 | host-test: $(INTEGRATION) test/host/child.rv64 $(BIN_DIR)/native.fixture.rv64 |
| 62 | @$(call integration,host) |
| 63 | |
| 64 | package-test: $(INTEGRATION) |
| 65 | @$(call integration,packages) |
| 66 | |
| 67 | module-test: $(RAD_BIN) test/compiler/discovery.rv64 test/compiler/metadata.rv64 |
| 68 | @$(HOSTED) test/compiler/discovery.rv64 |
| 69 | @$(HOSTED) test/compiler/metadata.rv64 |
| 70 | |
| 71 | # Standard Library Tests |
| 72 | |
| 73 | STD_LIB_TEST := lib/std.test.rv64 |
| 74 | |
| 75 | STD_TEST_FIXTURES := $(wildcard lib/std/lang/manifest/tests/fixtures/*.manifest \ |
| 76 | lib/std/lang/resolver/tests/fixtures/*/*.rad) |
| 77 | |
| 78 | std-test: $(STD_LIB_TEST) |
| 79 | @$(HOSTED) $(STD_LIB_TEST) |
| 80 | |
| 81 | $(STD_LIB_TEST): $(STD_TEST_FIXTURES) $(STD_TEST_LIB) $(STD_MANIFEST) $(RAD_BIN) test/Makefile |
| 82 | @$(RADIANCE) -test lib/std -o $@ |
| 83 | |
| 84 | clean-std-test: |
| 85 | @rm -f lib/std.test.rv64 lib/std.test.rv64.debug \ |
| 86 | lib/std.test.rv64.s lib/std.test.rv64.o |
| 87 | |
| 88 | # The source formatter keeps the AST of every standard library and compiler |
| 89 | # source, and formats its own output to itself. |
| 90 | FMT_TEST_SRC := $(shell find lib compiler test/integration test/host -name '*.rad' | sort) |
| 91 | |
| 92 | fmt-test: $(RAD_BIN) $(INTEGRATION) |
| 93 | @$(call integration,fmt,$(FMT_TEST_SRC)) |
| 94 | |
| 95 | kernel-test: $(KERNEL_TEST) $(INTEGRATION) $(RAD_BIN) |
| 96 | @$(HOSTED) $(KERNEL_TEST) |
| 97 | @$(call integration,slots) |
| 98 | |
| 99 | kernel-boot-test: $(BIN_DIR)/kernel.rv64 $(INTEGRATION) |
| 100 | @$(call integration,boot) |
| 101 | |
| 102 | # Native image execution through the configured machine-capable emulator. |
| 103 | native-test: $(BIN_DIR)/native.fixture.rv64 |
| 104 | @$(RAD_EMULATOR) -machine -max-steps=1000000 -run $< |
| 105 | |
| 106 | $(BIN_DIR)/native.fixture.rv64: test/native/build.rv64 test/Makefile |
| 107 | @$(HOSTED) $< $@ |
| 108 | |
| 109 | # Shared package execution |
| 110 | shared-test: test/shared/build.rv64 $(INTEGRATION) $(RAD_BIN) |
| 111 | @$(call integration,shared) |
| 112 | |
| 113 | # Kernel synchronization machine tests |
| 114 | sync-test: test/sync/build.rv64 $(INTEGRATION) |
| 115 | @$(call integration,sync) |
| 116 | |
| 117 | # Binary Tests |
| 118 | |
| 119 | # Only tests with `//! returns:` are compiled to binaries and executed. |
| 120 | BIN_TEST_SRC := $(shell grep -l '^//! returns:' $(wildcard test/tests/*.rad test/tests/*.ras \ |
| 121 | test/tests/*/test.rad)) |
| 122 | BIN_TEST_BIN := $(addsuffix .rv64,$(basename $(BIN_TEST_SRC))) |
| 123 | |
| 124 | bin-test: test/runner.rv64 $(INTEGRATION) $(BIN_TEST_BIN) |
| 125 | @$(call integration,bin) |
| 126 | |
| 127 | # Compile each executable test to a binary. A test is one module, or a package |
| 128 | # directory `test/tests/NAME/` with `test.manifest` and the root `test.rad` |
| 129 | # when it has submodules or assembly. A test links the packages it imports. |
| 130 | # Fixtures that use std must rebuild when a library source changes. |
| 131 | # A package fixture also depends on its own module and assembly inputs. |
| 132 | .SECONDEXPANSION: |
| 133 | $(filter %/test.rv64,$(BIN_TEST_BIN)): test/tests/%/test.rv64: test/tests/%/test.manifest \ |
| 134 | $$(wildcard test/tests/$$*/*.rad test/tests/$$*/*.ras) |
| 135 | |
| 136 | test/tests/%.rv64: test/tests/%.rad $(RAD_BIN) $(INTEGRATION) test/Makefile |
| 137 | @$(call integration,compile,$< $@) |
| 138 | |
| 139 | test/tests/%.rv64: test/tests/%.ras test/runner.rv64 test/Makefile |
| 140 | @$(HOSTED) test/runner.rv64 assemble $< $@ |
| 141 | |
| 142 | clean-bin-test: |
| 143 | @rm -f $(TEST_TOOLS) $(INTEGRATION) $(BIN_TEST_BIN) \ |
| 144 | test/compiler/discovery.rv64 test/compiler/metadata.rv64 \ |
| 145 | $(wildcard test/tests/*.rv64.debug test/tests/*.rv64.s) \ |
| 146 | $(TEST_TOOLS:.rv64=.rv64.debug) $(TEST_TOOLS:.rv64=.rv64.s) \ |
| 147 | $(TEST_TOOLS:.rv64=.rv64.o) |
| 148 | |
| 149 | # Integer trap contexts and nested machine interrupts. |
| 150 | trap-test: test/sync/build.rv64 $(INTEGRATION) |
| 151 | @$(call integration,trap) |
| 152 | |
| 153 | # Runtime package compilation and execution through the production kernel. |
| 154 | # Generator of the hostile packages that the loader must reject. |
| 155 | loader-test: $(BIN_DIR)/kernel.build.rv64 test/loader/hostile.rv64 $(INTEGRATION) $(RAD_BIN) |
| 156 | @$(call integration,loader) |
| 157 | |
| 158 | # Machine fixtures build one kernel image each; every hart count then runs |
| 159 | # the same image as its own target. |
| 160 | FIXTURE_DEPS := $(RAD_BIN) $(BIN_DIR)/kernel.build.rv64 \ |
| 161 | $(INTEGRATION) test/kernel/fixture.rad \ |
| 162 | test/kernel.rad test/Makefile kernel/mmio.rad $(KERNEL_MODULES) $(KERNEL_ASM) |
| 163 | DISPATCH_IMAGES := $(BIN_DIR)/dispatch.rv64 $(BIN_DIR)/smp.rv64 \ |
| 164 | $(BIN_DIR)/termination.rv64 $(BIN_DIR)/mmio.rv64 |
| 165 | |
| 166 | # Dispatch fixtures are built from test/NAME by the integration driver. |
| 167 | $(DISPATCH_IMAGES): $(BIN_DIR)/%.rv64: test/%/spin.rad test/%/machine.ras \ |
| 168 | test/%/kernel/dispatchcheck.rad $(FIXTURE_DEPS) |
| 169 | @$(call integration,dispatch-build,$* $@) |
| 170 | |
| 171 | $(BIN_DIR)/termination.rv64: test/termination/cases.rad |
| 172 | $(BIN_DIR)/mmio.rv64: test/mmio/cases.rad |
| 173 | $(BIN_DIR)/smp.rv64: test/smp/kernel/invariants.rad test/smp/cases.rad |
| 174 | |
| 175 | # Run the machine fixture image $(2) on $(3) harts with the extra emulator |
| 176 | # flags $(4), and report $(1) when it exits with status zero. |
| 177 | MACHINE_FLAGS := -machine -memory-size=262144 -max-steps=70000000000 |
| 178 | fixture = $(RAD_EMULATOR) $(MACHINE_FLAGS) -harts=$(3) $(4) -run $(2) \ |
| 179 | && echo "$(1): $(3)-hart execution passed" |
| 180 | |
| 181 | # Native preemption across user code, idle, and retained machine work. |
| 182 | dispatch-test: $(BIN_DIR)/dispatch.rv64 |
| 183 | @$(call fixture,dispatch,$<,1) |
| 184 | |
| 185 | # Concurrent user contexts and metadata transactions on every online hart. |
| 186 | smp-test: $(SMP_TESTS) |
| 187 | $(SMP_TESTS): smp-test-%: $(BIN_DIR)/smp.rv64 |
| 188 | @$(call fixture,smp,$<,$*,-irq=7 -irq-at=1) |
| 189 | |
| 190 | # User exit, abort, and CPU faults preserve the surviving parent's execution. |
| 191 | termination-test: $(BIN_DIR)/termination.rv64 |
| 192 | @$(call fixture,termination,$<,1) |
| 193 | |
| 194 | # Scheduled compilation, cancellation, retry, and shared executable publication. |
| 195 | runtime-test: $(BIN_DIR)/kernel.build.rv64 $(INTEGRATION) $(RAD_BIN) |
| 196 | @$(call integration,runtime) |
| 197 | |
| 198 | # Root lifetime and resource authority across the boot-package handoff. |
| 199 | bootstrap-test: $(BIN_DIR)/kernel.build.rv64 $(INTEGRATION) $(RAD_BIN) |
| 200 | @$(call integration,bootstrap) |
| 201 | |
| 202 | # Fixture root and scheduler packages execute authority changes in user mode. |
| 203 | scheduling-test: $(BIN_DIR)/kernel.rv64 $(INTEGRATION) $(RAD_BIN) |
| 204 | @$(call integration,scheduling) |
| 205 | |
| 206 | # Checked user-mode register access, including rejection before device effects. |
| 207 | mmio-test: $(BIN_DIR)/mmio.rv64 |
| 208 | @$(call fixture,mmio,$<,1) |
| 209 | |
| 210 | # Dependency, controller, and worker loading under every hart count. |
| 211 | $(BIN_DIR)/cycles.rv64: test/cycles/spin.rad \ |
| 212 | test/cycles/job.rad test/cycles/support.rad test/cycles/machine.ras \ |
| 213 | test/cycles/kernel/dispatchcheck.rad test/smp/kernel/invariants.rad \ |
| 214 | $(FIXTURE_DEPS) |
| 215 | @$(call integration,cycles-build,$@) |
| 216 | |
| 217 | cycles-test: $(CYCLES_TESTS) |
| 218 | $(CYCLES_TESTS): cycles-test-%: $(BIN_DIR)/cycles.rv64 |
| 219 | @$(call fixture,cycles,$<,$*) |
| 220 | |
| 221 | # The verifier accepts or rejects the binary RIL of each fixture as |
| 222 | # test/verify/expected says. |
| 223 | verify-test: test/verify/check.rv64 $(INTEGRATION) $(RAD_BIN) |
| 224 | @$(call integration,verify) |
| 225 | |
| 226 | # Exercise the production test discovery module with bounded storage. The |
| 227 | # compiler modules have no package directory, so these builds use package flags. |
| 228 | test/compiler/discovery.rv64: test/compiler/discovery.rad compiler/radiance/testgen.rad \ |
| 229 | test/compiler/checks.manifest $(STD_LIB) $(RAD_BIN) test/Makefile |
| 230 | @$(RADIANCE) $(STD) -pkg testgen -manifest seed/dependencies/std \ |
| 231 | -mod compiler/radiance/testgen.rad \ |
| 232 | -pkg checks -mod test/compiler/discovery.rad -entry checks -o $@ |
| 233 | |
| 234 | # Check canonical exported metadata through the production compiler module. |
| 235 | test/compiler/metadata.rv64: test/compiler/metadata.rad compiler/radiance/metadata.rad \ |
| 236 | test/compiler/metachecks.manifest $(STD_LIB) $(RAD_BIN) test/Makefile |
| 237 | @$(RADIANCE) $(STD) -pkg metadata -manifest seed/dependencies/std \ |
| 238 | -mod compiler/radiance/metadata.rad -pkg metachecks -mod test/compiler/metadata.rad \ |
| 239 | -entry metachecks -o $@ |
| 240 | |
| 241 | .PHONY: test $(TESTS) $(SMP_TESTS) $(CYCLES_TESTS) clean-std-test clean-bin-test |