-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Nick Spinale <[email protected]>
- Loading branch information
Showing
24 changed files
with
923 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
crates/private/tests/root-task/default-test-harness/Cargo.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# | ||
# Copyright 2023, Colias Group, LLC | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
|
||
{ mk, localCrates, versions }: | ||
|
||
mk { | ||
package.name = "tests-root-task-default-test-harness"; | ||
dependencies = { | ||
inherit (versions) log; | ||
}; | ||
dev-dependencies = { | ||
test = let package = "sel4-root-task-default-test-harness"; in localCrates.${package} // { | ||
inherit package; | ||
}; | ||
}; | ||
} |
24 changes: 24 additions & 0 deletions
24
crates/private/tests/root-task/default-test-harness/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# | ||
# Copyright 2023, Colias Group, LLC | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
# | ||
# This file is generated from './Cargo.nix'. You can edit this file directly | ||
# if you are not using this project's Cargo manifest management tools. | ||
# See 'hacking/cargo-manifest-management/README.md' for more information. | ||
# | ||
|
||
[package] | ||
name = "tests-root-task-default-test-harness" | ||
version = "0.1.0" | ||
authors = ["Nick Spinale <[email protected]>"] | ||
edition = "2021" | ||
license = "BSD-2-Clause" | ||
|
||
[dependencies] | ||
log = "0.4.17" | ||
|
||
[dev-dependencies.test] | ||
path = "../../../../sel4-root-task/default-test-harness" | ||
package = "sel4-root-task-default-test-harness" |
36 changes: 36 additions & 0 deletions
36
crates/private/tests/root-task/default-test-harness/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// Copyright 2023, Colias Group, LLC | ||
// | ||
// SPDX-License-Identifier: BSD-2-Clause | ||
// | ||
|
||
#![no_std] | ||
|
||
#[cfg(test)] | ||
mod test { | ||
#[test] | ||
fn foo() {} | ||
|
||
#[test] | ||
#[should_panic] | ||
fn bar() { | ||
assert!(false); | ||
} | ||
} | ||
|
||
mod m { | ||
#[cfg(test)] | ||
mod test { | ||
#[test] | ||
fn foo() {} | ||
|
||
#[ignore = "a reason"] | ||
#[test] | ||
fn bar() { | ||
assert!(false); | ||
} | ||
} | ||
} | ||
|
||
// cargo rustc $h --target aarch64-sel4 -p tests-root-task-default-test-harness --profile=check -- --test -Zunpretty=expanded | ||
// cargo rustc $h --target riscv64imac-sel4 -p tests-root-task-default-test-harness --profile=check -- --test -Zunpretty=expanded |
34 changes: 34 additions & 0 deletions
34
crates/private/tests/root-task/ring-test-harness/Cargo.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# | ||
# Copyright 2023, Colias Group, LLC | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
|
||
{ mk, localCrates, versions }: | ||
|
||
mk rec { | ||
package.name = "tests-root-task-ring-test-harness"; | ||
dependencies = { | ||
inherit (localCrates) | ||
sel4 | ||
sel4-root-task | ||
sel4-test-harness | ||
; | ||
sel4-newlib = localCrates.sel4-newlib // { | ||
features = [ | ||
"nosys" | ||
"all-symbols" | ||
"sel4-panicking-env" | ||
]; | ||
}; | ||
getrandom = { | ||
version = "0.2.10"; | ||
features = [ "custom" ]; | ||
}; | ||
rand = { | ||
version = "0.8.5"; | ||
default-features = false; | ||
features = [ "small_rng" ]; | ||
}; | ||
}; | ||
} |
28 changes: 28 additions & 0 deletions
28
crates/private/tests/root-task/ring-test-harness/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# Copyright 2023, Colias Group, LLC | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
# | ||
# This file is generated from './Cargo.nix'. You can edit this file directly | ||
# if you are not using this project's Cargo manifest management tools. | ||
# See 'hacking/cargo-manifest-management/README.md' for more information. | ||
# | ||
|
||
[package] | ||
name = "tests-root-task-ring-test-harness" | ||
version = "0.1.0" | ||
authors = ["Nick Spinale <[email protected]>"] | ||
edition = "2021" | ||
license = "BSD-2-Clause" | ||
|
||
[dependencies] | ||
getrandom = { version = "0.2.10", features = ["custom"] } | ||
rand = { version = "0.8.5", default-features = false, features = ["small_rng"] } | ||
sel4 = { path = "../../../../sel4" } | ||
sel4-root-task = { path = "../../../../sel4-root-task" } | ||
sel4-test-harness = { path = "../../../../sel4-test-harness" } | ||
|
||
[dependencies.sel4-newlib] | ||
path = "../../../../sel4-newlib" | ||
features = ["nosys", "all-symbols", "sel4-panicking-env"] |
58 changes: 58 additions & 0 deletions
58
crates/private/tests/root-task/ring-test-harness/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// Copyright 2023, Colias Group, LLC | ||
// | ||
// SPDX-License-Identifier: BSD-2-Clause | ||
// | ||
|
||
#![no_std] | ||
#![no_main] | ||
#![feature(cfg_target_thread_local)] | ||
#![feature(thread_local)] | ||
|
||
use core::cell::RefCell; | ||
|
||
use rand::rngs::SmallRng; | ||
use rand::{RngCore, SeedableRng}; | ||
|
||
use sel4_newlib as _; | ||
use sel4_root_task::root_task; | ||
use sel4_test_harness::run_test_main; | ||
|
||
pub use sel4_test_harness::for_generated_code::*; | ||
|
||
const HEAP_SIZE: usize = 256 * 1024 * 1024; | ||
|
||
#[root_task(heap_size = HEAP_SIZE)] | ||
fn main(_bootinfo: &sel4::BootInfo) -> ! { | ||
seed_insecure_dummy_rng(0); | ||
run_test_main(); | ||
sel4::BootInfo::init_thread_tcb().tcb_suspend().unwrap(); | ||
unreachable!() | ||
} | ||
|
||
#[cfg(not(target_thread_local))] | ||
compile_error!(""); | ||
|
||
#[thread_local] | ||
static RNG: RefCell<Option<SmallRng>> = RefCell::new(None); | ||
|
||
pub fn seed_insecure_dummy_rng(seed: u64) { | ||
assert!(RNG.replace(Some(SmallRng::seed_from_u64(seed))).is_none()); | ||
} | ||
|
||
pub fn insecure_dummy_rng(buf: &mut [u8]) -> Result<(), getrandom::Error> { | ||
if 1_u32.swap_bytes() == 0 { | ||
panic!() | ||
} | ||
RNG.borrow_mut().as_mut().unwrap().fill_bytes(buf); | ||
Ok(()) | ||
} | ||
|
||
getrandom::register_custom_getrandom!(insecure_dummy_rng); | ||
|
||
// https://github.com/rust-lang/compiler-builtins/pull/563 | ||
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] | ||
#[no_mangle] | ||
pub extern "C" fn __bswapsi2(u: u32) -> u32 { | ||
u.swap_bytes() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# Copyright 2023, Colias Group, LLC | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
|
||
{ mk, localCrates, versions }: | ||
|
||
mk rec { | ||
package.name = "sel4-root-task-default-test-harness"; | ||
dependencies = { | ||
inherit (localCrates) | ||
sel4 | ||
sel4-root-task | ||
sel4-test-harness | ||
; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# | ||
# Copyright 2023, Colias Group, LLC | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
# | ||
# This file is generated from './Cargo.nix'. You can edit this file directly | ||
# if you are not using this project's Cargo manifest management tools. | ||
# See 'hacking/cargo-manifest-management/README.md' for more information. | ||
# | ||
|
||
[package] | ||
name = "sel4-root-task-default-test-harness" | ||
version = "0.1.0" | ||
authors = ["Nick Spinale <[email protected]>"] | ||
edition = "2021" | ||
license = "BSD-2-Clause" | ||
|
||
[dependencies] | ||
sel4 = { path = "../../sel4" } | ||
sel4-root-task = { path = ".." } | ||
sel4-test-harness = { path = "../../sel4-test-harness" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// Copyright 2023, Colias Group, LLC | ||
// | ||
// SPDX-License-Identifier: BSD-2-Clause | ||
// | ||
|
||
#![no_std] | ||
#![no_main] | ||
|
||
use sel4_root_task::root_task; | ||
use sel4_test_harness::run_test_main; | ||
|
||
pub use sel4_test_harness::for_generated_code::*; | ||
|
||
const HEAP_SIZE: usize = 64 * 1024 * 1024; | ||
|
||
#[root_task(heap_size = HEAP_SIZE)] | ||
fn main(_bootinfo: &sel4::BootInfo) -> ! { | ||
run_test_main(); | ||
sel4::BootInfo::init_thread_tcb().tcb_suspend().unwrap(); | ||
unreachable!() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# | ||
# Copyright 2023, Colias Group, LLC | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
|
||
{ mk, localCrates, mkDefaultFrontmatterWithReuseArgs, defaultReuseFrontmatterArgs }: | ||
|
||
mk rec { | ||
nix.frontmatter = mkDefaultFrontmatterWithReuseArgs (defaultReuseFrontmatterArgs // { | ||
licenseID = package.license; | ||
}); | ||
package.name = "sel4-test-harness"; | ||
package.license = "MIT OR Apache-2.0"; | ||
dependencies = { | ||
inherit (localCrates) | ||
sel4-panicking-env | ||
sel4-panicking | ||
sel4-immediate-sync-once-cell | ||
; | ||
}; | ||
} |
Oops, something went wrong.