dirty fix to run tests

This commit is contained in:
histausse 2022-10-14 23:43:30 +02:00
parent 037c48fba0
commit 342e21218f
Signed by: histausse
GPG key ID: 67486F107F62E9E9
3 changed files with 28 additions and 3 deletions

View file

@ -91,12 +91,14 @@ def task_install_dep():
def task_compile(): def task_compile():
""" Compile the sources. """ Compile the sources.
""" """
return { task = {
'file_dep': get_build_dep(), 'file_dep': get_build_dep(),
'targets': [f'{consts.WORK_DIR}/target/{consts.TARGET}/release/kernel'], 'targets': [f'{consts.WORK_DIR}/target/{consts.TARGET}/release/kernel'],
'actions': [f'RUSTFLAGS="{consts.RUSTC_FLAGS}" cargo rustc --target={consts.TARGET} {consts.CARGO_COMPILE_FLAGS}'], 'actions': [f'RUSTFLAGS="{consts.RUSTC_FLAGS}" cargo rustc --target={consts.TARGET} {consts.CARGO_COMPILE_FLAGS}'],
'clean': [f'cargo clean'] 'clean': [f'cargo clean']
} }
print(task)
return task
def task_build(): def task_build():
""" Strip the binary from ELF format to raw binary. """ Strip the binary from ELF format to raw binary.

View file

@ -5,8 +5,8 @@
//! but it's a project for discovering rust on embedded, so its architecture is less generic and //! but it's a project for discovering rust on embedded, so its architecture is less generic and
//! I'm trying to reuse knowledge from Telecom-Paris SE203 class as much as I can. //! I'm trying to reuse knowledge from Telecom-Paris SE203 class as much as I can.
#![no_main] #![cfg_attr(not(test), no_main)]
#![no_std] #![cfg_attr(not(test), no_std)]
#![feature(format_args_nl)] #![feature(format_args_nl)]
#![feature(panic_info_message)] #![feature(panic_info_message)]
@ -16,19 +16,26 @@ mod traits;
mod bsp; mod bsp;
mod utils; mod utils;
#[cfg(not(test))]
mod panic; mod panic;
#[cfg(not(test))]
mod print; mod print;
#[cfg(not(test))]
use core::arch::global_asm; use core::arch::global_asm;
#[cfg(not(test))]
use core::arch::asm; use core::arch::asm;
// TODO: handle this with features // TODO: handle this with features
//use crate::bsp::qemu::console::console; //use crate::bsp::qemu::console::console;
#[cfg(not(test))]
use crate::bsp::rpi3::uart::console; use crate::bsp::rpi3::uart::console;
#[cfg(not(test))]
use crate::bsp::rpi3::gpio; use crate::bsp::rpi3::gpio;
// TODO: move this to BSP // TODO: move this to BSP
/// Pause the core with a infinit loop /// Pause the core with a infinit loop
#[cfg(not(test))]
#[inline(always)] #[inline(always)]
pub fn wait_forever() -> ! { pub fn wait_forever() -> ! {
loop { loop {
@ -37,9 +44,11 @@ pub fn wait_forever() -> ! {
} }
// TODO: move this to BSP // TODO: move this to BSP
#[cfg(not(test))]
global_asm!(include_str!("boot.s")); global_asm!(include_str!("boot.s"));
/// Start the rust part of the kernel /// Start the rust part of the kernel
#[cfg(not(test))]
#[no_mangle] #[no_mangle]
pub unsafe fn _start_rust() -> ! { pub unsafe fn _start_rust() -> ! {
@ -85,3 +94,6 @@ pub unsafe fn _start_rust() -> ! {
panic!("Paniccccccc") panic!("Paniccccccc")
*/ */
} }
#[cfg(test)]
fn main() {}

View file

@ -81,3 +81,14 @@ impl Field {
self.mask self.mask
} }
} }
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test() {
let f = Field::new(0, 0, 1);
assert_eq!(1, f.get_mask());
}
}