Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
os: [ubuntu-latest]
include:
- os: ubuntu-latest
deps: sudo apt-get update && sudo apt-get install libusb-1.0-0-dev libftdi1-dev libudev-dev
deps: sudo apt-get update && sudo apt-get install libusb-1.0-0-dev libftdi1-dev libudev-dev qemu-system-misc
#- os: windows-latest
# deps: vcpkg install libusb libftdi1
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
if: ${{ needs.skip_duplicate_jobs.outputs.should_skip != 'true' }}
strategy:
matrix:
os: [ ubuntu-latest, macOS-latest ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down
24 changes: 24 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@
inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-overlay.inputs.flake-utils.follows = "flake-utils";

inputs.qemuflake.url = "git+https://github.com/rivosinc/qemu?submodules=1&ref=dev/drew/nix";
inputs.qemuflake.inputs.nixpkgs.follows = "nixpkgs";

inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
inputs.pre-commit-hooks.inputs.flake-utils.follows = "flake-utils";
inputs.pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";

outputs = {
self,
nixpkgs,
qemuflake,
rust-overlay,
pre-commit-hooks,
flake-utils,
}: (flake-utils.lib.eachDefaultSystem (system: let
overlays = [(import rust-overlay)];
overlays = [(import rust-overlay)] ++ nixpkgs.lib.optional (system != "aarch64-darwin") qemuflake.overlays.default;

pkgs = import nixpkgs {
inherit system overlays;
Expand All @@ -30,6 +34,7 @@
cargo = rust;
rustc = rust;
humility = final.callPackage ./humility.nix {
qemu = pkgs.qemu;
cargo = rust;
src = self;
version = "0.9.5";
Expand Down
5 changes: 5 additions & 0 deletions humility.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
AppKit ? null,
libusb1,
cargo-readme,
qemu,
src,
version,
doCheck ? false,
Expand All @@ -34,6 +35,10 @@ rustPlatform.buildRustPackage rec {
]
++ lib.optionals stdenv.isLinux [systemd];

checkInputs = [
qemu
];

checkPhase = ''
${cargo}/bin/cargo fmt --all --check
${cargo}/bin/cargo clippy --profile=ci -- -D warnings
Expand Down
33 changes: 31 additions & 2 deletions tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::fmt::Write;
use std::fs::{self, File};
use std::path::Path;

#[derive(Debug, Clone)]
struct Test {
name: &'static str,
cmd: &'static str,
Expand All @@ -28,7 +29,7 @@ impl Test {
}

fn make_tests() -> Result<()> {
let postmortem = [
let all_tests = [
Test::witharg("extract", "extract", "app.toml"),
Test::witharg("extract-list", "extract", "--list"),
Test::basic("manifest"),
Expand All @@ -45,6 +46,34 @@ fn make_tests() -> Result<()> {
Test::basic("tasks"),
Test::witharg("tasks-slvr", "tasks", "-slvr"),
Test::basic("log"),
// don't need to rerun all of the cmds, just try to exercise each component of the core,
// registers, memory, start, stop
// also run each qemu command with the a different port so they can be parallelized
Test::witharg(
"qemu-readvar",
"qemu",
// these strings are weird since we have to escape the string so it is correctly
// written to the toml, but the toml itself also needs the escape characters for when
// it is parsed.
"--port 3333 --command \\\"readvar CLOCK_FREQ_KHZ\\\"",
),
Test::witharg(
"qemu-halt",
"qemu",
" --port 3334 --command \\\"halt\\\"",
),
Test::witharg(
"qemu-resume",
"qemu",
"--port 3335 --command \\\"resume\\\"",
),
Test::witharg(
"qemu-dump",
"qemu",
"--port 3336 --command \\\"dump\\\"",
),
//TODO how to verify halt/resume actually work
//TODO a write test might also be useful
];

let mut cores = vec![];
Expand All @@ -67,7 +96,7 @@ fn make_tests() -> Result<()> {
}
}

for test in &postmortem {
for test in &all_tests {
let dirpath = format!("./tests/cmd/{}", test.name);
let dir = Path::new(&dirpath);

Expand Down
Binary file added tests/cmd/cores/hubris.core.hifive1.1
Binary file not shown.
Empty file.
23 changes: 23 additions & 0 deletions tests/cmd/extract-list/extract-list.hifive1.1.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
SIZE NAME
462 README.TXT
46 git-rev
727 app.toml
248 chip.toml
345580 elf/task/jefe
45820 elf/task/pong
130200 elf/task/ping
34588 elf/task/idle
448576 elf/kernel
70341 img/combined.srec
36040 img/combined.elf
100517 img/combined.ihex
35712 img/combined.bin
70341 img/final.srec
36040 img/final.elf
100517 img/final.ihex
35712 img/final.bin
850 img/flash.ron
503 debug/script.gdb
582 debug/openocd.cfg
213 debug/openocd.gdb
181 debug/qemu.sh
10 changes: 10 additions & 0 deletions tests/cmd/extract-list/extract-list.hifive1.1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#
# This test case has been automatically created, but can be edited and
# should be checked in. Should it ever be regenerated, simply delete
# it and re-run "cargo test"
#
fs.base = "../cores"
bin.name = "humility"
args = "-d hubris.core.hifive1.1 extract --list"

1 change: 1 addition & 0 deletions tests/cmd/extract/extract.hifive1.1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
humility: extracting app.toml to stdout
39 changes: 39 additions & 0 deletions tests/cmd/extract/extract.hifive1.1.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name = "demo-hifive1-revb"
target = "riscv32imc-unknown-none-elf"
board = "hifive1-revb"
chip = "../../chips/fe310-g002"
stacksize = 896

[kernel]
name = "demo-hifive1-revb"
requires = {flash = 16384, ram = 2048}
features = []

[tasks.jefe]
name = "task-jefe"
priority = 0
max-sizes = {flash = 16384, ram = 4096}
start = true
features = ["log-stringbuf"]
stacksize = 1536

[tasks.pong]
name = "task-pong"
priority = 3
max-sizes = {flash = 8192, ram = 2048}
start = true

[tasks.ping]
name = "task-ping"
priority = 4
max-sizes = {flash = 8192, ram = 2048}
stacksize = 512
start = true
task-slots = [{peer = "pong"}]

[tasks.idle]
name = "task-idle"
priority = 5
max-sizes = {flash = 256, ram = 512}
stacksize = 256
start = true
10 changes: 10 additions & 0 deletions tests/cmd/extract/extract.hifive1.1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#
# This test case has been automatically created, but can be edited and
# should be checked in. Should it ever be regenerated, simply delete
# it and re-run "cargo test"
#
fs.base = "../cores"
bin.name = "humility"
args = "-d hubris.core.hifive1.1 extract app.toml"

1 change: 1 addition & 0 deletions tests/cmd/log/log.hifive1.1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
humility: attached to dump
5 changes: 5 additions & 0 deletions tests/cmd/log/log.hifive1.1.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
humility: stringbuf ringbuf::stringbuf::LOG__STRINGBUF in jefe:
t address 0x0
924: Task #2 Illegal instruction
927: Task #2 Memory fault at address 0x0
930: Task #2 Illegal instruction
10 changes: 10 additions & 0 deletions tests/cmd/log/log.hifive1.1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#
# This test case has been automatically created, but can be edited and
# should be checked in. Should it ever be regenerated, simply delete
# it and re-run "cargo test"
#
fs.base = "../cores"
bin.name = "humility"
args = "-d hubris.core.hifive1.1 log"

Empty file.
14 changes: 14 additions & 0 deletions tests/cmd/manifest/manifest.hifive1.1.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version => hubris build archive v3
git rev => 45b4b5979c548102c9b07e99c346b45157952d39-dirty
image id => [63, bc, fe, 8d, 6f, 87, 97, ff]
board => hifive1-revb
target => riscv32imc-unknown-none-elf
features =>
total size => 35K
kernel size => 16K
tasks => 4
ID TASK SIZE FEATURES
0 jefe 14.0K log-stringbuf
1 idle 0.1K
2 pong 0.4K
3 ping 4.6K
10 changes: 10 additions & 0 deletions tests/cmd/manifest/manifest.hifive1.1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#
# This test case has been automatically created, but can be edited and
# should be checked in. Should it ever be regenerated, simply delete
# it and re-run "cargo test"
#
fs.base = "../cores"
bin.name = "humility"
args = "-d hubris.core.hifive1.1 manifest"

1 change: 1 addition & 0 deletions tests/cmd/map/map.hifive1.1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
humility: attached to dump
13 changes: 13 additions & 0 deletions tests/cmd/map/map.hifive1.1.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DESC LOW HIGH SIZE ATTR ID TASK
- 0x20010000 - 0x20013459 13KiB r-x-- - kernel
- 0x20013460 - 0x2001399f 1KiB r---- - kernel
0x200137d4 0x20014000 - 0x2001774f 13KiB r-x-- 0 jefe
0x2001381c 0x20017750 - 0x200177df 144 r-x-- 3 idle
0x200137ec 0x200177e0 - 0x200179af 464 r-x-- 1 pong
0x20013804 0x200179b0 - 0x20018b7f 4KiB r-x-- 2 ping
- 0x80000000 - 0x800003ff 1KiB rw--- - kernel
- 0x80000400 - 0x800007b7 952 rw--- - kernel
0x200137e0 0x80000800 - 0x80000edf 1KiB rw--- 0 jefe
0x20013828 0x80000ee0 - 0x80000fdf 256 rw--- 3 idle
0x20013810 0x80000fe0 - 0x8000125f 640 rw--- 2 ping
0x200137f8 0x80001260 - 0x800015df 896 rw--- 1 pong
10 changes: 10 additions & 0 deletions tests/cmd/map/map.hifive1.1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#
# This test case has been automatically created, but can be edited and
# should be checked in. Should it ever be regenerated, simply delete
# it and re-run "cargo test"
#
fs.base = "../cores"
bin.name = "humility"
args = "-d hubris.core.hifive1.1 map"

1 change: 1 addition & 0 deletions tests/cmd/pmp/pmp.hifive1.1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
humility: attached to dump
3 changes: 3 additions & 0 deletions tests/cmd/pmp/pmp.hifive1.1.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DESC LOW HIGH SIZE ATTR MODE
pmpaddr01 0x200177e0 - 0x200179af 1cf r-x- TOR
pmpaddr03 0x80001260 - 0x800015df 37f rw-- TOR
10 changes: 10 additions & 0 deletions tests/cmd/pmp/pmp.hifive1.1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#
# This test case has been automatically created, but can be edited and
# should be checked in. Should it ever be regenerated, simply delete
# it and re-run "cargo test"
#
fs.base = "../cores"
bin.name = "humility"
args = "-d hubris.core.hifive1.1 pmp"

4 changes: 4 additions & 0 deletions tests/cmd/qemu-dump/qemu-dump.chilly.0.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
humility qemu failed: No 'qemu.sh' archive found in the hubris archive

Caused by:
failed to find 'debug/qemu.sh': specified file not found in archive
Empty file.
11 changes: 11 additions & 0 deletions tests/cmd/qemu-dump/qemu-dump.chilly.0.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

#
# This test case has been automatically created, but can be edited and
# should be checked in. Should it ever be regenerated, simply delete
# it and re-run "cargo test"
#
fs.base = "../cores"
bin.name = "humility"
args = "-d hubris.core.chilly.0 qemu --command \"dump\""

status.code = 1
4 changes: 4 additions & 0 deletions tests/cmd/qemu-dump/qemu-dump.flash-ram-mismatch.0.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
humility qemu failed: No 'qemu.sh' archive found in the hubris archive

Caused by:
failed to find 'debug/qemu.sh': specified file not found in archive
Empty file.
11 changes: 11 additions & 0 deletions tests/cmd/qemu-dump/qemu-dump.flash-ram-mismatch.0.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

#
# This test case has been automatically created, but can be edited and
# should be checked in. Should it ever be regenerated, simply delete
# it and re-run "cargo test"
#
fs.base = "../cores"
bin.name = "humility"
args = "-d hubris.core.flash-ram-mismatch.0 qemu --command \"dump\""

status.code = 1
4 changes: 4 additions & 0 deletions tests/cmd/qemu-dump/qemu-dump.hifive1.0.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
humility qemu failed: No 'qemu.sh' archive found in the hubris archive

Caused by:
failed to find 'debug/qemu.sh': specified file not found in archive
Empty file.
11 changes: 11 additions & 0 deletions tests/cmd/qemu-dump/qemu-dump.hifive1.0.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

#
# This test case has been automatically created, but can be edited and
# should be checked in. Should it ever be regenerated, simply delete
# it and re-run "cargo test"
#
fs.base = "../cores"
bin.name = "humility"
args = "-d hubris.core.hifive1.0 qemu --command \"dump\""

status.code = 1
Loading