From: batt Date: Sat, 20 Sep 2008 13:23:14 +0000 (+0000) Subject: Add another write test. X-Git-Tag: 2.0.0~105 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=a73a7feb1d41ff1ec0b59c50102199c55013f464;p=bertos.git Add another write test. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1829 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/fs/battfs_test.c b/bertos/fs/battfs_test.c index e74d135e..863f3932 100644 --- a/bertos/fs/battfs_test.c +++ b/bertos/fs/battfs_test.c @@ -662,6 +662,31 @@ static void test14(BattFsSuper *disk) kprintf("Test14: passed\n"); } +static void test15(BattFsSuper *disk) +{ + kprintf("Test15: file creation on new disk\n"); + + FILE *fpt = fopen(test_filename, "w+"); + + for (int i = 0; i < FILE_SIZE; i++) + fputc(0xff, fpt); + fclose(fpt); + + BattFs fd1; + unsigned int INODE = 0; + unsigned int MODE = BATTFS_CREATE; + + ASSERT(battfs_init(disk)); + ASSERT(battfs_fileopen(disk, &fd1, INODE, MODE)); + for (int i = 0; i < FILE_SIZE / 2; i++) + ASSERT(kfile_putc(i, &fd1.fd) != EOF); + + ASSERT(kfile_close(&fd1.fd) == 0); + ASSERT(battfs_close(disk)); + + kprintf("Test15: passed\n"); +} + int battfs_testRun(void) { BattFsSuper disk; @@ -688,6 +713,7 @@ int battfs_testRun(void) test12(&disk); test13(&disk); test14(&disk); + test15(&disk); kprintf("All tests passed!\n"); return 0;