x86test_types/
lib.rs

1#[macro_export]
2macro_rules! kassert {
3    ($test:expr) => ({
4        if !$test {
5            sprintln!("kassertion failed: {}, {}:{}:{}", stringify!($test), file!(), line!(), column!());
6            unsafe { x86test::outw(0xf4, 0x01); } // exit failure
7        }
8    });
9    ($test:expr, $($arg:tt)+) => ({
10        if !$test {
11            sprintln!("kassertion failed: {}, {}:{}:{}", format_args!($($arg)+), file!(), line!(), column!());
12            #[allow(unused_unsafe)]
13            unsafe { x86test::outw(0xf4, 0x01); } // exit failure
14        }
15    });
16}
17
18#[macro_export]
19macro_rules! kpanic {
20    ($test:expr) => ({
21        sprintln!("kpanic: {}, {}:{}:{}", stringify!($test), file!(), line!(), column!());
22        unsafe { x86test::outw(0xf4, 0x02); } // exit failure
23    });
24    ($test:expr, $($arg:tt)+) => ({
25        if !$test {
26            sprintln!("kpanic: {}, {}:{}:{}", format_args!($($arg)+), file!(), line!(), column!());
27            #[allow(unused_unsafe)]
28            unsafe { x86test::outw(0xf4, 0x02); } // exit failure
29        }
30    });
31}
32
33pub struct StaticTestFn(pub fn());
34
35pub struct X86TestFn {
36    /// Name of test.
37    pub name: &'static str,
38    /// Ignore this test?
39    pub ignore: bool,
40    /// Create an identify map of process inside the VM?
41    pub identity_map: bool,
42    /// Add guest physical memory in this range.
43    pub physical_memory: (u64, u64),
44    /// When read on ioport_enable.0 return ioport_enable.1 as value.
45    /// When write on ioport_enable.0 abort if value was not ioport_enable.1.
46    pub ioport_enable: (u16, u32),
47    /// Test has a #[should_panic] attribute
48    pub should_panic: bool,
49    /// Test has a #[should_halt] attribute
50    pub should_halt: bool,
51    /// Test function we need to execute (in a VM).
52    pub testfn: StaticTestFn,
53}