static void testCheck(BattFsSuper *disk, pgcnt_t *reference)
{
ASSERT(battfs_init(disk));
+ ASSERT(battfs_fsck(disk));
for (int i = 0; i < disk->page_count; i++)
{
fclose(fp);
ASSERT(battfs_init(disk));
+ ASSERT(battfs_fsck(disk));
ASSERT(!battfs_fileExists(disk, INEXISTENT_INODE));
ASSERT(battfs_fileExists(disk, INODE));
fclose(fp);
ASSERT(battfs_init(disk));
+ ASSERT(battfs_fsck(disk));
ASSERT(battfs_fileopen(disk, &fd1, INODE, MODE));
ASSERT(kfile_read(&fd1.fd, buf, sizeof(buf)) == sizeof(buf));
ASSERT(fd1.fd.seek_pos == sizeof(buf));
fclose(fp);
ASSERT(battfs_init(disk));
+ ASSERT(battfs_fsck(disk));
ASSERT(battfs_fileopen(disk, &fd1, INODE, MODE));
ASSERT(kfile_read(&fd1.fd, buf, sizeof(buf)) == sizeof(buf));
buf[i] = i;
ASSERT(battfs_init(disk));
+ ASSERT(battfs_fsck(disk));
ASSERT(battfs_fileopen(disk, &fd1, INODE, MODE));
ASSERT(kfile_write(&fd1.fd, buf, sizeof(buf)) == sizeof(buf));
ASSERT(fd1.fd.seek_pos == sizeof(buf));
fclose(fp);
ASSERT(battfs_init(disk));
+ ASSERT(battfs_fsck(disk));
ASSERT(battfs_fileopen(disk, &fd1, INODE, MODE));
uint8_t val = 0;
unsigned int MODE = BATTFS_CREATE;
ASSERT(battfs_init(disk));
+ ASSERT(battfs_fsck(disk));
ASSERT(battfs_fileopen(disk, &fd1, INODE, MODE));
for (int i = 0; i < FILE_SIZE / 2; i++)
ASSERT(kfile_putc(i, &fd1.fd) != EOF);
ASSERT(battfs_close(disk));
ASSERT(battfs_init(disk));
+ ASSERT(battfs_fsck(disk));
ASSERT(battfs_fileopen(disk, &fd1, INODE, 0));
ASSERT(fd1.fd.size == FILE_SIZE / 2);
ASSERT(fd1.fd.seek_pos == 0);
uint8_t buf[1000];
ASSERT(battfs_init(disk));
+ ASSERT(battfs_fsck(disk));
ASSERT(battfs_fileopen(disk, &fd1, INODE, MODE));
int j;
ASSERT(battfs_close(disk));
ASSERT(battfs_init(disk));
+ ASSERT(battfs_fsck(disk));
ASSERT(disk->free_bytes == disk->disk_size - sizeof(buf));
ASSERT(battfs_fileopen(disk, &fd1, INODE, 0));
ASSERT(fd1.fd.size == sizeof(buf));
uint8_t buf[1000];
ASSERT(battfs_init(disk));
+ ASSERT(battfs_fsck(disk));
ASSERT(battfs_fileopen(disk, &fd1, INODE1, MODE));
ASSERT(battfs_fileopen(disk, &fd2, INODE2, MODE));
for (unsigned i = 0; i < sizeof(buf); i++)
fclose(fp);
ASSERT(battfs_init(disk));
+ ASSERT(battfs_fsck(disk));
ASSERT(battfs_fileopen(disk, &fd1, INODE, MODE));
ASSERT(kfile_seek(&fd1.fd, fd1.fd.size + 10, SEEK_SET) == fd1.fd.size + 10);
ASSERT(fd1.fd.seek_pos == fd1.fd.size + 10);
buf[i] = i;
ASSERT(battfs_init(disk));
+ ASSERT(battfs_fsck(disk));
disk_size_t prev_free = disk->free_bytes;
ASSERT(battfs_fileopen(disk, &fd1, INODE, MODE));
ASSERT(fd1.fd.size == 0);