Skip to content

Commit

Permalink
Format with cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoncouture committed Jan 4, 2023
1 parent a87e34d commit 8564ab7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 24 deletions.
9 changes: 7 additions & 2 deletions tests/default_settings.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
use bootloader_test_runner::define_test;
const BASIC_BOOT_KERNEL: &str = env!("CARGO_BIN_FILE_TEST_KERNEL_DEFAULT_SETTINGS_basic_boot");
const SHOULD_PANIC_KERNEL: &str = env!("CARGO_BIN_FILE_TEST_KERNEL_DEFAULT_SETTINGS_should_panic");
const CHECK_BOOT_INFO_KERNEL: &str = env!("CARGO_BIN_FILE_TEST_KERNEL_DEFAULT_SETTINGS_check_boot_info");
const CHECK_BOOT_INFO_KERNEL: &str =
env!("CARGO_BIN_FILE_TEST_KERNEL_DEFAULT_SETTINGS_check_boot_info");

define_test!(basic_boot, BASIC_BOOT_KERNEL);
define_test!(should_panic, SHOULD_PANIC_KERNEL);
define_test!(check_boot_info, CHECK_BOOT_INFO_KERNEL);
define_test!(disable_default_ramdisk_macro_test, BASIC_BOOT_KERNEL, without_ramdisk_tests);
define_test!(
disable_default_ramdisk_macro_test,
BASIC_BOOT_KERNEL,
without_ramdisk_tests
);
3 changes: 2 additions & 1 deletion tests/higher_half.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use bootloader_test_runner::define_test;
const BASIC_BOOT_KERNEL: &str = env!("CARGO_BIN_FILE_TEST_KERNEL_HIGHER_HALF_basic_boot");
const SHOULD_PANIC_KERNEL: &str = env!("CARGO_BIN_FILE_TEST_KERNEL_HIGHER_HALF_should_panic");
const CHECK_BOOT_INFO_KERNEL: &str = env!("CARGO_BIN_FILE_TEST_KERNEL_HIGHER_HALF_check_boot_info");
const VERIFY_HIGHER_HALF_KERNEL: &str = env!("CARGO_BIN_FILE_TEST_KERNEL_HIGHER_HALF_verify_higher_half");
const VERIFY_HIGHER_HALF_KERNEL: &str =
env!("CARGO_BIN_FILE_TEST_KERNEL_HIGHER_HALF_verify_higher_half");

define_test!(basic_boot, BASIC_BOOT_KERNEL);
define_test!(should_panic, SHOULD_PANIC_KERNEL);
Expand Down
6 changes: 4 additions & 2 deletions tests/map_phys_mem.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use bootloader_test_runner::define_test;
const CHECK_BOOT_INFO_KERNEL: &str = env!("CARGO_BIN_FILE_TEST_KERNEL_MAP_PHYS_MEM_check_boot_info");
const ACCESS_PHYS_MEM_KERNEL: &str = env!("CARGO_BIN_FILE_TEST_KERNEL_MAP_PHYS_MEM_access_phys_mem");
const CHECK_BOOT_INFO_KERNEL: &str =
env!("CARGO_BIN_FILE_TEST_KERNEL_MAP_PHYS_MEM_check_boot_info");
const ACCESS_PHYS_MEM_KERNEL: &str =
env!("CARGO_BIN_FILE_TEST_KERNEL_MAP_PHYS_MEM_access_phys_mem");

define_test!(check_boot_info, CHECK_BOOT_INFO_KERNEL);
define_test!(access_phys_mem, ACCESS_PHYS_MEM_KERNEL);
2 changes: 1 addition & 1 deletion tests/ramdisk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ static RAMDISK_PATH: &str = "tests/ramdisk.txt";
static BASIC_BOOT_KERNEL: &str = env!("CARGO_BIN_FILE_TEST_KERNEL_RAMDISK_basic_boot");
static RAMDISK_KERNEL: &str = env!("CARGO_BIN_FILE_TEST_KERNEL_RAMDISK_ramdisk");
define_test!(basic_boot, BASIC_BOOT_KERNEL, RAMDISK_PATH);
define_test!(ramdisk, RAMDISK_KERNEL, RAMDISK_PATH);
define_test!(ramdisk, RAMDISK_KERNEL, RAMDISK_PATH);
38 changes: 20 additions & 18 deletions tests/runner/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
use std::{io::Write, path::{Path, PathBuf}, process::Command};
use std::{
io::Write,
path::{Path, PathBuf},
process::Command,
};

