projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove obsolete header.
[bertos.git]
/
app
/
battfs
/
battfs_test.c
diff --git
a/app/battfs/battfs_test.c
b/app/battfs/battfs_test.c
index 05d40df896f3178755e23471ba355ffb51f0d732..8b13d597e2ace29faf4d789713e87719ed9dc642 100644
(file)
--- a/
app/battfs/battfs_test.c
+++ b/
app/battfs/battfs_test.c
@@
-26,20
+26,20
@@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*
- * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
- *
+ * Copyright 2007, 2008 Develer S.r.l. (http://www.develer.com/)
* -->
*
* -->
*
- * \
version $Id: demo.c 18242 2007-10-08 17:35:23Z marco $
+ * \
brief BattFS Test.
*
*
+ * \version $Id: demo.c 18242 2007-10-08 17:35:23Z marco $
* \author Francesco Sacchi <batt@develer.com>
* \author Francesco Sacchi <batt@develer.com>
- *
- * \brief BattFs Test.
*/
*/
-#include <cfg/debug.h>
#include <fs/battfs.h>
#include <fs/battfs.h>
+#include <cfg/debug.h>
+#include <cfg/test.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@
-99,7
+99,7
@@
static bool disk_close(struct BattFsSuper *d)
static void testCheck(BattFsSuper *disk, pgcnt_t *reference)
{
ASSERT(battfs_init(disk));
static void testCheck(BattFsSuper *disk, pgcnt_t *reference)
{
ASSERT(battfs_init(disk));
-
+
for (int i = 0; i < disk->page_count; i++)
{
if (disk->page_array[i] != reference[i])
for (int i = 0; i < disk->page_count; i++)
{
if (disk->page_array[i] != reference[i])
@@
-351,8
+351,8
@@
static void test9(BattFsSuper *disk)
static void test10(BattFsSuper *disk)
{
static void test10(BattFsSuper *disk)
{
-
KFileBattFs
fd1;
-
KFileBattFs
fd2;
+
BattFS
fd1;
+
BattFS
fd2;
kprintf("Test10: open file test, inode 0 and inode 4\n");
fp = fopen(test_filename, "w+");
kprintf("Test10: open file test, inode 0 and inode 4\n");
fp = fopen(test_filename, "w+");
@@
-404,7
+404,7
@@
static void test10(BattFsSuper *disk)
ASSERT(fd2.inode == INODE2);
ASSERT(fd2.start == &disk->page_array[2]);
ASSERT(fd2.disk == disk);
ASSERT(fd2.inode == INODE2);
ASSERT(fd2.start == &disk->page_array[2]);
ASSERT(fd2.disk == disk);
- ASSERT(LIST_HEAD(&disk->file_opened_list)->succ == &fd2.link);
+ ASSERT(LIST_HEAD(&disk->file_opened_list)->succ == &fd2.link);
ASSERT(kfile_close(&fd1.fd) == 0);
ASSERT(kfile_close(&fd2.fd) == 0);
ASSERT(kfile_close(&fd1.fd) == 0);
ASSERT(kfile_close(&fd2.fd) == 0);
@@
-416,7
+416,7
@@
static void test10(BattFsSuper *disk)
static void test11(BattFsSuper *disk)
{
static void test11(BattFsSuper *disk)
{
-
KFileBattFs
fd1;
+
BattFS
fd1;
uint8_t buf[16];
kprintf("Test11: read file test\n");
uint8_t buf[16];
kprintf("Test11: read file test\n");
@@
-454,7
+454,7
@@
static void test11(BattFsSuper *disk)
static void test12(BattFsSuper *disk)
{
static void test12(BattFsSuper *disk)
{
-
KFileBattFs
fd1;
+
BattFS
fd1;
kprintf("Test12: read file test across page boundary and seek test\n");
kprintf("Test12: read file test across page boundary and seek test\n");
@@
-480,30
+480,30
@@
static void test12(BattFsSuper *disk)
ASSERT(battfs_fileopen(disk, &fd1, INODE, MODE));
ASSERT(kfile_read(&fd1.fd, buf, sizeof(buf)) == sizeof(buf));
ASSERT(battfs_fileopen(disk, &fd1, INODE, MODE));
ASSERT(kfile_read(&fd1.fd, buf, sizeof(buf)) == sizeof(buf));
- ASSERT(fd1.fd.seek_pos == sizeof(buf));
+ ASSERT(fd1.fd.seek_pos ==
(kfile_off_t)
sizeof(buf));
for (size_t i = 0; i < sizeof(buf); i++)
ASSERT(buf[i] == 0);
ASSERT(kfile_read(&fd1.fd, buf, sizeof(buf)) == sizeof(buf));
for (size_t i = 0; i < sizeof(buf); i++)
ASSERT(buf[i] == 0);
ASSERT(kfile_read(&fd1.fd, buf, sizeof(buf)) == sizeof(buf));
- ASSERT(fd1.fd.seek_pos == sizeof(buf) * 2);
+ ASSERT(fd1.fd.seek_pos ==
(kfile_off_t)
sizeof(buf) * 2);
for (size_t i = 0; i < sizeof(buf); i++)
ASSERT(buf[i] == 0);
ASSERT(kfile_read(&fd1.fd, buf, sizeof(buf)) == sizeof(buf));
for (size_t i = 0; i < sizeof(buf); i++)
ASSERT(buf[i] == 0);
ASSERT(kfile_read(&fd1.fd, buf, sizeof(buf)) == sizeof(buf));
- ASSERT(fd1.fd.seek_pos == sizeof(buf) * 3);
+ ASSERT(fd1.fd.seek_pos ==
(kfile_off_t)
sizeof(buf) * 3);
for (size_t i = 0; i < sizeof(buf); i++)
ASSERT(buf[i] == 0);
ASSERT(kfile_read(&fd1.fd, buf, sizeof(buf)) == 86);
for (size_t i = 0; i < sizeof(buf); i++)
ASSERT(buf[i] == 0);
ASSERT(kfile_read(&fd1.fd, buf, sizeof(buf)) == 86);
- ASSERT(fd1.fd.seek_pos == fd1.fd.size);
+ ASSERT(fd1.fd.seek_pos ==
(kfile_off_t)
fd1.fd.size);
for (size_t i = 0; i < 86; i++)
ASSERT(buf[i] == 0);
ASSERT(kfile_seek(&fd1.fd, 0, KSM_SEEK_SET) == 0);
ASSERT(fd1.fd.seek_pos == 0);
for (size_t i = 0; i < 86; i++)
ASSERT(buf[i] == 0);
ASSERT(kfile_seek(&fd1.fd, 0, KSM_SEEK_SET) == 0);
ASSERT(fd1.fd.seek_pos == 0);
- ASSERT(kfile_seek(&fd1.fd, 0, KSM_SEEK_END) == fd1.fd.size);
- ASSERT(fd1.fd.seek_pos = fd1.fd.size);
+ ASSERT(kfile_seek(&fd1.fd, 0, KSM_SEEK_END) ==
(kfile_off_t)
fd1.fd.size);
+ ASSERT(fd1.fd.seek_pos =
(kfile_off_t)
fd1.fd.size);
ASSERT(kfile_close(&fd1.fd) == 0);
ASSERT(battfs_close(disk));
ASSERT(kfile_close(&fd1.fd) == 0);
ASSERT(battfs_close(disk));
@@
-512,10
+512,7
@@
static void test12(BattFsSuper *disk)
}
}
-
-
-
-int main(void)
+int battfs_testRun(void)
{
BattFsSuper disk;
{
BattFsSuper disk;
@@
-536,7
+533,33
@@
int main(void)
test10(&disk);
test11(&disk);
test12(&disk);
test10(&disk);
test11(&disk);
test12(&disk);
- kprintf("All test passed!\n");
+ kprintf("All tests passed!\n");
+
+ return 0;
+}
+
+#ifdef _TEST
+
+int battfs_testSetup(void)
+{
+ return 0;
+}
+int battfs_testTearDown(void)
+{
return 0;
}
return 0;
}
+
+TEST_MAIN(battfs)
+
+#include "fs/battfs.c"
+#include "drv/kdebug.c"
+#include "mware/formatwr.c"
+#include "mware/hex.c"
+
+#else
+int main(void)
+{
+ return battfs_testRun();
+}
+#endif // _TEST