From 56be9a5b274ea5391876e284a3c24d62f3583be9 Mon Sep 17 00:00:00 2001 From: bernie Date: Sun, 17 Aug 2008 16:32:47 +0000 Subject: [PATCH] battfs: Make it a bit more compliant with the test policy git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1653 38d2e660-2303-0410-9eaa-f027e97ec537 --- app/battfs/battfs_test.c | 59 ++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/app/battfs/battfs_test.c b/app/battfs/battfs_test.c index e7b529eb..8b13d597 100644 --- 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. * - * 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 - * - * \brief BattFs Test. */ -#include #include +#include +#include + #include #include #include @@ -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(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); @@ -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(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)); - 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)); - 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); - 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); - 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)); @@ -512,10 +512,7 @@ static void test12(BattFsSuper *disk) } - - - -int main(void) +int battfs_testRun(void) { BattFsSuper disk; @@ -536,7 +533,33 @@ int main(void) 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; +} + +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 -- 2.25.1