You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/04/21 03:00:31 UTC
[2/2] incubator-mynewt-core git commit: nffs - Add 1000-append unit
test.
nffs - Add 1000-append unit test.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/4d0a3870
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/4d0a3870
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/4d0a3870
Branch: refs/heads/develop
Commit: 4d0a38707bdeeb2061b3089d627fc2cee13f1f6c
Parents: ff20497
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Apr 20 17:59:15 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Apr 20 17:59:15 2016 -0700
----------------------------------------------------------------------
fs/nffs/src/test/arch/sim/nffs_test.c | 83 +++++++++++++++++++++++++++++-
1 file changed, 81 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4d0a3870/fs/nffs/src/test/arch/sim/nffs_test.c
----------------------------------------------------------------------
diff --git a/fs/nffs/src/test/arch/sim/nffs_test.c b/fs/nffs/src/test/arch/sim/nffs_test.c
index 8b3b03a..8078ea0 100644
--- a/fs/nffs/src/test/arch/sim/nffs_test.c
+++ b/fs/nffs/src/test/arch/sim/nffs_test.c
@@ -536,6 +536,7 @@ nffs_test_assert_system_once(const struct nffs_test_file_desc *root_dir)
{
struct nffs_inode_entry *inode_entry;
struct nffs_hash_entry *entry;
+ struct nffs_hash_entry *next;
int i;
nffs_test_num_touched_entries = 0;
@@ -543,7 +544,7 @@ nffs_test_assert_system_once(const struct nffs_test_file_desc *root_dir)
nffs_test_assert_branch_touched(nffs_root_dir);
/* Ensure no orphaned inodes or blocks. */
- NFFS_HASH_FOREACH(entry, i) {
+ NFFS_HASH_FOREACH(entry, i, next) {
TEST_ASSERT(entry->nhe_flash_loc != NFFS_FLASH_LOC_NONE);
if (nffs_hash_id_is_inode(entry->nhe_id)) {
inode_entry = (void *)entry;
@@ -931,8 +932,10 @@ TEST_CASE(nffs_test_truncate)
TEST_CASE(nffs_test_append)
{
struct fs_file *file;
+ uint32_t len;
+ char c;
int rc;
-
+ int i;
rc = nffs_format(nffs_area_descs);
TEST_ASSERT(rc == 0);
@@ -978,6 +981,48 @@ TEST_CASE(nffs_test_append)
nffs_test_util_assert_contents("/myfile.txt",
"abcdefghijklmnopqrstuvwx", 24);
+ rc = fs_mkdir("/mydir");
+ TEST_ASSERT_FATAL(rc == 0);
+ rc = fs_open("/mydir/gaga.txt", FS_ACCESS_WRITE | FS_ACCESS_APPEND, &file);
+ TEST_ASSERT_FATAL(rc == 0);
+
+ /*** Repeated appends to a large file. */
+ for (i = 0; i < 1000; i++) {
+ rc = fs_filelen(file, &len);
+ TEST_ASSERT_FATAL(rc == 0);
+ TEST_ASSERT(len == i);
+
+ c = '0' + i % 10;
+ rc = fs_write(file, &c, 1);
+ TEST_ASSERT_FATAL(rc == 0);
+ }
+
+ rc = fs_close(file);
+ TEST_ASSERT(rc == 0);
+
+ nffs_test_util_assert_contents("/mydir/gaga.txt",
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789",
+ 1000);
+
struct nffs_test_file_desc *expected_system =
(struct nffs_test_file_desc[]) { {
.filename = "",
@@ -987,6 +1032,37 @@ TEST_CASE(nffs_test_append)
.contents = "abcdefghijklmnopqrstuvwx",
.contents_len = 24,
}, {
+ .filename = "mydir",
+ .is_dir = 1,
+ .children = (struct nffs_test_file_desc[]) { {
+ .filename = "gaga.txt",
+ .contents =
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ "01234567890123456789012345678901234567890123456789"
+ ,
+ .contents_len = 1000,
+ }, {
+ .filename = NULL,
+ } },
+ }, {
.filename = NULL,
} },
} };
@@ -2491,6 +2567,9 @@ TEST_SUITE(gen_32_1024)
int
nffs_test_all(void)
{
+ nffs_config.nc_num_inodes = 1024 * 8;
+ nffs_config.nc_num_blocks = 1024 * 20;
+
gen_1_1();
gen_4_32();
gen_32_1024();