test with files are now sequentials

This commit is contained in:
Baptiste
2023-03-22 16:01:53 +01:00
parent b07c675986
commit 3be14e7f6a
5 changed files with 357 additions and 4 deletions

View File

@ -35,11 +35,12 @@ impl Disk {
write(true).
open(DISK_PATH);
let magic_to_write : [u8 ; 4] = [0xAB, 0xBA, 0xCD, 0xDC];
match result_open {
Err(e) => {
//On creer le fichier et on y écrit le magic number
let magic_to_write : [u8 ; 4] = [0xAB, 0xBA, 0xCD, 0xDC];
println!("Error opening file : {}", e);
disk_file = File::options().
@ -48,15 +49,14 @@ impl Disk {
create_new(true).
open(DISK_PATH).unwrap();
disk_file.write_at(&magic_to_write[..], 0);
disk_file.set_len(DISK_SIZE as u64);
disk_file.write_at(&magic_to_write[..], 0);
}
Ok(f) => {
disk_file = f;
let magic_to_write : [u8 ; 4] = [0xAB, 0xBA, 0xCD, 0xDC];
disk_file.write_at(&magic_to_write[..], 0);
disk_file.set_len(DISK_SIZE as u64);
disk_file.write_at(&magic_to_write[..], 0);
}
}
@ -175,11 +175,14 @@ pub fn stupid_fct(buf : &[u8]){
#[cfg(test)]
mod test {
use serial_test::serial;
use crate::Disk;
use super::stupid_fct;
#[test]
#[serial]
fn test_init_stupid_fct() {
let buffy: [u8 ; 6] = [1,2,3,4,5,6];
stupid_fct(&buffy);
@ -188,11 +191,13 @@ mod test {
}
#[test]
#[serial]
fn test_init_disk() {
let disk = Disk::init_disk();
}
#[test]
#[serial]
fn test_read_write_disk() {
let mut disk = Disk::init_disk();