forked from M-Labs/rust-fatfs
Add new test images and script for generating them - tests fail.
This commit is contained in:
parent
b535b460f9
commit
8df86d24ef
@ -7,7 +7,7 @@ use std::str;
|
|||||||
use rustfat::FatFileSystem;
|
use rustfat::FatFileSystem;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let file = File::open("resources/floppy.img").unwrap();
|
let file = File::open("resources/fat12.img").unwrap();
|
||||||
let buf_rdr = BufReader::new(file);
|
let buf_rdr = BufReader::new(file);
|
||||||
let mut fs = FatFileSystem::new(Box::new(buf_rdr)).unwrap();
|
let mut fs = FatFileSystem::new(Box::new(buf_rdr)).unwrap();
|
||||||
let mut root_dir = fs.root_dir();
|
let mut root_dir = fs.root_dir();
|
||||||
|
BIN
resources/fat12.img
Normal file
BIN
resources/fat12.img
Normal file
Binary file not shown.
BIN
resources/fat16.img
Normal file
BIN
resources/fat16.img
Normal file
Binary file not shown.
BIN
resources/fat32.img
Normal file
BIN
resources/fat32.img
Normal file
Binary file not shown.
Binary file not shown.
24
scripts/create-test-img.sh
Executable file
24
scripts/create-test-img.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
OUT_DIR=../resources
|
||||||
|
set -e
|
||||||
|
|
||||||
|
create_test_img() {
|
||||||
|
local name=$1
|
||||||
|
local blkcount=$2
|
||||||
|
local fatSize=$3
|
||||||
|
dd if=/dev/zero of="$name" bs=1024 count=$blkcount
|
||||||
|
mkfs.vfat -s 1 -F $fatSize "$name"
|
||||||
|
mkdir -p mnt
|
||||||
|
sudo mount -o loop "$name" mnt -o rw,uid=$USER,gid=$USER
|
||||||
|
for i in {1..1000}; do
|
||||||
|
echo "Rust is cool!" >>"mnt/long.txt"
|
||||||
|
done
|
||||||
|
echo "Rust is cool!" >>"mnt/short.txt"
|
||||||
|
mkdir -p mnt/very/long/path
|
||||||
|
echo "Rust is cool!" >>"mnt/very/long/path/test.txt"
|
||||||
|
sudo umount mnt
|
||||||
|
}
|
||||||
|
|
||||||
|
create_test_img "$OUT_DIR/fat12.img" 1000 12
|
||||||
|
create_test_img "$OUT_DIR/fat16.img" 2500 16
|
||||||
|
create_test_img "$OUT_DIR/fat32.img" 34000 32
|
@ -6,14 +6,29 @@ use std::str;
|
|||||||
|
|
||||||
use rustfat::FatFileSystem;
|
use rustfat::FatFileSystem;
|
||||||
|
|
||||||
#[test]
|
fn test_img(name: &str) {
|
||||||
fn fat12_test() {
|
let file = File::open(name).unwrap();
|
||||||
let file = File::open("resources/floppy.img").unwrap();
|
|
||||||
let buf_rdr = BufReader::new(file);
|
let buf_rdr = BufReader::new(file);
|
||||||
let mut fs = FatFileSystem::new(Box::new(buf_rdr)).unwrap();
|
let mut fs = FatFileSystem::new(Box::new(buf_rdr)).unwrap();
|
||||||
let mut root_dir = fs.root_dir();
|
let mut root_dir = fs.root_dir();
|
||||||
let entries = root_dir.list().unwrap();
|
let entries = root_dir.list().unwrap();
|
||||||
assert_eq!(entries.len(), 2);
|
assert_eq!(entries.len(), 3);
|
||||||
assert_eq!(entries[0].get_name(), "RAFOS");
|
assert_eq!(entries[0].get_name(), "LONG.TXT");
|
||||||
assert_eq!(entries[1].get_name(), "GRUB");
|
assert_eq!(entries[1].get_name(), "SHORT.TXT");
|
||||||
|
assert_eq!(entries[2].get_name(), "VERY");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn fat12() {
|
||||||
|
test_img("resources/fat12.img");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn fat16() {
|
||||||
|
test_img("resources/fat16.img");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn fat32() {
|
||||||
|
test_img("resources/fat32.img");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user