projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix subtle bug in crc table declaration; substitute extern_c macros.
[bertos.git]
/
bertos
/
kern
/
kfile_test.c
diff --git
a/bertos/kern/kfile_test.c
b/bertos/kern/kfile_test.c
index 21fc3d3bf73255aa8f4537c97dc67a50f5387b6b..52afa98a60ab0fd948c358bfec34bc32f2c0b8b9 100644
(file)
--- a/
bertos/kern/kfile_test.c
+++ b/
bertos/kern/kfile_test.c
@@
-58,8
+58,11
@@
MOD_DEFINE(kfile_test);
MOD_DEFINE(kfile_test);
+// Size of the "virtual" disk that
+// we want to test.
#define BUF_TEST_LEN 3209
#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];
typedef uint8_t fake_t;
fake_t test_buf[BUF_TEST_LEN];
fake_t test_buf_save[BUF_TEST_LEN];
@@
-67,6
+70,9
@@
fake_t test_disk[BUF_TEST_LEN];
KFile fd;
KFile fd;
+/*
+ * Beckend to use kfile structure on pc.
+ */
static int fake_close(KFile *fd)
{
(void)fd;
static int fake_close(KFile *fd)
{
(void)fd;
@@
-90,7
+96,7
@@
static size_t fake_read(KFile *fd, void *buf, size_t size)
static size_t fake_write(KFile *fd, const void *buf, size_t size)
{
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);
size_t wr_len;
wr_len = MIN((kfile_off_t)size, fd->size - fd->seek_pos);
@@
-103,14
+109,14
@@
static size_t fake_write(KFile *fd, const void *buf, size_t size)
return wr_len;
}
return wr_len;
}
-int fake_flush(KFile *fd)
+
static
int fake_flush(KFile *fd)
{
(void)fd;
return 0;
}
{
(void)fd;
return 0;
}
-void fake_kfileInit(void)
+
static
void fake_kfileInit(void)
{
// Setup data flash programming functions.
fd.reopen = kfile_genericReopen;
{
// Setup data flash programming functions.
fd.reopen = kfile_genericReopen;
@@
-125,14
+131,16
@@
void fake_kfileInit(void)
}
}
+/*
+ * Help function to init disk and the buffers.
+ */
static void init_testBuf(void)
{
static void init_testBuf(void)
{
- #include <stdlib.h>
kprintf("Init fake buffer..\n");
for (int i = 0; i < BUF_TEST_LEN; i++)
{
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");
kprintf("%d ", test_disk[i]);
}
kprintf("\nend\n");
@@
-352,6
+360,7
@@
int kfile_testSetup(void)
MOD_INIT(kfile_test);
LOG_INFO("Mod init..ok\n");
MOD_INIT(kfile_test);
LOG_INFO("Mod init..ok\n");
+ // Init our backend and the buffers
fake_kfileInit();
init_testBuf();
fake_kfileInit();
init_testBuf();
@@
-373,3
+382,4
@@
int kfile_testTearDown(void)
}
TEST_MAIN(kfile);
}
TEST_MAIN(kfile);
+