Added tests for the file system

This commit is contained in:
Sparchatus 2022-05-31 12:20:40 +00:00
parent 046d7269da
commit e0fecab3ed
5 changed files with 26 additions and 0 deletions

8
include/test_fs.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef __TEST_FS_H
#define __TEST_FS_H
#include <aos/aos.h>
void do_test_fs(void);
#endif /* __TEST_SPAWN_H */

View File

@ -1326,6 +1326,11 @@ static errval_t _fat32_rmdir(struct fat32 *fat32, const char *path) {
return FS_ERR_NOTDIR;
}
// we don't allow deleting the root directory
if (path_resolve_result.directory_entry_ref.sector_number == UINT32_MAX || path_resolve_result.directory_entry_ref.index_in_sector == UINT32_MAX) {
return FS_ERR_NOTEMPTY;
}
// we refuse to delete non-empty directories
err = fat32_check_directory_empty(fat32, &path_resolve_result.directory_entry);
if (err_is_fail(err)) return err;

View File

@ -21,6 +21,7 @@
"test_paging.c",
"test_spawn.c",
"test_ipc.c",
"test_fs.c",
"test_threads.c",
"test_stackoverflow.c"
],

View File

@ -13,6 +13,7 @@
#include <test_paging.h>
#include <test_spawn.h>
#include <test_ipc.h>
#include <test_fs.h>
#include <test_threads.h>
#include <test_stackoverflow.h>
@ -52,5 +53,6 @@ void
grading_test_late(void) {
if (my_core_id == 0) {
do_test_spawn();
do_test_fs();
}
}

10
lib/grading/test_fs.c Normal file
View File

@ -0,0 +1,10 @@
#include <test_helper.h>
#include <test_fs.h>
#include <spawn/spawn.h>
void do_test_fs(void) {
// spawn the filereader process that contains all the tests
struct spawninfo *si = malloc(sizeof(struct spawninfo));
domainid_t *pid = malloc(sizeof(domainid_t));
CHECK_ERR(spawn_load_by_name("filereader", si, pid));
}