Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
3ae87f4
Add littlefs-disk-img-viewer to README
tniessen Jun 21, 2021
56a9903
Created new test_runner.c and test_.py
geky Apr 16, 2022
d683f1c
Reintroduced test-defines into the new test_runner
geky Apr 18, 2022
4b0aa62
Some more minor improvements to the test_runner
geky Apr 18, 2022
9281ce2
More test_runner progress
geky Apr 18, 2022
92a600a
Added trace and persist flags to test_runner
geky Apr 19, 2022
6443693
Putting together rewritten test.py script
geky Apr 24, 2022
5812d2b
Reworked how multi-layered defines work in the test-runner
geky Apr 25, 2022
5ee4b05
Misc test-runner improvements
geky Apr 25, 2022
4962829
Continued progress toward feature parity with new test-runner
geky May 1, 2022
be0e6ad
More progress toward test-runner feature parity
geky May 2, 2022
5a572ce
Reworked how test defines are implemented to support recursion
geky May 8, 2022
d679fbb
In ./scripts/test.py, readded external commands, tweaked subprocesses
geky May 8, 2022
0781f50
Ported tests to new framework
geky May 14, 2022
4a42326
Moved test suites into custom linker section
geky May 14, 2022
1616115
Fix test.py hang on ctrl-C, cleanup TODOs
geky May 15, 2022
2b11f2b
Tweaked generation of .cgi files, error code for recursion in stack.py
geky May 15, 2022
4a7e94f
Reimplemented coverage.py, using only gcov and with line+branch coverage
geky May 16, 2022
5b0a6d4
Reworked scripts to move field details into classes
geky May 21, 2022
46cc6d4
Added support for annotated source in coverage.py
geky May 23, 2022
d9333ec
Add "chamelon" to the related projects section.
yomimono Aug 2, 2022
92eee8e
Removed some prefixes from Makefile variables where not necessary
geky Aug 15, 2022
b08463f
Reworked scripts/pretty_asserts.py a bit
geky Aug 16, 2022
a368d3a
Moved emulation of erase values up into lfs_testbd
geky Aug 17, 2022
01b11da
Added a simple test that the block device works
geky Aug 17, 2022
61455b6
Added back heuristic-based power-loss testing
geky Aug 19, 2022
4689678
Added --color to test.py, fixed some terminal-clobbering issues
geky Aug 22, 2022
3f4f859
Readded support for mirror writes to a file in testbd
geky Aug 23, 2022
552336e
Added optional read/prog/erase delays to testbd
geky Aug 23, 2022
5279fc6
Implemented exhaustive testing of n nested powerlosses
geky Aug 25, 2022
c9a6e3a
Added tailpipe.py and improved redirecting test trace/log output over…
geky Aug 27, 2022
91200e6
Added tracebd.py, a script for rendering block device operations
geky Sep 2, 2022
a208d84
Reworked test defines a bit to use one common array layout
geky Sep 6, 2022
c7f7094
Several tweaks to test.py and test runner
geky Sep 9, 2022
5a2ff17
Changed test identifier separator # -> :
geky Sep 9, 2022
bfbe44e
Dropped permutation number for full leb16-encoded defines
geky Sep 10, 2022
03c1a4e
Added permutations and ranges to test defines
geky Sep 11, 2022
23fba40
Added option for updating a CSV file with test results
geky Sep 12, 2022
acdea18
Made summary.py more powerful, dropped -m from size scripts
geky Sep 14, 2022
1fcd82d
Made test.py output parsable by summary.py
geky Sep 16, 2022
11d6d12
Dropped namespacing of test cases
geky Sep 17, 2022
20ec0be
Cleaned up a number of small tweaks in the scripts
geky Sep 19, 2022
4fe0738
Added bench.py and bench_runner.c for benchmarking
geky Sep 20, 2022
9a0e3be
Added a quick trie to avoid running redundant test/bench permutations
geky Sep 20, 2022
7591d9c
Added plot.py for in-terminal plotting
geky Sep 22, 2022
fb58148
Consistent handling of by/field arguments for plot.py and summary.py
geky Sep 23, 2022
42d889e
Reworked/simplified tracebd.py a bit
geky Sep 25, 2022
9507e62
Several tweaks to script flags
geky Sep 27, 2022
a2fb708
Added stddev/gmean/gstddev to summary.py
geky Sep 27, 2022
274222b
Added some automatic sizing for field-names in scripts/runners
geky Sep 27, 2022
296c5af
Renamed bench_read/prog/erased -> bench_readed/proged/erased
geky Sep 27, 2022
ca66993
Tweaked scripts to share more code, added coverage calls/hits
geky Oct 2, 2022
490e1c4
Added perf.py a wrapper around Linux's perf tool for perf sampling
geky Oct 2, 2022
df283ae
Added recursive results to perf.py
geky Oct 9, 2022
29cbafe
Renamed coverage.py -> cov.py
geky Oct 9, 2022
3a33c37
Added perfbd.py and block device performance sampling in bench-runner
geky Oct 13, 2022
b2a2cc9
Added teepipe.py and watch.py
geky Oct 16, 2022
559e174
Added plotmpl.py for creating svg/png plots with matplotlib
geky Oct 20, 2022
6fce9e5
Changed plotmpl.py/plot.py to not treat missing values as discontinui…
geky Nov 10, 2022
1a07c2c
A number of small script fixes/tweaks from usage
geky Nov 11, 2022
e35e078
Renamed prefix.py -> changeprefix.py and updated to use argparse
geky Nov 16, 2022
bcc88f5
A couple Makefile-related tweaks
geky Nov 17, 2022
f734941
Changed default build target lfs.a -> liblfs.a
geky Nov 17, 2022
6c18b4d
Added a simple help rule to the Makefile
geky Nov 17, 2022
f89d758
Fixed test out-of-space issues with powerloss testing
geky Nov 28, 2022
eba5553
Fixed hidden orphans by separating deorphan search into two passes
geky Nov 28, 2022
0b11ce0
Fixed incorrect calculation of extra space needed in mdir blocks
geky Nov 19, 2022
387cf6f
Fixed a couple corner cases in scripts when fields are empty
geky Nov 19, 2022
65923cd
Adopted script changes in GitHub Actions
geky Nov 17, 2022
397aa27
Removed unnecessarily heavy RAM usage from logs in bench/test.py
geky Nov 23, 2022
a659c02
Added a bot-generated PR-comment with a simple status table
geky Nov 23, 2022
4a20934
Fixed bench workflow + changeprefix issue in prefix releases
geky Nov 27, 2022
0c781dd
Merge remote-tracking branch 'origin/master' into test-and-bench-runners
geky Dec 7, 2022
9990342
Fixed Clang testing in CI, removed override vars in Makefile
geky Nov 29, 2022
c4b3e9d
A couple of script changes after CI integration
geky Nov 29, 2022
9b687dd
Added make benchmarks/testmarks rules
geky Nov 29, 2022
cda2f6f
Changed test_runner to run with -Pnone,linear by default
geky Nov 30, 2022
d8e7ffb
Changed lfs_emubd_get* -> lfs_emubd_*
geky Nov 30, 2022
b0382fa
Added BENCH/TEST_PRNG, replacing other ad-hoc sources of randomness
geky Nov 30, 2022
2d2dd8b
Added plotmpl.py --github flag to match the website's foreground/back…
geky Dec 2, 2022
cfd4e60
Added --subplot* to plotmpl.py
geky Dec 13, 2022
1f37eb5
Adopted --subplot* in plot.py
geky Dec 15, 2022
801cf27
Tweaked/fixed a number of small runner things after a bit of use
geky Dec 17, 2022
c2147c4
Added --gdb-pl to test.py for breaking on specific powerlosses
geky Dec 10, 2022
1278ec1
Adopted Brent's algorithm for cycle detection
geky Nov 8, 2022
52dd830
Initial implementation of forward-looking erase-state CRCs
geky Dec 5, 2020
91ad673
Cleaned up a few additional commit corner cases
geky Dec 6, 2020
b4091c6
Switched to separate-tag encoding of forward-looking CRCs
geky Dec 7, 2020
2f26966
Continued implementation of forward-crcs, adopted new test runners
geky Dec 8, 2022
d1b254d
Reverted removal of 1-bit counter threaded through tags
geky Dec 10, 2022
ba1c764
Fixed issue where deorphan could get stuck circling between two half-…
geky Dec 11, 2022
7b151e1
Add test scenario for truncating to a block size
colin-foster-in-advantage Jan 26, 2023
24795e6
Add missing iterations in tests
sosthene-nitrokey Mar 13, 2023
d5dc487
Expanded truncate tests to test more corner cases
geky Apr 17, 2023
6dc18c3
Fixed block-boundary truncate issue
geky Apr 17, 2023
e57402c
Added ability to revert to inline file in lfs_file_truncate
geky Apr 17, 2023
aae897f
Added an assert for truthy-preserving bool conversions
geky Apr 18, 2023
b0a4a44
Added explicit assert for minimum block size of 128 bytes
geky Apr 18, 2023
384a498
Extend dir seek tests to include seeking to end of directory
geky Apr 18, 2023
b33a5b3
Fixed issue where seeking to end-of-directory return LFS_ERR_INVAL
geky Apr 18, 2023
bf045dd
Tweaked link to littlefs-disk-img-viewer to go to github repo
geky Apr 19, 2023
f0cc1db
Tweaked changeprefix.py to not rename dir component in paths
geky Apr 19, 2023
116332d
Added tests for forwards and backwards disk compatibility
geky Apr 20, 2023
ca0da3d
Added compatibility testing on pull-request to GitHub test action
geky Apr 20, 2023
4c93600
Added ability to bump on-disk minor version
geky Apr 20, 2023
9e28c75
Bumped minor version to v2.6 and on-disk minor version to lfs2.1
geky Apr 20, 2023
3e25dfc
Added FCRC tags and an explanation of how FCRCs work to SPEC.md
geky Apr 21, 2023
0a7eca0
Merge pull request #752 from littlefs-project/test-and-bench-runners
geky Apr 26, 2023
6f074eb
Merge pull request #497 from littlefs-project/crc-rework-2
geky Apr 26, 2023
2a18e03
Merge pull request #809 from littlefs-project/brent-cycle-detection
geky Apr 26, 2023
01ac033
Merge pull request #572 from tniessen/add-littlefs-disk-img-viewer
geky Apr 26, 2023
ee6a51b
Merge pull request #718 from yomimono/mention-chamelon
geky Apr 26, 2023
e43d381
chore: add littlefs2 crate to README
elpiel Mar 17, 2023
363a8b5
Tweaked wording of littlefs2-rust link in README.md
geky Apr 18, 2023
a99574c
Merge pull request #807 from littlefs-project/doc-link-littlefs2-rust
geky Apr 26, 2023
50b394c
Merge pull request #801 from littlefs-project/assert-bool-cast
geky Apr 26, 2023
92298c7
Merge pull request #802 from littlefs-project/assert-minimum-block-size
geky Apr 26, 2023
922a35b
Merge remote-tracking branch 'origin/devel' into fix-boundary-truncates
geky Apr 26, 2023
b6773e6
Merge remote-tracking branch 'origin/devel' into fix-dir-seek-end
geky Apr 26, 2023
23a4a08
Merge pull request #800 from littlefs-project/fix-boundary-truncates
geky Apr 26, 2023
dd03c27
Merge pull request #805 from littlefs-project/fix-dir-seek-end
geky Apr 26, 2023
94d9e09
Fixed issue where lfs_fs_deorphan may run more than needed
geky Apr 27, 2023
259535e
Added lfs_fs_mkconsistent
geky Apr 27, 2023
3dca029
Merge pull request #811 from littlefs-project/fix-deorphan-repeatedly
geky May 1, 2023
405f332
Merge pull request #812 from littlefs-project/mkconsistent
geky May 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implemented exhaustive testing of n nested powerlosses
As expected this takes a significant amount of time (~10 minutes for all
1 powerlosses, >10 hours for all 2 powerlosses) but this may be reducible in
the future by optimizing tests for powerloss testing. Currently
test_files does a lot of work that doesn't really have testing value.
  • Loading branch information
