1 /*
2  * Copyright (c) 2023 Antmicro
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/ztest.h>
8 #include <zephyr/fs/fs.h>
9 
10 #include "utils.h"
11 
12 #ifdef CONFIG_DISK_DRIVER_RAM
13 	#define STORAGE_DEVICE "RAM"
14 #elif CONFIG_DISK_DRIVER_FLASH
15 	#define STORAGE_DEVICE "NAND"
16 #elif CONFIG_DISK_DRIVER_SDMMC
17 	#define STORAGE_DEVICE "SDMMC"
18 #endif
19 
20 /* All tests must use this structure to mount file system. After each test this structure is cleaned
21  * to allow for running next tests unaffected by previous one.
22  */
23 struct fs_mount_t testfs_mnt = {
24 	.type = FS_EXT2,
25 	.mnt_point = "/sml",
26 	.storage_dev = STORAGE_DEVICE,
27 	.flags = 0,
28 };
29 
before_test(void * f)30 static void before_test(void *f)
31 {
32 	ARG_UNUSED(f);
33 
34 	zassert_equal(wipe_partition((uintptr_t)testfs_mnt.storage_dev), TC_PASS,
35 			"Failed to clean partition");
36 	testfs_mnt.flags = 0;
37 }
38 
after_test(void * f)39 static void after_test(void *f)
40 {
41 	ARG_UNUSED(f);
42 
43 	/* Unmount file system */
44 	fs_unmount(&testfs_mnt);
45 }
46 
47 ZTEST_SUITE(ext2tests, NULL, NULL, before_test, after_test, NULL);
48