Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the QEMU test invocation to make test #199

Merged
merged 5 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tock"]
path = tock
url = https://github.com/tock/tock.git
30 changes: 1 addition & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,8 @@ os:

cache: cargo

# Once Travis supports a version of Ubuntu that inlcudes QEMU 5.1+
# we can apt install QEMU for RISC-V.
# Until then we need to build it ourselves
before_install:
# - sudo apt-get -y install qemu-system-misc
# addons:
# apt:
# update: true
- git clone https://github.com/alistair23/qemu.git -b riscv-tock.next
- pushd qemu
- ./configure --target-list=riscv32-softmmu
- make -j8
- sudo ln -s $PWD/riscv32-softmmu/qemu-system-riscv32 /usr/bin/
- popd

install:
- make setup
# Build Tock, it needs to be outside of the libtock-rs source
- pushd ../
- git clone https://github.com/tock/tock.git
- cd tock/boards/hifive1
# Use a known working version of Tock
- git checkout 152189fe077aea955332ee3c28ccbee519d8b072
- make
- popd
- make -j8 setup

script:
- make test
# Run a QEMU instance of the HiFive1 app
- PLATFORM=hifive1 cargo rrv32imac --example libtock_test --features=alloc --features=__internal_disable_gpio_in_integration_test
- pushd test-runner
- cargo run
- popd
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ lto = true
debug = true

[workspace]
exclude = [ "tock" ]
members = [
"codegen",
"core",
Expand Down
29 changes: 24 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ release=--release
endif

.PHONY: setup
setup:
setup: setup-qemu
rustup target add thumbv7em-none-eabi
rustup target add riscv32imac-unknown-none-elf
rustup target add riscv32imc-unknown-none-elf
Expand All @@ -41,6 +41,25 @@ setup:
cargo install elf2tab --version 0.4.0
cargo install stack-sizes

# Sets up QEMU in the tock/ directory. We use Tock's QEMU which may contain
# patches to better support boards that Tock supports.
.PHONY: setup-qemu
setup-qemu:
$(MAKE) -C tock emulation-setup

# Builds a Tock kernel for the HiFive board for use by QEMU tests.
.PHONY: kernel-hifive
kernel-hifive:
$(MAKE) -C tock/boards/hifive1 \
$(CURDIR)/tock/target/riscv32imac-unknown-none-elf/release/hifive1.elf

# Runs the libtock_test tests in QEMU on a simulated HiFive board.
.PHONY: test-qemu-hifive
test-qemu-hifive: kernel-hifive setup-qemu
PLATFORM=hifive1 cargo rrv32imac --example libtock_test --features=alloc \
--features=__internal_disable_gpio_in_integration_test
cargo run -p test-runner

.PHONY: examples
examples:
PLATFORM=nrf52 cargo build --release --target=thumbv7em-none-eabi --examples
Expand All @@ -50,11 +69,11 @@ examples:
PLATFORM=opentitan cargo build --release --target=riscv32imc-unknown-none-elf --examples # Important: This is testing a platform without atomics support

.PHONY: test
test:
test: examples test-qemu-hifive
PLATFORM=nrf52 cargo fmt --all -- --check
PLATFORM=nrf52 cargo clippy --workspace --all-targets
PLATFORM=nrf52 cargo test --workspace
make examples
echo '[ SUCCESS ] libtock-rs tests pass'

.PHONY: analyse-stack-sizes
analyse-stack-sizes:
Expand Down Expand Up @@ -110,5 +129,5 @@ flash-nrf52:

.PHONY: clean
clean:
rm -rf target
rm Cargo.lock
cargo clean
$(MAKE) -C tock clean
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ This script does the following steps for you:

## License

Licensed under either of
libtock-rs is licensed under either of

- Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
Expand All @@ -113,6 +113,8 @@ Licensed under either of

at your option.

Submodules have their own licenses.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
Expand Down
7 changes: 4 additions & 3 deletions test-runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
async fn perform_tests() -> Result<(), Box<dyn std::error::Error>> {
let mut failed_tests = Vec::new();

let tests = Command::new("qemu-system-riscv32")
let tests = Command::new("tock/tools/qemu/riscv32-softmmu/qemu-system-riscv32")
.arg("-M")
.arg("sifive_e,revb=true")
.arg("-kernel")
.arg("../../tock/target/riscv32imac-unknown-none-elf/release/hifive1")
.arg("tock/target/riscv32imac-unknown-none-elf/release/hifive1")
.arg("-device")
.arg("loader,file=./../target/riscv32imac-unknown-none-elf/tab/hifive1/libtock_test/rv32imac.tbf,addr=0x20040000")
.arg("loader,file=target/riscv32imac-unknown-none-elf/tab/hifive1/libtock_test/rv32imac.tbf,addr=0x20040000")
.arg("-nographic")
.stdin(Stdio::null())
.stdout(Stdio::piped())
.kill_on_drop(true)
.spawn()?;
Expand Down
1 change: 1 addition & 0 deletions tock
Submodule tock added at 152189