geky committed Aug 25, 2022
commit 5279fc6022eb56d532c685b855b7637b74662ce3
199 changes: 95 additions & 104 deletions bd/lfs_testbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,68 +29,65 @@
// Note we can only modify a block if we have exclusive access to it (rc == 1)
//

// TODO
__attribute__((unused))
static void lfs_testbd_incblock(lfs_testbd_t *bd, lfs_block_t block) {
if (bd->blocks[block]) {
bd->blocks[block]->rc += 1;
static lfs_testbd_block_t *lfs_testbd_incblock(lfs_testbd_block_t *block) {
if (block) {
block->rc += 1;
}
return block;
}

static void lfs_testbd_decblock(lfs_testbd_t *bd, lfs_block_t block) {
if (bd->blocks[block]) {
bd->blocks[block]->rc -= 1;
if (bd->blocks[block]->rc == 0) {
free(bd->blocks[block]);
bd->blocks[block] = NULL;
static void lfs_testbd_decblock(lfs_testbd_block_t *block) {
if (block) {
block->rc -= 1;
if (block->rc == 0) {
free(block);
}
}
}

static const lfs_testbd_block_t *lfs_testbd_getblock(lfs_testbd_t *bd,
lfs_block_t block) {
return bd->blocks[block];
}

static lfs_testbd_block_t *lfs_testbd_mutblock(lfs_testbd_t *bd,
lfs_block_t block, lfs_size_t block_size) {
if (bd->blocks[block] && bd->blocks[block]->rc == 1) {
static lfs_testbd_block_t *lfs_testbd_mutblock(
const struct lfs_config *cfg,
lfs_testbd_block_t **block) {
lfs_testbd_block_t *block_ = *block;
if (block_ && block_->rc == 1) {
// rc == 1? can modify
return bd->blocks[block];
return block_;

} else if (bd->blocks[block]) {
} else if (block_) {
// rc > 1? need to create a copy
lfs_testbd_block_t *b = malloc(
sizeof(lfs_testbd_block_t) + block_size);
if (!b) {
lfs_testbd_block_t *nblock = malloc(
sizeof(lfs_testbd_block_t) + cfg->block_size);
if (!nblock) {
return NULL;
}

memcpy(b, bd->blocks[block], sizeof(lfs_testbd_block_t) + block_size);
b->rc = 1;
memcpy(nblock, block_,
sizeof(lfs_testbd_block_t) + cfg->block_size);
nblock->rc = 1;

lfs_testbd_decblock(bd, block);
bd->blocks[block] = b;
return b;
lfs_testbd_decblock(block_);
*block = nblock;
return nblock;

} else {
// no block? need to allocate
lfs_testbd_block_t *b = malloc(
sizeof(lfs_testbd_block_t) + block_size);
if (!b) {
lfs_testbd_block_t *nblock = malloc(
sizeof(lfs_testbd_block_t) + cfg->block_size);
if (!nblock) {
return NULL;
}

b->rc = 1;
b->wear = 0;
nblock->rc = 1;
nblock->wear = 0;

// zero for consistency
memset(b->data,
lfs_testbd_t *bd = cfg->context;
memset(nblock->data,
(bd->cfg->erase_value != -1) ? bd->cfg->erase_value : 0,
block_size);
cfg->block_size);

bd->blocks[block] = b;
return b;
*block = nblock;
return nblock;
}
}

Expand Down Expand Up @@ -129,22 +126,25 @@ int lfs_testbd_createcfg(const struct lfs_config *cfg, const char *path,

// setup testing things
bd->power_cycles = bd->cfg->power_cycles;
bd->disk_fd = -1;
bd->disk_scratch_block = NULL;

bd->branches = NULL;
bd->branch_capacity = 0;
bd->branch_count = 0;
bd->disk = NULL;

if (bd->cfg->disk_path) {
bd->disk = malloc(sizeof(lfs_testbd_disk_t));
if (!bd->disk) {
LFS_TESTBD_TRACE("lfs_testbd_createcfg -> %d", LFS_ERR_NOMEM);
return LFS_ERR_NOMEM;
}
bd->disk->rc = 1;
bd->disk->scratch = NULL;

#ifdef _WIN32
bd->disk_fd = open(bd->cfg->disk_path,
bd->disk->fd = open(bd->cfg->disk_path,
O_RDWR | O_CREAT | O_BINARY, 0666);
#else
bd->disk_fd = open(bd->cfg->disk_path,
bd->disk->fd = open(bd->cfg->disk_path,
O_RDWR | O_CREAT, 0666);
#endif
if (bd->disk_fd < 0) {
if (bd->disk->fd < 0) {
int err = -errno;
LFS_TESTBD_TRACE("lfs_testbd_create -> %d", err);
return err;
Expand All @@ -153,12 +153,12 @@ int lfs_testbd_createcfg(const struct lfs_config *cfg, const char *path,
// if we're emulating erase values, we can keep a block around in
// memory of just the erase state to speed up emulated erases
if (bd->cfg->erase_value != -1) {
bd->disk_scratch_block = malloc(cfg->block_size);
if (!bd->disk_scratch_block) {
bd->disk->scratch = malloc(cfg->block_size);
if (!bd->disk->scratch) {
LFS_TESTBD_TRACE("lfs_testbd_createcfg -> %d", LFS_ERR_NOMEM);
return LFS_ERR_NOMEM;
}
memset(bd->disk_scratch_block,
memset(bd->disk->scratch,
bd->cfg->erase_value,
cfg->block_size);
}
Expand Down Expand Up @@ -191,16 +191,18 @@ int lfs_testbd_destroy(const struct lfs_config *cfg) {

// decrement reference counts
for (lfs_block_t i = 0; i < cfg->block_count; i++) {
lfs_testbd_decblock(bd, i);
lfs_testbd_decblock(bd->blocks[i]);
}

// free memory
free(bd->blocks);
free(bd->branches);

if (bd->disk_fd >= 0) {
close(bd->disk_fd);
free(bd->disk_scratch_block);
// clean up other resources
if (bd->disk) {
bd->disk->rc -= 1;
if (bd->disk->rc == 0) {
close(bd->disk->fd);
free(bd->disk->scratch);
free(bd->disk);
}
}

LFS_TESTBD_TRACE("lfs_testbd_destroy -> %d", 0);
Expand All @@ -225,7 +227,7 @@ int lfs_testbd_read(const struct lfs_config *cfg, lfs_block_t block,
LFS_ASSERT(off+size <= cfg->block_size);

// get the block
const lfs_testbd_block_t *b = lfs_testbd_getblock(bd, block);
const lfs_testbd_block_t *b = bd->blocks[block];
if (b) {
// block bad?
if (bd->cfg->erase_cycles && b->wear >= bd->cfg->erase_cycles &&
Expand Down Expand Up @@ -273,7 +275,7 @@ int lfs_testbd_prog(const struct lfs_config *cfg, lfs_block_t block,
LFS_ASSERT(off+size <= cfg->block_size);

// get the block
lfs_testbd_block_t *b = lfs_testbd_mutblock(bd, block, cfg->block_size);
lfs_testbd_block_t *b = lfs_testbd_mutblock(cfg, &bd->blocks[block]);
if (!b) {
LFS_TESTBD_TRACE("lfs_testbd_prog -> %d", LFS_ERR_NOMEM);
return LFS_ERR_NOMEM;
Expand Down Expand Up @@ -305,8 +307,8 @@ int lfs_testbd_prog(const struct lfs_config *cfg, lfs_block_t block,
memcpy(&b->data[off], buffer, size);

// mirror to disk file?
if (bd->disk_fd >= 0) {
off_t res1 = lseek(bd->disk_fd,
if (bd->disk) {
off_t res1 = lseek(bd->disk->fd,
(off_t)block*cfg->block_size + (off_t)off,
SEEK_SET);
if (res1 < 0) {
Expand All @@ -315,7 +317,7 @@ int lfs_testbd_prog(const struct lfs_config *cfg, lfs_block_t block,
return err;
}

ssize_t res2 = write(bd->disk_fd, buffer, size);
ssize_t res2 = write(bd->disk->fd, buffer, size);
if (res2 < 0) {
int err = -errno;
LFS_TESTBD_TRACE("lfs_testbd_prog -> %d", err);
Expand Down Expand Up @@ -344,15 +346,6 @@ int lfs_testbd_prog(const struct lfs_config *cfg, lfs_block_t block,
}
}

// // track power-loss branch?
// if (bd->cfg->track_branches) {
// int err = lfs_testbd_trackbranch(bd);
// if (err) {
// LFS_TESTBD_TRACE("lfs_testbd_prog -> %d", err);
// return err;
// }
// }

LFS_TESTBD_TRACE("lfs_testbd_prog -> %d", 0);
return 0;
}
Expand All @@ -365,7 +358,7 @@ int lfs_testbd_erase(const struct lfs_config *cfg, lfs_block_t block) {
LFS_ASSERT(block < cfg->block_count);

// get the block
lfs_testbd_block_t *b = lfs_testbd_mutblock(bd, block, cfg->block_size);
lfs_testbd_block_t *b = lfs_testbd_mutblock(cfg, &bd->blocks[block]);
if (!b) {
LFS_TESTBD_TRACE("lfs_testbd_prog -> %d", LFS_ERR_NOMEM);
return LFS_ERR_NOMEM;
Expand Down Expand Up @@ -394,8 +387,8 @@ int lfs_testbd_erase(const struct lfs_config *cfg, lfs_block_t block) {
memset(b->data, bd->cfg->erase_value, cfg->block_size);

// mirror to disk file?
if (bd->disk_fd >= 0) {
off_t res1 = lseek(bd->disk_fd,
if (bd->disk) {
off_t res1 = lseek(bd->disk->fd,
(off_t)block*cfg->block_size,
SEEK_SET);
if (res1 < 0) {
Expand All @@ -404,8 +397,8 @@ int lfs_testbd_erase(const struct lfs_config *cfg, lfs_block_t block) {
return err;
}

ssize_t res2 = write(bd->disk_fd,
bd->disk_scratch_block,
ssize_t res2 = write(bd->disk->fd,
bd->disk->scratch,
cfg->block_size);
if (res2 < 0) {
int err = -errno;
Expand Down Expand Up @@ -436,15 +429,6 @@ int lfs_testbd_erase(const struct lfs_config *cfg, lfs_block_t block) {
}
}

// // track power-loss branch?
// if (bd->cfg->track_branches) {
// int err = lfs_testbd_trackbranch(bd);
// if (err) {
// LFS_TESTBD_TRACE("lfs_testbd_prog -> %d", err);
// return err;
// }
// }

LFS_TESTBD_TRACE("lfs_testbd_prog -> %d", 0);
return 0;
}
Expand Down Expand Up @@ -472,7 +456,7 @@ lfs_testbd_swear_t lfs_testbd_getwear(const struct lfs_config *cfg,

// get the wear
lfs_testbd_wear_t wear;
const lfs_testbd_block_t *b = lfs_testbd_getblock(bd, block);
const lfs_testbd_block_t *b = bd->blocks[block];
if (b) {
wear = b->wear;
} else {
Expand All @@ -492,7 +476,7 @@ int lfs_testbd_setwear(const struct lfs_config *cfg,
LFS_ASSERT(block < cfg->block_count);

// set the wear
lfs_testbd_block_t *b = lfs_testbd_mutblock(bd, block, cfg->block_size);
lfs_testbd_block_t *b = lfs_testbd_mutblock(cfg, &bd->blocks[block]);
if (!b) {
LFS_TESTBD_TRACE("lfs_testbd_setwear -> %"PRIu32, LFS_ERR_NOMEM);
return LFS_ERR_NOMEM;
Expand Down Expand Up @@ -524,23 +508,30 @@ int lfs_testbd_setpowercycles(const struct lfs_config *cfg,
return 0;
}

//int lfs_testbd_getbranch(const struct lfs_config *cfg,
// lfs_testbd_powercycles_t branch, lfs_testbd_t *bd) {
// LFS_TESTBD_TRACE("lfs_testbd_getbranch(%p, %zu, %p)",
// (void*)cfg, branch, bd);
// lfs_testbd_t *bd = cfg->context;
//
// // TODO
//
// LFS_TESTBD_TRACE("lfs_testbd_getbranch -> %d", 0);
// return 0;
//}

lfs_testbd_spowercycles_t lfs_testbd_getbranchcount(
const struct lfs_config *cfg) {
LFS_TESTBD_TRACE("lfs_testbd_getbranchcount(%p)", (void*)cfg);
int lfs_testbd_copy(const struct lfs_config *cfg, lfs_testbd_t *copy) {
LFS_TESTBD_TRACE("lfs_testbd_copy(%p, %p)", (void*)cfg, (void*)copy);
lfs_testbd_t *bd = cfg->context;

LFS_TESTBD_TRACE("lfs_testbd_getbranchcount -> %"PRIu32, bd->branch_count);
return bd->branch_count;
// lazily copy over our block array
copy->blocks = malloc(cfg->block_count * sizeof(lfs_testbd_block_t*));
if (!copy->blocks) {
LFS_TESTBD_TRACE("lfs_testbd_copy -> %d", LFS_ERR_NOMEM);
return LFS_ERR_NOMEM;
}

for (size_t i = 0; i < cfg->block_count; i++) {
copy->blocks[i] = lfs_testbd_incblock(bd->blocks[i]);
}

// other state
copy->power_cycles = bd->power_cycles;
copy->disk = bd->disk;
if (copy->disk) {
copy->disk->rc += 1;
}
copy->cfg = bd->cfg;

LFS_TESTBD_TRACE("lfs_testbd_copy -> %d", 0);
return 0;
}

Loading