Skip to content

Commit c6e59f2

Browse files
author
Johnathan Van Why
committed
Merge branch 'master' into allowed
2 parents 5824434 + 62346d2 commit c6e59f2

File tree

9 files changed

+98
-3
lines changed

9 files changed

+98
-3
lines changed

.github/workflows/artifacts.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Artifacts
2+
on: [push]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout repository
9+
uses: actions/checkout@v2
10+
11+
- name: Install Rust toolchain
12+
uses: actions-rs/[email protected]
13+
with:
14+
profile: minimal
15+
16+
- name: Install dependencies
17+
run: |
18+
rustup target add thumbv7em-none-eabi
19+
rustup target add riscv32imac-unknown-none-elf
20+
rustup target add riscv32imc-unknown-none-elf
21+
cargo install elf2tab --version 0.4.0
22+
23+
- name: Build Hello World
24+
run: |
25+
FEATURES="alloc" make flash-apollo3 EXAMPLE=hello_world -j2
26+
FEATURES="alloc" make flash-hail EXAMPLE=hello_world -j2
27+
FEATURES="alloc" make flash-nucleo_f429zi EXAMPLE=hello_world -j2
28+
FEATURES="alloc" make flash-nucleo_f446re EXAMPLE=hello_world -j2
29+
FEATURES="alloc" make flash-nrf52840 EXAMPLE=hello_world -j2
30+
FEATURES="alloc" make flash-opentitan EXAMPLE=hello_world -j2
31+
FEATURES="alloc" make flash-hifive1 EXAMPLE=hello_world -j2
32+
FEATURES="alloc" make flash-nrf52 EXAMPLE=hello_world -j2
33+
34+
- name: Build libtock-test
35+
run: |
36+
FEATURES="alloc" make flash-apollo3 EXAMPLE=libtock_test -j2
37+
FEATURES="alloc" make flash-hail EXAMPLE=libtock_test -j2
38+
FEATURES="alloc" make flash-nucleo_f429zi EXAMPLE=libtock_test -j2
39+
FEATURES="alloc" make flash-nucleo_f446re EXAMPLE=libtock_test -j2
40+
FEATURES="alloc" make flash-nrf52840 EXAMPLE=libtock_test -j2
41+
FEATURES="alloc" make flash-opentitan EXAMPLE=libtock_test -j2
42+
FEATURES="alloc" make flash-hifive1 EXAMPLE=libtock_test -j2
43+
FEATURES="alloc" make flash-nrf52 EXAMPLE=libtock_test -j2
44+
45+
- name: Build extra tests
46+
run: |
47+
FEATURES="alloc" make flash-opentitan EXAMPLE=hmac -j2
48+
49+
- name: Archive artifacts
50+
uses: actions/upload-artifact@v2
51+
with:
52+
name: libtock-rs examples
53+
path: target/*/tab/*/*/*.tbf

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ edition = "2018"
99
alloc = ["libtock_core/alloc"]
1010
custom_panic_handler = ["libtock_core/custom_panic_handler"]
1111
custom_alloc_error_handler = ["libtock_core/custom_alloc_error_handler"]
12+
# In the QEMU-emulated HiFive1 target, we do not have connected GPIO pins or a
13+
# working timer interface. These features allow the test's user to disable these
14+
# tests in environments where they will not pass.
1215
__internal_disable_gpio_in_integration_test = []
16+
__internal_disable_timer_in_integration_test = []
1317

1418
[dependencies]
1519
libtock_core = { path = "core" }

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ print-sizes: examples
6868
.PHONY: test-qemu-hifive
6969
test-qemu-hifive: kernel-hifive
7070
PLATFORM=hifive1 cargo rrv32imac --example libtock_test --features=alloc \
71-
--features=__internal_disable_gpio_in_integration_test
71+
--features=__internal_disable_gpio_in_integration_test \
72+
--features=__internal_disable_timer_in_integration_test
7273
cargo run -p test_runner
7374

7475
.PHONY: examples

core/platform/src/error_code.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/// An error code returned by the kernel. Tock's system calls return errors as a
2+
/// negative `isize`. This wraps the isize, and is useful for adding type safety
3+
/// to APIs.
4+
5+
#[derive(Clone, Copy, PartialEq, Eq)]
6+
pub struct ErrorCode {
7+
// Note: value *should* always be negative, but we do not *verify* that so
8+
// unsafe code cannot rely on value being negative.
9+
value: isize,
10+
}
11+
12+
impl ErrorCode {
13+
// Converts the given isize into an ErrorCode. Note that the isize should be
14+
// negative, although that is not verified to reduce code size. We don't
15+
// implement From because not every isize converts sensibly to an ErrorCode.
16+
pub fn new(value: isize) -> ErrorCode {
17+
ErrorCode { value }
18+
}
19+
}
20+
21+
impl Into<isize> for ErrorCode {
22+
fn into(self) -> isize {
23+
self.value
24+
}
25+
}

core/platform/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@
99
// unit test environments.
1010

1111
mod allows;
12+
mod error_code;
1213

1314
pub use allows::{AllowReadable, Allowed};
15+
pub use error_code::ErrorCode;

examples-features/libtock_test.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ async fn libtock_test(
5151
test.formatting()?;
5252
test.heap()?;
5353
test.drivers_only_instantiable_once()?;
54+
#[cfg(not(feature = "__internal_disable_timer_in_integration_test"))]
5455
test.callbacks(timer).await?;
5556
#[cfg(not(feature = "__internal_disable_gpio_in_integration_test"))]
5657
test.gpio(gpio)?;
@@ -113,6 +114,10 @@ impl LibtockTest {
113114
)
114115
}
115116

117+
#[cfg_attr(
118+
feature = "__internal_disable_timer_in_integration_test",
119+
allow(dead_code)
120+
)]
116121
async fn callbacks(&mut self, timer_context: &mut DriverContext) -> TockResult<()> {
117122
let mut callback_hit = false;
118123
let mut with_callback = timer_context.with_callback(|_, _| callback_hit = true);

test_runner/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
1414
async fn perform_tests() -> Result<(), Box<dyn std::error::Error>> {
1515
let mut failed_tests = Vec::new();
1616

17-
let tests = Command::new("tock/tools/qemu/riscv32-softmmu/qemu-system-riscv32")
17+
let tests = Command::new("tock/tools/qemu-build/riscv32-softmmu/qemu-system-riscv32")
1818
.arg("-M")
1919
.arg("sifive_e,revb=true")
2020
.arg("-kernel")

tock

Submodule tock updated 265 files

tools/flash.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,10 @@ if [ $tockload == "n" ]; then
7070
exit 0
7171
fi
7272

73+
if ! [ -x "$(command -v tockloader)" ]; then
74+
echo "Skipping flashing as tockloader isn't installed"
75+
exit 0
76+
fi
77+
7378
tockloader uninstall ${tockloader_flags} || true
7479
tockloader install ${tockloader_flags} "${tab_file_name}"

0 commit comments

Comments
 (0)