Fixed FAT32 tests

Git workflow changed to run on any push
Mount in utf8 so copies files unicode filenames correctly
Renamed large_file2 to large_file
This commit is contained in:
DrDeano 2020-12-27 13:11:38 +00:00
parent 5e4d95c6f9
commit f87f66a37f
No known key found for this signature in database
GPG key ID: 96188600582B9ED7
5 changed files with 20 additions and 13 deletions

View file

@ -2,9 +2,8 @@ name: CI
on:
push:
branches: "*"
pull_request:
branches: "*"
branches: '*'
jobs:
test:

View file

@ -3,7 +3,7 @@
IMAGE_PATH_DIR=$1
mkdir test/fat32/mnt
sudo mount $IMAGE_PATH_DIR test/fat32/mnt/
sudo cp test/fat32/test_files/* test/fat32/mnt/
sudo mount -o utf8=true $IMAGE_PATH_DIR test/fat32/mnt/
sudo cp -r test/fat32/test_files/. test/fat32/mnt/
sudo umount test/fat32/mnt/
rm -rf test/fat32/mnt

View file

@ -2090,12 +2090,12 @@ test "Fat32FS.init FATConfig expected" {
.fsinfo_sector = 1,
.backup_boot_sector = 6,
.has_fs_info = true,
.number_free_clusters = 65491,
.next_free_cluster = 35,
.number_free_clusters = 65490,
.next_free_cluster = 36,
.cluster_end_marker = 0x0FFFFFFF,
};
expectEqual(expected, test_fs.fat_config);
expectEqual(test_fs.fat_config, expected);
}
test "Fat32FS.init FATConfig mix FSInfo" {
@ -2133,7 +2133,7 @@ test "Fat32FS.init FATConfig mix FSInfo" {
.cluster_end_marker = 0x0FFFFFFF,
};
expectEqual(expected, test_fs.fat_config);
expectEqual(test_fs.fat_config, expected);
test_file_buf[48] = 0x01;
}
@ -2162,7 +2162,7 @@ test "Fat32FS.init FATConfig mix FSInfo" {
.cluster_end_marker = 0x0FFFFFFF,
};
expectEqual(expected, test_fs.fat_config);
expectEqual(test_fs.fat_config, expected);
test_file_buf[512] = 0x52;
}
@ -2190,11 +2190,11 @@ test "Fat32FS.init FATConfig mix FSInfo" {
.backup_boot_sector = 6,
.has_fs_info = true,
.number_free_clusters = 0xFFFFFFFF,
.next_free_cluster = 35,
.next_free_cluster = 36,
.cluster_end_marker = 0x0FFFFFFF,
};
expectEqual(expected, test_fs.fat_config);
expectEqual(test_fs.fat_config, expected);
}
}
@ -3879,14 +3879,14 @@ test "Fat32FS.read - large" {
vfs.setRoot(test_fs.root_node.node);
const test_node = try vfs.openFile("/large_file2.txt", .NO_CREATION);
const test_node = try vfs.openFile("/large_file.txt", .NO_CREATION);
defer test_node.close();
var buff = [_]u8{0xAA} ** 8450;
const read = try test_node.read(buff[0..]);
expectEqual(read, 8450);
const large_file_content = @embedFile("../../../test/fat32/test_files/large_file2.txt");
const large_file_content = @embedFile("../../../test/fat32/test_files/large_file.txt");
expectEqualSlices(u8, buff[0..], large_file_content[0..]);
}
@ -3905,6 +3905,10 @@ test "Fat32FS.read - all test files" {
var it = test_files.iterate();
while (try it.next()) |file| {
// Have tested the large file
if (std.mem.eql(u8, file.name, "large_file.txt")) {
continue;
}
// Need to add a '/' at the beginning
var file_name = try std.testing.allocator.alloc(u8, file.name.len + 1);
defer std.testing.allocator.free(file_name);

View file

@ -218,3 +218,7 @@ fn initStage2() noreturn {
// Can't return for now, later this can return maybe
arch.spinWait();
}
test "" {
_ = @import("filesystem/fat32.zig");
}