MOD_DEFINE(kfile_test);
+// Size of the "virtual" disk that
+// we want to test.
#define BUF_TEST_LEN 3209
+// Buffer for test
typedef uint8_t fake_t;
fake_t test_buf[BUF_TEST_LEN];
fake_t test_buf_save[BUF_TEST_LEN];
KFile fd;
+/*
+ * Beckend to use kfile structure on pc.
+ */
static int fake_close(KFile *fd)
{
(void)fd;
static size_t fake_write(KFile *fd, const void *buf, size_t size)
{
- fake_t *src = (fake_t *)buf;
+ const fake_t *src = (const fake_t *)buf;
size_t wr_len;
wr_len = MIN((kfile_off_t)size, fd->size - fd->seek_pos);
return wr_len;
}
-int fake_flush(KFile *fd)
+static int fake_flush(KFile *fd)
{
(void)fd;
return 0;
}
-void fake_kfileInit(void)
+static void fake_kfileInit(void)
{
// Setup data flash programming functions.
fd.reopen = kfile_genericReopen;
}
+/*
+ * Help function to init disk and the buffers.
+ */
static void init_testBuf(void)
{
- #include <stdlib.h>
kprintf("Init fake buffer..\n");
for (int i = 0; i < BUF_TEST_LEN; i++)
{
- test_disk[i] = random();
+ test_disk[i] = i;
kprintf("%d ", test_disk[i]);
}
kprintf("\nend\n");
MOD_INIT(kfile_test);
LOG_INFO("Mod init..ok\n");
+ // Init our backend and the buffers
fake_kfileInit();
init_testBuf();
}
TEST_MAIN(kfile);
+