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

RISC-V: Add automated QEMU testing #1801

Merged
merged 2 commits into from May 4, 2020

Conversation

alistair23
Copy link
Contributor

Pull Request Overview

This starts the process of automating QEMU testing for certain targets.

Currently we just do very basic grep based testing. The idea is to move this to a more capable test-runner infrastructure. We want to make sure we utilise the make qemu target for each board to be as close as possible to user testing.

Testing Strategy

Push to GitHub and have Travis run tests.

TODO or Help Wanted

Nothing TODO for this PR.

Once OT support is merged to mainline QEMU (patches are on list) we can add OpenTitan testing to this as well.

Future TODO is to use a test-runner and to have more complex test cases.

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make formatall.

@alistair23 alistair23 changed the title Alistair/qemu automation RISC-V: Add automated QEMU testing Apr 26, 2020
@alistair23 alistair23 added the WG-OpenTitan In the purview of the OpenTitan working group. label Apr 26, 2020
@torfmaster
Copy link
Contributor

Nice! Would it make sense to run the libtock-rs test suite to check the kernel?

@alistair23
Copy link
Contributor Author

A test suite would be nice, but I'm not sure it's the right answer. How do we build it? What happens if there is a bug in libtock-rs? What happens if we change the kernel ABI (Tock 2.0)?

@torfmaster
Copy link
Contributor

I would (inside .travis.yml for example) choose a fixed version of libtock-rswhich could be bumped from time to time. If the ABI changes then there will (hopefully) be a version of libtock-rs which is compatible with that which could be chosen.

@bradjc
Copy link
Contributor

bradjc commented May 1, 2020

Is the qemu folder cached?

@alistair23
Copy link
Contributor Author

I don't think so, I can see if I can.

@alistair23 alistair23 force-pushed the alistair/qemu-automation branch 2 times, most recently from c0acae5 to 5683896 Compare May 1, 2020 17:12
@alistair23
Copy link
Contributor Author

It should be cached now

.travis.yml Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@alistair23 alistair23 force-pushed the alistair/qemu-automation branch 2 times, most recently from 3e57f5c to 727808b Compare May 1, 2020 18:07
.gitignore Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@alistair23 alistair23 force-pushed the alistair/qemu-automation branch 2 times, most recently from 4e0414d to 5958e67 Compare May 1, 2020 18:52
@alistair23
Copy link
Contributor Author

Ok, back to passing. I think I have addressed all comments.

@bradjc
Copy link
Contributor

bradjc commented May 1, 2020

Do you think I can volunteer you @hudson-ayers and @lschuermann to convert this to github actions? All signs point to that being strictly better than travis...maybe we should just freeze and eventually deprecate our travis setup, and move all new CI development over.

@bradjc
Copy link
Contributor

bradjc commented May 1, 2020

But we can also use this now, and switch at some later point.

@alistair23
Copy link
Contributor Author

I'm happy to help with the swap as well

@hudson-ayers
Copy link
Contributor

Sure, here is a test: Tock-CI#10 .

It seems to work pretty much as-is, with the caveat that both the travis build log and the github actions build log show /bin/sh: 1: [[: not found /bin/sh: 1: -f: not found as the first two lines of the emulation steps

This add two targets to the top level Makefile:
 - emulation-setup: Clones the latest QEMU from mainline and builds it
   for the RV32 platforms. We use master QEMU as it will soon have
   OpenTitan support.
 - emulation-check: Boot Tock in QEMU using the board's Makefile. We
   then do a simple test to see if we printed the "Entering main loop"
   string.

This is based on what libtock-rs used to do (with the timeout command
and grep). This should be moved across to a cargo test runner which is
what libtock-rs does now. We just need to figure out a way to hook the
test runner up with the board's Makefile (to run the QEMU args) to avoid
code duplication and test what users will run.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
@hudson-ayers
Copy link
Contributor

The fix for that is to change emulation-setup to use bash instead of sh (which will use dash on ubuntu):

.PHONY: emulation-setup
emulation-setup: SHELL:=/usr/bin/env bash
emulation-setup:
	@#Use the latest QEMU as it has OpenTitan support
	@if [[ ! -d tools/qemu || ! -f tools/qemu/VERSION ]]; then \
# ...

@alistair23
Copy link
Contributor Author

I didn't notice that warning. I have pushed a fix.

Copy link
Member

@ppannuto ppannuto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

I agree that Travis is (hopefully) not long for this world, but this is good to have now

@bors
Copy link
Contributor

bors bot commented May 4, 2020

Build succeeded:

@bors bors bot merged commit e022ef7 into tock:master May 4, 2020
@alistair23 alistair23 deleted the alistair/qemu-automation branch May 27, 2020 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WG-OpenTitan In the purview of the OpenTitan working group.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants