mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Fix race condition in test_println_output test
This commit is contained in:
@@ -196,14 +196,20 @@ fn test_println_many() {
|
|||||||
|
|
||||||
#[test_case]
|
#[test_case]
|
||||||
fn test_println_output() {
|
fn test_println_output() {
|
||||||
|
use core::fmt::Write;
|
||||||
|
use x86_64::instructions::interrupts;
|
||||||
|
|
||||||
serial_print!("test_println_output... ");
|
serial_print!("test_println_output... ");
|
||||||
|
|
||||||
let s = "Some test string that fits on a single line";
|
let s = "Some test string that fits on a single line";
|
||||||
println!("{}", s);
|
interrupts::without_interrupts(|| {
|
||||||
for (i, c) in s.chars().enumerate() {
|
let mut writer = WRITER.lock();
|
||||||
let screen_char = WRITER.lock().buffer.chars[BUFFER_HEIGHT - 2][i].read();
|
writeln!(writer, "\n{}", s).expect("writeln failed");
|
||||||
assert_eq!(char::from(screen_char.ascii_character), c);
|
for (i, c) in s.chars().enumerate() {
|
||||||
}
|
let screen_char = writer.buffer.chars[BUFFER_HEIGHT - 2][i].read();
|
||||||
|
assert_eq!(char::from(screen_char.ascii_character), c);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
serial_println!("[ok]");
|
serial_println!("[ok]");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user