pub extern crate lazy_static;
pub extern crate paste;
#[doc(hidden)]
pub use paste::paste;
#[doc(hidden)]
pub use lazy_static::lazy_static;
#[doc(hidden)]
pub use paste::paste;
use rand::Rng;

const QEMU_ARGS: &[&str] = &[
Expand All @@ -20,10 +24,10 @@ const QEMU_ARGS: &[&str] = &[

pub fn generate_test_image_filename(path: &Path) -> PathBuf {
let s: String = rand::thread_rng()
.sample_iter(&rand::distributions::Alphanumeric)
.take(8)
.map(char::from)
.collect();
.sample_iter(&rand::distributions::Alphanumeric)
.take(8)
.map(char::from)
.collect();
path.with_file_name(s)
}

Expand Down Expand Up @@ -66,7 +70,6 @@ pub fn run_test_kernel_uefi(kernel_binary_path: &str, ramdisk_path: Option<&str>

uefi_builder.create_disk_image(&gpt_path).unwrap();


run_test_kernel_on_uefi(&gpt_path);
}

Expand All @@ -76,7 +79,6 @@ pub fn run_test_kernel(kernel_binary_path: &str, ramdisk_path: Option<&str>) {
run_test_kernel_tftp(kernel_binary_path, ramdisk_path);
}


pub fn run_test_kernel_tftp(kernel_binary_path: &str, ramdisk_path: Option<&str>) {
let kernel_path = Path::new(kernel_binary_path);
let ramdisk_path = match ramdisk_path {
Expand Down Expand Up @@ -171,12 +173,12 @@ pub fn run_test_kernel_on_uefi_pxe(out_tftp_path: &Path) {

#[macro_export]
/// Creates a series of test functions for a given kernel image to cover bios, uefi, and tftp
///
///
/// define_test!(name, kernel) will generate all 3 tests, with a ramdisk and no-ramdisk variant.
/// define_test!(name, kernel, ramdisk) will generate all 3 tests, with the specified ramdisk
/// define_test!(name, kernel, without_ramdisk_tests) will generate all 3 tests, with only the no-ramdisk variant
macro_rules! define_test {
($test_name: ident, $bin: tt) => (
macro_rules! define_test {
($test_name: ident, $bin: tt) => {
$crate::paste! {
#[test]
fn [< $test_name _uefi_without_ramdisk >]() {
Expand Down Expand Up @@ -227,8 +229,8 @@ pub fn run_test_kernel_on_uefi_pxe(out_tftp_path: &Path) {
);
}
}
);
($test_name: ident, $bin:tt, without_ramdisk_tests) => (
};
($test_name: ident, $bin:tt, without_ramdisk_tests) => {
$crate::paste! {
#[test]
fn [< $test_name _uefi_without_ramdisk >]() {
Expand All @@ -254,8 +256,8 @@ pub fn run_test_kernel_on_uefi_pxe(out_tftp_path: &Path) {
);
}
}
);
($test_name: ident, $bin: tt, $ramdisk: tt) => (
};
($test_name: ident, $bin: tt, $ramdisk: tt) => {
$crate::paste! {
#[test]
fn [< $test_name _uefi_with_ramdisk >]() {
Expand All @@ -281,5 +283,5 @@ pub fn run_test_kernel_on_uefi_pxe(out_tftp_path: &Path) {
);
}
}
);
}
};
}

0 comments on commit 8564ab7

Please sign in to comment.