diff --git a/bd/lfs3_emubd.c b/bd/lfs3_emubd.c index f72d5fe9..b7a0b148 100644 --- a/bd/lfs3_emubd.c +++ b/bd/lfs3_emubd.c @@ -217,8 +217,11 @@ int lfs3_emubd_createcfg(const struct lfs3_cfg *cfg, const char *path, // setup testing things bd->blocks = NULL; + bd->reads = 0; + bd->progs = 0; + bd->erases = 0; bd->readed = 0; - bd->proged = 0; + bd->progged = 0; bd->erased = 0; bd->prng = bd->cfg->seed; bd->power_cycles = bd->cfg->power_cycles; @@ -434,6 +437,7 @@ int lfs3_emubd_read(const struct lfs3_cfg *cfg, lfs3_block_t block, } // track reads + bd->reads += 1; bd->readed += size; if (bd->cfg->read_sleep) { int err = nanosleep(&(struct timespec){ @@ -745,7 +749,8 @@ progged:; } // track progs - bd->proged += size; + bd->progs += 1; + bd->progged += size; if (bd->cfg->prog_sleep) { int err = nanosleep(&(struct timespec){ .tv_sec=bd->cfg->prog_sleep/1000000000, @@ -1040,6 +1045,7 @@ int lfs3_emubd_erase(const struct lfs3_cfg *cfg, lfs3_block_t block) { erased:; // track erases + bd->erases += 1; bd->erased += cfg->block_size; if (bd->cfg->erase_sleep) { int err = nanosleep(&(struct timespec){ @@ -1076,24 +1082,65 @@ int lfs3_emubd_sync(const struct lfs3_cfg *cfg) { /// Additional emubd features for testing /// -void lfs3_emubd_seed(const struct lfs3_cfg *cfg, uint32_t seed) { - LFS3_EMUBD_TRACE("lfs3_emubd_seed(%p, 0x%08"PRIx32")", - (void*)cfg, seed); +lfs3_emubd_sns_t lfs3_emubd_simtime(const struct lfs3_cfg *cfg) { + LFS3_EMUBD_TRACE("lfs3_emubd_simtime(%p)", (void*)cfg); lfs3_emubd_t *bd = cfg->context; - bd->prng = seed; + // error if all possible timings are zero + if (bd->cfg->reads_timing == 0 + && bd->cfg->progs_timing == 0 + && bd->cfg->erases_timing == 0 + && bd->cfg->readed_timing == 0 + && bd->cfg->progged_timing == 0 + && bd->cfg->erased_timing == 0) { + LFS3_EMUBD_TRACE("lfs3_emubd_simtime -> %d", LFS3_ERR_NOTSUP); + return LFS3_ERR_NOTSUP; + } - LFS3_EMUBD_TRACE("lfs3_emubd_seed -> _"); + lfs3_emubd_ns_t ns + = (bd->cfg->reads_timing * bd->reads) + + (bd->cfg->progs_timing * bd->progs) + + (bd->cfg->erases_timing * bd->erases) + + (bd->cfg->readed_timing * bd->readed) + + (bd->cfg->progged_timing * bd->progged) + + (bd->cfg->erased_timing * bd->erased); + + LFS3_EMUBD_TRACE("lfs3_emubd_simtime -> %"PRIu64, ns); + return ns; } -uint32_t lfs3_emubd_prng(const struct lfs3_cfg *cfg) { - LFS3_EMUBD_TRACE("lfs3_emubd_prng(%p)", (void*)cfg); +int lfs3_emubd_simreset(const struct lfs3_cfg *cfg) { + LFS3_EMUBD_TRACE("lfs3_emubd_simreset(%p)", (void*)cfg); lfs3_emubd_t *bd = cfg->context; + bd->reads = 0; + bd->progs = 0; + bd->erases = 0; + bd->readed = 0; + bd->progged = 0; + bd->erased = 0; + LFS3_EMUBD_TRACE("lfs3_emubd_simreset -> %d", 0); + return 0; +} - uint32_t x = lfs3_emubd_prng_(&bd->prng); +lfs3_emubd_sio_t lfs3_emubd_reads(const struct lfs3_cfg *cfg) { + LFS3_EMUBD_TRACE("lfs3_emubd_reads(%p)", (void*)cfg); + lfs3_emubd_t *bd = cfg->context; + LFS3_EMUBD_TRACE("lfs3_emubd_reads -> %"PRIu64, bd->reads); + return bd->reads; +} - LFS3_EMUBD_TRACE("lfs3_emubd_prng -> 0x%08"PRIx32, x); - return x; +lfs3_emubd_sio_t lfs3_emubd_progs(const struct lfs3_cfg *cfg) { + LFS3_EMUBD_TRACE("lfs3_emubd_progs(%p)", (void*)cfg); + lfs3_emubd_t *bd = cfg->context; + LFS3_EMUBD_TRACE("lfs3_emubd_progs -> %"PRIu64, bd->progs); + return bd->progs; +} + +lfs3_emubd_sio_t lfs3_emubd_erases(const struct lfs3_cfg *cfg) { + LFS3_EMUBD_TRACE("lfs3_emubd_erases(%p)", (void*)cfg); + lfs3_emubd_t *bd = cfg->context; + LFS3_EMUBD_TRACE("lfs3_emubd_erases -> %"PRIu64, bd->erases); + return bd->erases; } lfs3_emubd_sio_t lfs3_emubd_readed(const struct lfs3_cfg *cfg) { @@ -1103,11 +1150,11 @@ lfs3_emubd_sio_t lfs3_emubd_readed(const struct lfs3_cfg *cfg) { return bd->readed; } -lfs3_emubd_sio_t lfs3_emubd_proged(const struct lfs3_cfg *cfg) { - LFS3_EMUBD_TRACE("lfs3_emubd_proged(%p)", (void*)cfg); +lfs3_emubd_sio_t lfs3_emubd_progged(const struct lfs3_cfg *cfg) { + LFS3_EMUBD_TRACE("lfs3_emubd_progged(%p)", (void*)cfg); lfs3_emubd_t *bd = cfg->context; - LFS3_EMUBD_TRACE("lfs3_emubd_proged -> %"PRIu64, bd->proged); - return bd->proged; + LFS3_EMUBD_TRACE("lfs3_emubd_progged -> %"PRIu64, bd->progged); + return bd->progged; } lfs3_emubd_sio_t lfs3_emubd_erased(const struct lfs3_cfg *cfg) { @@ -1117,33 +1164,6 @@ lfs3_emubd_sio_t lfs3_emubd_erased(const struct lfs3_cfg *cfg) { return bd->erased; } -int lfs3_emubd_setreaded(const struct lfs3_cfg *cfg, - lfs3_emubd_io_t readed) { - LFS3_EMUBD_TRACE("lfs3_emubd_setreaded(%p, %"PRIu64")", (void*)cfg, readed); - lfs3_emubd_t *bd = cfg->context; - bd->readed = readed; - LFS3_EMUBD_TRACE("lfs3_emubd_setreaded -> %d", 0); - return 0; -} - -int lfs3_emubd_setproged(const struct lfs3_cfg *cfg, - lfs3_emubd_io_t proged) { - LFS3_EMUBD_TRACE("lfs3_emubd_setproged(%p, %"PRIu64")", (void*)cfg, proged); - lfs3_emubd_t *bd = cfg->context; - bd->proged = proged; - LFS3_EMUBD_TRACE("lfs3_emubd_setproged -> %d", 0); - return 0; -} - -int lfs3_emubd_seterased(const struct lfs3_cfg *cfg, - lfs3_emubd_io_t erased) { - LFS3_EMUBD_TRACE("lfs3_emubd_seterased(%p, %"PRIu64")", (void*)cfg, erased); - lfs3_emubd_t *bd = cfg->context; - bd->erased = erased; - LFS3_EMUBD_TRACE("lfs3_emubd_seterased -> %d", 0); - return 0; -} - lfs3_emubd_swear_t lfs3_emubd_wear(const struct lfs3_cfg *cfg, lfs3_block_t block) { LFS3_EMUBD_TRACE("lfs3_emubd_wear(%p, %"PRIu32")", (void*)cfg, block); @@ -1189,9 +1209,9 @@ int lfs3_emubd_setwear(const struct lfs3_cfg *cfg, return 0; } -int lfs3_emubd_markbad(const struct lfs3_cfg *cfg, +int lfs3_emubd_mkbad(const struct lfs3_cfg *cfg, lfs3_block_t block) { - LFS3_EMUBD_TRACE("lfs3_emubd_markbad(%p, %"PRIu32")", + LFS3_EMUBD_TRACE("lfs3_emubd_mkbad(%p, %"PRIu32")", (void*)cfg, block); lfs3_emubd_t *bd = cfg->context; @@ -1201,7 +1221,7 @@ int lfs3_emubd_markbad(const struct lfs3_cfg *cfg, // mutate the block lfs3_emubd_block_t *b = lfs3_emubd_mutblock(cfg, bd->blocks[block]); if (!b) { - LFS3_EMUBD_TRACE("lfs3_emubd_markbad -> %d", LFS3_ERR_NOMEM); + LFS3_EMUBD_TRACE("lfs3_emubd_mkbad -> %d", LFS3_ERR_NOMEM); return LFS3_ERR_NOMEM; } bd->blocks[block] = b; @@ -1215,13 +1235,13 @@ int lfs3_emubd_markbad(const struct lfs3_cfg *cfg, % (cfg->block_size*8); } - LFS3_EMUBD_TRACE("lfs3_emubd_markbad -> %d", 0); + LFS3_EMUBD_TRACE("lfs3_emubd_mkbad -> %d", 0); return 0; } -int lfs3_emubd_markgood(const struct lfs3_cfg *cfg, +int lfs3_emubd_mkgood(const struct lfs3_cfg *cfg, lfs3_block_t block) { - LFS3_EMUBD_TRACE("lfs3_emubd_markgood(%p, %"PRIu32")", + LFS3_EMUBD_TRACE("lfs3_emubd_mkgood(%p, %"PRIu32")", (void*)cfg, block); lfs3_emubd_t *bd = cfg->context; @@ -1231,7 +1251,7 @@ int lfs3_emubd_markgood(const struct lfs3_cfg *cfg, // mutate the block lfs3_emubd_block_t *b = lfs3_emubd_mutblock(cfg, bd->blocks[block]); if (!b) { - LFS3_EMUBD_TRACE("lfs3_emubd_markgood -> %d", LFS3_ERR_NOMEM); + LFS3_EMUBD_TRACE("lfs3_emubd_mkgood -> %d", LFS3_ERR_NOMEM); return LFS3_ERR_NOMEM; } bd->blocks[block] = b; @@ -1239,7 +1259,7 @@ int lfs3_emubd_markgood(const struct lfs3_cfg *cfg, // set the wear b->wear = 0; - LFS3_EMUBD_TRACE("lfs3_emubd_markgood -> %d", 0); + LFS3_EMUBD_TRACE("lfs3_emubd_mkgood -> %d", 0); return 0; } @@ -1312,9 +1332,9 @@ int lfs3_emubd_randomizebadbit(const struct lfs3_cfg *cfg, return 0; } -int lfs3_emubd_markbadbit(const struct lfs3_cfg *cfg, +int lfs3_emubd_mkbadbit(const struct lfs3_cfg *cfg, lfs3_block_t block, lfs3_size_t bit) { - LFS3_EMUBD_TRACE("lfs3_emubd_markbadbit(%p, %"PRIu32", %"PRIu32")", + LFS3_EMUBD_TRACE("lfs3_emubd_mkbadbit(%p, %"PRIu32", %"PRIu32")", (void*)cfg, block, bit); lfs3_emubd_t *bd = cfg->context; @@ -1324,7 +1344,7 @@ int lfs3_emubd_markbadbit(const struct lfs3_cfg *cfg, // mutate the block lfs3_emubd_block_t *b = lfs3_emubd_mutblock(cfg, bd->blocks[block]); if (!b) { - LFS3_EMUBD_TRACE("lfs3_emubd_markbadbit -> %d", LFS3_ERR_NOMEM); + LFS3_EMUBD_TRACE("lfs3_emubd_mkbadbit -> %d", LFS3_ERR_NOMEM); return LFS3_ERR_NOMEM; } bd->blocks[block] = b; @@ -1334,7 +1354,7 @@ int lfs3_emubd_markbadbit(const struct lfs3_cfg *cfg, // set the bad bit and mark as fixed b->bad_bit = 0x80000000 | bit; - LFS3_EMUBD_TRACE("lfs3_emubd_markbadbit -> %d", 0); + LFS3_EMUBD_TRACE("lfs3_emubd_mkbadbit -> %d", 0); return 0; } @@ -1434,6 +1454,27 @@ int lfs3_emubd_setpowercycles(const struct lfs3_cfg *cfg, return 0; } +void lfs3_emubd_seed(const struct lfs3_cfg *cfg, uint32_t seed) { + LFS3_EMUBD_TRACE("lfs3_emubd_seed(%p, 0x%08"PRIx32")", + (void*)cfg, seed); + lfs3_emubd_t *bd = cfg->context; + + bd->prng = seed; + + LFS3_EMUBD_TRACE("lfs3_emubd_seed -> _"); +} + +uint32_t lfs3_emubd_prng(const struct lfs3_cfg *cfg) { + LFS3_EMUBD_TRACE("lfs3_emubd_prng(%p)", (void*)cfg); + lfs3_emubd_t *bd = cfg->context; + + uint32_t x = lfs3_emubd_prng_(&bd->prng); + + LFS3_EMUBD_TRACE("lfs3_emubd_prng -> 0x%08"PRIx32, x); + return x; +} + + int lfs3_emubd_cpy(const struct lfs3_cfg *cfg, lfs3_emubd_t *copy) { LFS3_EMUBD_TRACE("lfs3_emubd_cpy(%p, %p)", (void*)cfg, (void*)copy); lfs3_emubd_t *bd = cfg->context; @@ -1472,8 +1513,11 @@ int lfs3_emubd_cpy(const struct lfs3_cfg *cfg, lfs3_emubd_t *copy) { } // other state + copy->reads = bd->reads; + copy->progs = bd->progs; + copy->erases = bd->erases; copy->readed = bd->readed; - copy->proged = bd->proged; + copy->progged = bd->progged; copy->erased = bd->erased; copy->prng = bd->prng; copy->power_cycles = bd->power_cycles; diff --git a/bd/lfs3_emubd.h b/bd/lfs3_emubd.h index f1b67bc7..49ea3acc 100644 --- a/bd/lfs3_emubd.h +++ b/bd/lfs3_emubd.h @@ -63,8 +63,8 @@ typedef uint32_t lfs3_emubd_powercycles_t; typedef int32_t lfs3_emubd_spowercycles_t; // Type for delays in nanoseconds -typedef uint64_t lfs3_emubd_sleep_t; -typedef int64_t lfs3_emubd_ssleep_t; +typedef uint64_t lfs3_emubd_ns_t; +typedef int64_t lfs3_emubd_sns_t; // emubd config, this is required for testing struct lfs3_emubd_cfg { @@ -74,6 +74,42 @@ struct lfs3_emubd_cfg { // does _not_ rely on this!). int32_t erase_value; + // Simulated read transaction timing in nanoseconds, this is added + // to simtime each read call, ignoring the requested size + lfs3_emubd_ns_t reads_timing; + + // Simulated prog transaction timing in nanoseconds, this is added + // to simtime each prog call, ignoring the requested size + lfs3_emubd_ns_t progs_timing; + + // Simulated erase transaction timing in nanoseconds, this is added + // to simtime each erase call, ignoring the requested size + lfs3_emubd_ns_t erases_timing; + + // Simulated read byte timing in nanoseconds, this is scaled by the + // requested size and added to simtime each read call. + lfs3_emubd_ns_t readed_timing; + + // Simulated prog byte timing in nanoseconds, this is scaled by the + // requested size and added to simtime each prog call. + lfs3_emubd_ns_t progged_timing; + + // Simulated erase byte timing in nanoseconds, this is scaled by the + // requested size and added to simtime each erase call. + lfs3_emubd_ns_t erased_timing; + + // Artificial read transaction delay in nanoseconds, there is no + // purpose for this other than slowing down the simulation. + lfs3_emubd_ns_t read_sleep; + + // Artificial prog transaction delay in nanoseconds, there is no + // purpose for this other than slowing down the simulation. + lfs3_emubd_ns_t prog_sleep; + + // Artificial erase transaction delay in nanoseconds, there is no + // purpose for this other than slowing down the simulation. + lfs3_emubd_ns_t erase_sleep; + // Number of erase cycles before a block becomes "bad". The exact behavior // of bad blocks is controlled by badblock_behavior. uint32_t erase_cycles; @@ -99,18 +135,6 @@ struct lfs3_emubd_cfg { // Seed for prng, which may be used for emulating failed progs. This does // not affect normal operation. uint32_t seed; - - // Artificial delay in nanoseconds, there is no purpose for this other - // than slowing down the simulation. - lfs3_emubd_sleep_t read_sleep; - - // Artificial delay in nanoseconds, there is no purpose for this other - // than slowing down the simulation. - lfs3_emubd_sleep_t prog_sleep; - - // Artificial delay in nanoseconds, there is no purpose for this other - // than slowing down the simulation. - lfs3_emubd_sleep_t erase_sleep; }; // A reference counted block @@ -138,8 +162,11 @@ typedef struct lfs3_emubd { lfs3_emubd_block_t **blocks; // some other test state + lfs3_emubd_io_t reads; + lfs3_emubd_io_t progs; + lfs3_emubd_io_t erases; lfs3_emubd_io_t readed; - lfs3_emubd_io_t proged; + lfs3_emubd_io_t progged; lfs3_emubd_io_t erased; uint32_t prng; lfs3_emubd_powercycles_t power_cycles; @@ -188,33 +215,32 @@ int lfs3_emubd_sync(const struct lfs3_cfg *cfg); /// Additional emubd features for testing /// -// Set the current prng state -void lfs3_emubd_seed(const struct lfs3_cfg *cfg, uint32_t seed); +// Get total simulated runtime +lfs3_emubd_sns_t lfs3_emubd_simtime(const struct lfs3_cfg *cfg); -// Get a pseudo-random number from emubd's internal prng -uint32_t lfs3_emubd_prng(const struct lfs3_cfg *cfg); +// Reset simulation counters +// +// You probably shouldn't call this, instead diff before/after simtimes +int lfs3_emubd_simreset(const struct lfs3_cfg *cfg); + +// Get total number of read transactions +lfs3_emubd_sio_t lfs3_emubd_reads(const struct lfs3_cfg *cfg); + +// Get total number of prog transactions +lfs3_emubd_sio_t lfs3_emubd_progs(const struct lfs3_cfg *cfg); + +// Get total number of erase transactions +lfs3_emubd_sio_t lfs3_emubd_erases(const struct lfs3_cfg *cfg); // Get total amount of bytes read lfs3_emubd_sio_t lfs3_emubd_readed(const struct lfs3_cfg *cfg); // Get total amount of bytes programmed -lfs3_emubd_sio_t lfs3_emubd_proged(const struct lfs3_cfg *cfg); +lfs3_emubd_sio_t lfs3_emubd_progged(const struct lfs3_cfg *cfg); // Get total amount of bytes erased lfs3_emubd_sio_t lfs3_emubd_erased(const struct lfs3_cfg *cfg); -// Manually set amount of bytes read -int lfs3_emubd_setreaded(const struct lfs3_cfg *cfg, - lfs3_emubd_io_t readed); - -// Manually set amount of bytes programmed -int lfs3_emubd_setproged(const struct lfs3_cfg *cfg, - lfs3_emubd_io_t proged); - -// Manually set amount of bytes erased -int lfs3_emubd_seterased(const struct lfs3_cfg *cfg, - lfs3_emubd_io_t erased); - // Get simulated wear on a given block lfs3_emubd_swear_t lfs3_emubd_wear(const struct lfs3_cfg *cfg, lfs3_block_t block); @@ -224,10 +250,10 @@ int lfs3_emubd_setwear(const struct lfs3_cfg *cfg, lfs3_block_t block, lfs3_emubd_wear_t wear); // Mark a block as bad, this is equivalent to setting wear to maximum -int lfs3_emubd_markbad(const struct lfs3_cfg *cfg, lfs3_block_t block); +int lfs3_emubd_mkbad(const struct lfs3_cfg *cfg, lfs3_block_t block); // Clear any simulated wear on a given block -int lfs3_emubd_markgood(const struct lfs3_cfg *cfg, lfs3_block_t block); +int lfs3_emubd_mkgood(const struct lfs3_cfg *cfg, lfs3_block_t block); // Get which bit failed, this changes on erase/power-loss unless manually set lfs3_ssize_t lfs3_emubd_badbit(const struct lfs3_cfg *cfg, @@ -242,7 +268,7 @@ int lfs3_emubd_randomizebadbit(const struct lfs3_cfg *cfg, lfs3_block_t block); // Mark a block as bad and which bit should fail -int lfs3_emubd_markbadbit(const struct lfs3_cfg *cfg, +int lfs3_emubd_mkbadbit(const struct lfs3_cfg *cfg, lfs3_block_t block, lfs3_size_t bit); // Flip a bit in a given block, intended for emulating bit errors @@ -260,6 +286,12 @@ lfs3_emubd_spowercycles_t lfs3_emubd_powercycles( int lfs3_emubd_setpowercycles(const struct lfs3_cfg *cfg, lfs3_emubd_powercycles_t power_cycles); +// Get a pseudo-random number from emubd's internal prng +uint32_t lfs3_emubd_prng(const struct lfs3_cfg *cfg); + +// Set the current prng state +void lfs3_emubd_seed(const struct lfs3_cfg *cfg, uint32_t seed); + // Create a copy-on-write copy of the state of this block device int lfs3_emubd_cpy(const struct lfs3_cfg *cfg, lfs3_emubd_t *copy); diff --git a/bd/lfs3_kiwibd.c b/bd/lfs3_kiwibd.c index 53dec9be..bf2cf08a 100644 --- a/bd/lfs3_kiwibd.c +++ b/bd/lfs3_kiwibd.c @@ -117,8 +117,11 @@ int lfs3_kiwibd_createcfg(const struct lfs3_cfg *cfg, const char *path, bd->cfg = bdcfg; // setup some initial state + bd->reads = 0; + bd->progs = 0; + bd->erases = 0; bd->readed = 0; - bd->proged = 0; + bd->progged = 0; bd->erased = 0; bd->fd = -1; if (path) { @@ -276,6 +279,7 @@ int lfs3_kiwibd_read(const struct lfs3_cfg *cfg, lfs3_block_t block, } // track reads + bd->reads += 1; bd->readed += size; if (bd->cfg->read_sleep) { int err = nanosleep(&(struct timespec){ @@ -404,7 +408,8 @@ int lfs3_kiwibd_prog(const struct lfs3_cfg *cfg, lfs3_block_t block, } // track progs - bd->proged += size; + bd->progs += 1; + bd->progged += size; if (bd->cfg->prog_sleep) { int err = nanosleep(&(struct timespec){ .tv_sec=bd->cfg->prog_sleep/1000000000, @@ -465,6 +470,7 @@ int lfs3_kiwibd_erase(const struct lfs3_cfg *cfg, lfs3_block_t block) { erased:; // track erases + bd->erases += 1; bd->erased += cfg->block_size; if (bd->cfg->erase_sleep) { int err = nanosleep(&(struct timespec){ @@ -501,6 +507,67 @@ int lfs3_kiwibd_sync(const struct lfs3_cfg *cfg) { /// Additional kiwibd features /// +lfs3_kiwibd_sns_t lfs3_kiwibd_simtime(const struct lfs3_cfg *cfg) { + LFS3_KIWIBD_TRACE("lfs3_kiwibd_simtime(%p)", (void*)cfg); + lfs3_kiwibd_t *bd = cfg->context; + + // error if all possible timings are zero + if (bd->cfg->reads_timing == 0 + && bd->cfg->progs_timing == 0 + && bd->cfg->erases_timing == 0 + && bd->cfg->readed_timing == 0 + && bd->cfg->progged_timing == 0 + && bd->cfg->erased_timing == 0) { + LFS3_KIWIBD_TRACE("lfs3_kiwibd_simtime -> %d", LFS3_ERR_NOTSUP); + return LFS3_ERR_NOTSUP; + } + + lfs3_kiwibd_ns_t ns + = (bd->cfg->reads_timing * bd->reads) + + (bd->cfg->progs_timing * bd->progs) + + (bd->cfg->erases_timing * bd->erases) + + (bd->cfg->readed_timing * bd->readed) + + (bd->cfg->progged_timing * bd->progged) + + (bd->cfg->erased_timing * bd->erased); + + LFS3_KIWIBD_TRACE("lfs3_kiwibd_simtime -> %"PRIu64, ns); + return ns; +} + +int lfs3_kiwibd_simreset(const struct lfs3_cfg *cfg) { + LFS3_KIWIBD_TRACE("lfs3_kiwibd_simreset(%p)", (void*)cfg); + lfs3_kiwibd_t *bd = cfg->context; + bd->reads = 0; + bd->progs = 0; + bd->erases = 0; + bd->readed = 0; + bd->progged = 0; + bd->erased = 0; + LFS3_KIWIBD_TRACE("lfs3_kiwibd_simreset -> %d", 0); + return 0; +} + +lfs3_kiwibd_sio_t lfs3_kiwibd_reads(const struct lfs3_cfg *cfg) { + LFS3_KIWIBD_TRACE("lfs3_kiwibd_reads(%p)", (void*)cfg); + lfs3_kiwibd_t *bd = cfg->context; + LFS3_KIWIBD_TRACE("lfs3_kiwibd_reads -> %"PRIu64, bd->reads); + return bd->reads; +} + +lfs3_kiwibd_sio_t lfs3_kiwibd_progs(const struct lfs3_cfg *cfg) { + LFS3_KIWIBD_TRACE("lfs3_kiwibd_progs(%p)", (void*)cfg); + lfs3_kiwibd_t *bd = cfg->context; + LFS3_KIWIBD_TRACE("lfs3_kiwibd_progs -> %"PRIu64, bd->progs); + return bd->progs; +} + +lfs3_kiwibd_sio_t lfs3_kiwibd_erases(const struct lfs3_cfg *cfg) { + LFS3_KIWIBD_TRACE("lfs3_kiwibd_erases(%p)", (void*)cfg); + lfs3_kiwibd_t *bd = cfg->context; + LFS3_KIWIBD_TRACE("lfs3_kiwibd_erases -> %"PRIu64, bd->erases); + return bd->erases; +} + lfs3_kiwibd_sio_t lfs3_kiwibd_readed(const struct lfs3_cfg *cfg) { LFS3_KIWIBD_TRACE("lfs3_kiwibd_readed(%p)", (void*)cfg); lfs3_kiwibd_t *bd = cfg->context; @@ -508,11 +575,11 @@ lfs3_kiwibd_sio_t lfs3_kiwibd_readed(const struct lfs3_cfg *cfg) { return bd->readed; } -lfs3_kiwibd_sio_t lfs3_kiwibd_proged(const struct lfs3_cfg *cfg) { - LFS3_KIWIBD_TRACE("lfs3_kiwibd_proged(%p)", (void*)cfg); +lfs3_kiwibd_sio_t lfs3_kiwibd_progged(const struct lfs3_cfg *cfg) { + LFS3_KIWIBD_TRACE("lfs3_kiwibd_progged(%p)", (void*)cfg); lfs3_kiwibd_t *bd = cfg->context; - LFS3_KIWIBD_TRACE("lfs3_kiwibd_proged -> %"PRIu64, bd->proged); - return bd->proged; + LFS3_KIWIBD_TRACE("lfs3_kiwibd_progged -> %"PRIu64, bd->progged); + return bd->progged; } lfs3_kiwibd_sio_t lfs3_kiwibd_erased(const struct lfs3_cfg *cfg) { @@ -522,33 +589,3 @@ lfs3_kiwibd_sio_t lfs3_kiwibd_erased(const struct lfs3_cfg *cfg) { return bd->erased; } -int lfs3_kiwibd_setreaded(const struct lfs3_cfg *cfg, - lfs3_kiwibd_io_t readed) { - LFS3_KIWIBD_TRACE("lfs3_kiwibd_setreaded(%p, %"PRIu64")", - (void*)cfg, readed); - lfs3_kiwibd_t *bd = cfg->context; - bd->readed = readed; - LFS3_KIWIBD_TRACE("lfs3_kiwibd_setreaded -> %d", 0); - return 0; -} - -int lfs3_kiwibd_setproged(const struct lfs3_cfg *cfg, - lfs3_kiwibd_io_t proged) { - LFS3_KIWIBD_TRACE("lfs3_kiwibd_setproged(%p, %"PRIu64")", - (void*)cfg, proged); - lfs3_kiwibd_t *bd = cfg->context; - bd->proged = proged; - LFS3_KIWIBD_TRACE("lfs3_kiwibd_setproged -> %d", 0); - return 0; -} - -int lfs3_kiwibd_seterased(const struct lfs3_cfg *cfg, - lfs3_kiwibd_io_t erased) { - LFS3_KIWIBD_TRACE("lfs3_kiwibd_seterased(%p, %"PRIu64")", - (void*)cfg, erased); - lfs3_kiwibd_t *bd = cfg->context; - bd->erased = erased; - LFS3_KIWIBD_TRACE("lfs3_kiwibd_seterased -> %d", 0); - return 0; -} - diff --git a/bd/lfs3_kiwibd.h b/bd/lfs3_kiwibd.h index 0cd36728..f3d00c99 100644 --- a/bd/lfs3_kiwibd.h +++ b/bd/lfs3_kiwibd.h @@ -28,32 +28,56 @@ typedef uint64_t lfs3_kiwibd_io_t; typedef int64_t lfs3_kiwibd_sio_t; // Type for delays in nanoseconds -typedef uint64_t lfs3_kiwibd_sleep_t; -typedef int64_t lfs3_kiwibd_ssleep_t; +typedef uint64_t lfs3_kiwibd_ns_t; +typedef int64_t lfs3_kiwibd_sns_t; // kiwibd config, this is required for testing struct lfs3_kiwibd_cfg { + // Optional statically allocated buffer for the block device. Ignored + // if disk_path is provided. + void *buffer; + // 8-bit erase value to use for simulating erases. -1 simulates a noop // erase, which is faster than simulating a fixed erase value. -2 emulates // nor-masking, which is useful for testing other filesystems (littlefs // does _not_ rely on this!). int32_t erase_value; - // Optional statically allocated buffer for the block device. Ignored - // if disk_path is provided. - void *buffer; + // Simulated read transaction timing in nanoseconds, this is added + // to simtime each read call, ignoring the requested size + lfs3_kiwibd_ns_t reads_timing; - // Artificial delay in nanoseconds, there is no purpose for this other - // than slowing down the simulation. - lfs3_kiwibd_sleep_t read_sleep; + // Simulated prog transaction timing in nanoseconds, this is added + // to simtime each prog call, ignoring the requested size + lfs3_kiwibd_ns_t progs_timing; - // Artificial delay in nanoseconds, there is no purpose for this other - // than slowing down the simulation. - lfs3_kiwibd_sleep_t prog_sleep; + // Simulated erase transaction timing in nanoseconds, this is added + // to simtime each erase call, ignoring the requested size + lfs3_kiwibd_ns_t erases_timing; - // Artificial delay in nanoseconds, there is no purpose for this other - // than slowing down the simulation. - lfs3_kiwibd_sleep_t erase_sleep; + // Simulated read byte timing in nanoseconds, this is scaled by the + // requested size and added to simtime each read call. + lfs3_kiwibd_ns_t readed_timing; + + // Simulated prog byte timing in nanoseconds, this is scaled by the + // requested size and added to simtime each prog call. + lfs3_kiwibd_ns_t progged_timing; + + // Simulated erase byte timing in nanoseconds, this is scaled by the + // requested size and added to simtime each erase call. + lfs3_kiwibd_ns_t erased_timing; + + // Artificial read transaction delay in nanoseconds, there is no + // purpose for this other than slowing down the simulation. + lfs3_kiwibd_ns_t read_sleep; + + // Artificial prog transaction delay in nanoseconds, there is no + // purpose for this other than slowing down the simulation. + lfs3_kiwibd_ns_t prog_sleep; + + // Artificial erase transaction delay in nanoseconds, there is no + // purpose for this other than slowing down the simulation. + lfs3_kiwibd_ns_t erase_sleep; }; // kiwibd state @@ -66,8 +90,11 @@ typedef struct lfs3_kiwibd { } u; // amount read/progged/erased + lfs3_kiwibd_io_t reads; + lfs3_kiwibd_io_t progs; + lfs3_kiwibd_io_t erases; lfs3_kiwibd_io_t readed; - lfs3_kiwibd_io_t proged; + lfs3_kiwibd_io_t progged; lfs3_kiwibd_io_t erased; const struct lfs3_kiwibd_cfg *cfg; @@ -110,27 +137,32 @@ int lfs3_kiwibd_sync(const struct lfs3_cfg *cfg); /// Additional kiwibd features /// +// Get total simulated runtime +lfs3_kiwibd_sns_t lfs3_kiwibd_simtime(const struct lfs3_cfg *cfg); + +// Reset simulation counters +// +// You probably shouldn't call this, instead diff before/after simtimes +int lfs3_kiwibd_simreset(const struct lfs3_cfg *cfg); + +// Get total number of read transactions +lfs3_kiwibd_sio_t lfs3_kiwibd_reads(const struct lfs3_cfg *cfg); + +// Get total number of prog transactions +lfs3_kiwibd_sio_t lfs3_kiwibd_progs(const struct lfs3_cfg *cfg); + +// Get total number of erase transactions +lfs3_kiwibd_sio_t lfs3_kiwibd_erases(const struct lfs3_cfg *cfg); + // Get total amount of bytes read lfs3_kiwibd_sio_t lfs3_kiwibd_readed(const struct lfs3_cfg *cfg); // Get total amount of bytes programmed -lfs3_kiwibd_sio_t lfs3_kiwibd_proged(const struct lfs3_cfg *cfg); +lfs3_kiwibd_sio_t lfs3_kiwibd_progged(const struct lfs3_cfg *cfg); // Get total amount of bytes erased lfs3_kiwibd_sio_t lfs3_kiwibd_erased(const struct lfs3_cfg *cfg); -// Manually set amount of bytes read -int lfs3_kiwibd_setreaded(const struct lfs3_cfg *cfg, - lfs3_kiwibd_io_t readed); - -// Manually set amount of bytes programmed -int lfs3_kiwibd_setproged(const struct lfs3_cfg *cfg, - lfs3_kiwibd_io_t proged); - -// Manually set amount of bytes erased -int lfs3_kiwibd_seterased(const struct lfs3_cfg *cfg, - lfs3_kiwibd_io_t erased); - #endif diff --git a/runners/bench_defines.h b/runners/bench_defines.h index e5e64d19..a7ba00b0 100644 --- a/runners/bench_defines.h +++ b/runners/bench_defines.h @@ -25,6 +25,42 @@ BENCH_DEFINE(CRYSTAL_THRESH, BLOCK_SIZE/8 ) BENCH_DEFINE(LOOKGBMAP_THRESH, BLOCK_COUNT/4 ) BENCH_DEFINE(ERASE_VALUE, 0xff ) + // the default timings here are based on NOR flash, specifically + // w25q64jv: + // + // https://www.winbond.com/resource-files/W25Q256JV%20SPI%20RevQ%2002072025%20Plus.pdf + // + // note one thing unique to NOR flash is the extreme erase cost + // + // FR=104 MHz, quad prog (9.6 ns * 8/4) + // => +~19 ns for bus (not read!) + // + // readed=40ns/B fR=50 MHz, quad read (20 ns * 8/4) + // progged=1582ns/B tPP=0.4 ms, page=256 (0.4 ms / 256 + bus) + // erased=10986ns/B tSE=45 ms, sector=4096 (45 ms / 4096) + // + // reads=0ns (no transaction cost) + // progs=400000ns tPP=0.4 ms, page=256 + // erases=45000000ns tSE=45 ms, sector=4096 + // readed=40ns/B fR=50 MHz, quad read (20 ns * 8/4) + // progged=1484ns/B tPP=0.4 ms (((4096/256)*0.4 ms - 0.4 ms)/4096 + bus) + // erased=0ns/B (no per-byte cost) + // + #ifdef BENCH_SIMPLE + BENCH_DEFINE(READS_TIMING, 0 ) + BENCH_DEFINE(PROGS_TIMING, 0 ) + BENCH_DEFINE(ERASES_TIMING, 0 ) + BENCH_DEFINE(READED_TIMING, 40 ) + BENCH_DEFINE(PROGGED_TIMING, 1582 ) + BENCH_DEFINE(ERASED_TIMING, 10986 ) + #else + BENCH_DEFINE(READS_TIMING, 0 ) + BENCH_DEFINE(PROGS_TIMING, 400000 ) + BENCH_DEFINE(ERASES_TIMING, 45000000 ) + BENCH_DEFINE(READED_TIMING, 40 ) + BENCH_DEFINE(PROGGED_TIMING, 1484 ) + BENCH_DEFINE(ERASED_TIMING, 0 ) + #endif BENCH_DEFINE(ERASE_CYCLES, 0 ) BENCH_DEFINE(BADBLOCK_BEHAVIOR, LFS3_EMUBD_BADBLOCK_PROGERROR ) BENCH_DEFINE(POWERLOSS_BEHAVIOR, LFS3_EMUBD_POWERLOSS_ATOMIC ) @@ -65,6 +101,12 @@ // struct lfs3_*bd_cfg fields #ifdef BENCH_BDCFG BENCH_BDCFG(erase_value, ERASE_VALUE ) + BENCH_BDCFG(reads_timing, READS_TIMING ) + BENCH_BDCFG(progs_timing, PROGS_TIMING ) + BENCH_BDCFG(erases_timing, ERASES_TIMING ) + BENCH_BDCFG(readed_timing, READED_TIMING ) + BENCH_BDCFG(progged_timing, PROGGED_TIMING ) + BENCH_BDCFG(erased_timing, ERASED_TIMING ) BENCH_BDCFG(erase_cycles, ERASE_CYCLES ) BENCH_BDCFG(badblock_behavior, BADBLOCK_BEHAVIOR ) BENCH_BDCFG(powerloss_behavior, POWERLOSS_BEHAVIOR ) diff --git a/runners/bench_runner.c b/runners/bench_runner.c index 3c7eac6b..4bb2594b 100644 --- a/runners/bench_runner.c +++ b/runners/bench_runner.c @@ -436,9 +436,9 @@ FILE *bench_trace_file = NULL; uint32_t bench_trace_cycles = 0; uint64_t bench_trace_time = 0; uint64_t bench_trace_open_time = 0; -lfs3_emubd_sleep_t bench_read_sleep = 0.0; -lfs3_emubd_sleep_t bench_prog_sleep = 0.0; -lfs3_emubd_sleep_t bench_erase_sleep = 0.0; +lfs3_emubd_ns_t bench_read_sleep = 0.0; +lfs3_emubd_ns_t bench_prog_sleep = 0.0; +lfs3_emubd_ns_t bench_erase_sleep = 0.0; // this determines both the backtrace buffer and the trace printf buffer, if // trace ends up interleaved or truncated this may need to be increased @@ -604,9 +604,13 @@ void bench_permutation(size_t i, uint32_t *buffer, size_t size) { typedef struct bench_record { const char *m; uintmax_t n; + lfs3_emubd_io_t last_reads; + lfs3_emubd_io_t last_progs; + lfs3_emubd_io_t last_erases; lfs3_emubd_io_t last_readed; - lfs3_emubd_io_t last_proged; + lfs3_emubd_io_t last_progged; lfs3_emubd_io_t last_erased; + lfs3_emubd_ns_t last_simtime; } bench_record_t; static struct lfs3_cfg *bench_cfg = NULL; @@ -622,12 +626,20 @@ void bench_reset(struct lfs3_cfg *cfg) { void bench_start(const char *m, uintmax_t n) { // measure current read/prog/erase assert(bench_cfg); + lfs3_emubd_sio_t reads = lfs3_emubd_reads(bench_cfg); + assert(reads >= 0); + lfs3_emubd_sio_t progs = lfs3_emubd_progs(bench_cfg); + assert(progs >= 0); + lfs3_emubd_sio_t erases = lfs3_emubd_erases(bench_cfg); + assert(erases >= 0); lfs3_emubd_sio_t readed = lfs3_emubd_readed(bench_cfg); assert(readed >= 0); - lfs3_emubd_sio_t proged = lfs3_emubd_proged(bench_cfg); - assert(proged >= 0); + lfs3_emubd_sio_t progged = lfs3_emubd_progged(bench_cfg); + assert(progged >= 0); lfs3_emubd_sio_t erased = lfs3_emubd_erased(bench_cfg); assert(erased >= 0); + // note this can error if no timings provided + lfs3_emubd_sns_t simtime = lfs3_emubd_simtime(bench_cfg); // allocate a new record bench_record_t *record = mappend( @@ -637,31 +649,64 @@ void bench_start(const char *m, uintmax_t n) { &bench_record_capacity); record->m = m; record->n = n; + record->last_reads = reads; + record->last_progs = progs; + record->last_erases = erases; record->last_readed = readed; - record->last_proged = proged; + record->last_progged = progged; record->last_erased = erased; + record->last_simtime = simtime; } void bench_stop(const char *m) { // measure current read/prog/erase assert(bench_cfg); + lfs3_emubd_sio_t reads = lfs3_emubd_reads(bench_cfg); + assert(reads >= 0); + lfs3_emubd_sio_t progs = lfs3_emubd_progs(bench_cfg); + assert(progs >= 0); + lfs3_emubd_sio_t erases = lfs3_emubd_erases(bench_cfg); + assert(erases >= 0); lfs3_emubd_sio_t readed = lfs3_emubd_readed(bench_cfg); assert(readed >= 0); - lfs3_emubd_sio_t proged = lfs3_emubd_proged(bench_cfg); - assert(proged >= 0); + lfs3_emubd_sio_t progged = lfs3_emubd_progged(bench_cfg); + assert(progged >= 0); lfs3_emubd_sio_t erased = lfs3_emubd_erased(bench_cfg); assert(erased >= 0); + // note this can error if no timings provided + lfs3_emubd_sns_t simtime = lfs3_emubd_simtime(bench_cfg); // find our record for (size_t i = 0; i < bench_record_count; i++) { if (strcmp(bench_records[i].m, m) == 0) { // print results - printf("benched %s %jd %"PRIu64" %"PRIu64" %"PRIu64"\n", - bench_records[i].m, - bench_records[i].n, - readed - bench_records[i].last_readed, - proged - bench_records[i].last_proged, - erased - bench_records[i].last_erased); + if (simtime >= 0) { + printf("benched %s %jd " + "%"PRIu64" %"PRIu64" %"PRIu64" " + "%"PRIu64" %"PRIu64" %"PRIu64" " + "%"PRIu64"\n", + bench_records[i].m, + bench_records[i].n, + reads - bench_records[i].last_reads, + progs - bench_records[i].last_progs, + erases - bench_records[i].last_erases, + readed - bench_records[i].last_readed, + progged - bench_records[i].last_progged, + erased - bench_records[i].last_erased, + simtime - bench_records[i].last_simtime); + } else { + printf("benched %s %jd " + "%"PRIu64" %"PRIu64" %"PRIu64" " + "%"PRIu64" %"PRIu64" %"PRIu64"\n", + bench_records[i].m, + bench_records[i].n, + reads - bench_records[i].last_reads, + progs - bench_records[i].last_progs, + erases - bench_records[i].last_erases, + readed - bench_records[i].last_readed, + progged - bench_records[i].last_progged, + erased - bench_records[i].last_erased); + } // remove our record memmove(&bench_records[i], diff --git a/runners/test_runner.c b/runners/test_runner.c index 4449029a..bdb1bb5f 100644 --- a/runners/test_runner.c +++ b/runners/test_runner.c @@ -447,9 +447,9 @@ FILE *test_trace_file = NULL; uint32_t test_trace_cycles = 0; uint64_t test_trace_time = 0; uint64_t test_trace_open_time = 0; -lfs3_emubd_sleep_t test_read_sleep = 0.0; -lfs3_emubd_sleep_t test_prog_sleep = 0.0; -lfs3_emubd_sleep_t test_erase_sleep = 0.0; +lfs3_emubd_ns_t test_read_sleep = 0.0; +lfs3_emubd_ns_t test_prog_sleep = 0.0; +lfs3_emubd_ns_t test_erase_sleep = 0.0; volatile size_t TEST_PLS = 0; diff --git a/scripts/bench.py b/scripts/bench.py index d9ad7646..54eb2d6e 100755 --- a/scripts/bench.py +++ b/scripts/bench.py @@ -1081,7 +1081,7 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args): passed_perms = 0 failed_perms = 0 readed = 0 - proged = 0 + progged = 0 erased = 0 failures = [] killed = False @@ -1094,9 +1094,15 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args): '|' '(?Pbenched)' ' (?P[^\s]+)' ' (?P\d+)' - '(?: (?P[\d\.]+))?' - '(?: (?P[\d\.]+))?' - '(?: (?P[\d\.]+))?' + '(?:' + '(?:' + ' (?P[\d\.]+)' + ' (?P[\d\.]+)' + ' (?P[\d\.]+)' ')?' + ' (?P[\d\.]+)' + ' (?P[\d\.]+)' + ' (?P[\d\.]+)' ')?' + '(?: (?P[\d\.]+))?' ')$') locals = th.local() children = set() @@ -1106,7 +1112,7 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args): nonlocal passed_case_perms nonlocal passed_perms nonlocal readed - nonlocal proged + nonlocal progged nonlocal erased nonlocal locals @@ -1127,9 +1133,13 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args): last_defines = None # fetched on demand last_stdout = co.deque(maxlen=args.get('context', 5) + 1) last_assert = None + creads = co.defaultdict(lambda: 0) + cprogs = co.defaultdict(lambda: 0) + cerases = co.defaultdict(lambda: 0) creaded = co.defaultdict(lambda: 0) - cproged = co.defaultdict(lambda: 0) + cprogged = co.defaultdict(lambda: 0) cerased = co.defaultdict(lambda: 0) + csimtime = co.defaultdict(lambda: 0) try: while True: # parse a line for state changes @@ -1160,9 +1170,13 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args): last_defines = None last_stdout.clear() last_assert = None + creads.clear() + cprogs.clear() + cerases.clear() creaded.clear() - cproged.clear() + cprogged.clear() cerased.clear() + csimtime.clear() elif op == 'finished': # force a failure if args.get('fail'): @@ -1195,13 +1209,21 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args): return float(v) else: return int(v) - readed_ = dat(m.group('readed')) - proged_ = dat(m.group('proged')) - erased_ = dat(m.group('erased')) + reads_ = dat(m.group('reads')) + progs_ = dat(m.group('progs')) + erases_ = dat(m.group('erases')) + readed_ = dat(m.group('readed')) + progged_ = dat(m.group('progged')) + erased_ = dat(m.group('erased')) + simtime_ = dat(m.group('simtime')) # keep track of cumulative measurements - creaded[m_] += readed_ - cproged[m_] += proged_ - cerased[m_] += erased_ + creads[m_] += reads_ + cprogs[m_] += progs_ + cerases[m_] += erases_ + creaded[m_] += readed_ + cprogged[m_] += progged_ + cerased[m_] += erased_ + csimtime[m_] += simtime_ if output_: # fetch defines if needed, only do this at most # once per perm @@ -1216,15 +1238,23 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args): **last_defines, 'm': m_, 'n': n_, + 'bench_reads': reads_, + 'bench_progs': progs_, + 'bench_erases': erases_, 'bench_readed': readed_, - 'bench_proged': proged_, + 'bench_progged': progged_, 'bench_erased': erased_, + 'bench_simtime': simtime_, + 'bench_creads': creads[m_], + 'bench_cprogs': cprogs[m_], + 'bench_cerases': cerases[m_], 'bench_creaded': creaded[m_], - 'bench_cproged': cproged[m_], - 'bench_cerased': cerased[m_]}) + 'bench_cprogged': cprogged[m_], + 'bench_cerased': cerased[m_], + 'bench_csimtime': csimtime[m_]}) # keep track of total for summary readed += readed_ - proged += proged_ + progged += progged_ erased += erased_ except KeyboardInterrupt: proc.kill() @@ -1357,7 +1387,7 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args): passed_perms, failed_perms, readed, - proged, + progged, erased, failures, killed) @@ -1401,12 +1431,20 @@ def run(runner, bench_ids=[], **args): ['suite', 'case'], # defines go here ['m', 'n', + 'bench_reads', + 'bench_progs', + 'bench_erases', 'bench_readed', - 'bench_proged', + 'bench_progged', 'bench_erased', + 'bench_simtime', + 'bench_creads', + 'bench_cprogs', + 'bench_cerases', 'bench_creaded', - 'bench_cproged', - 'bench_cerased']) + 'bench_cprogged', + 'bench_cerased', + 'bench_csimtime']) # measure runtime start = time.time() @@ -1416,7 +1454,7 @@ def run(runner, bench_ids=[], **args): passed = 0 failed = 0 readed = 0 - proged = 0 + progged = 0 erased = 0 failures = [] for by in (bench_ids if bench_ids else [None]): @@ -1425,7 +1463,7 @@ def run(runner, bench_ids=[], **args): passed_, failed_, readed_, - proged_, + progged_, erased_, failures_, killed) = run_stage( @@ -1438,11 +1476,11 @@ def run(runner, bench_ids=[], **args): **args) # collect passes/failures expected += expected_ - passed += passed_ - failed += failed_ - readed += readed_ - proged += proged_ - erased += erased_ + passed += passed_ + failed += failed_ + readed += readed_ + progged += progged_ + erased += erased_ # do not store more failures than we need to, otherwise we # quickly explode RAM when a common bug fails a bunch of cases failures.extend(failures_[:max( @@ -1475,7 +1513,7 @@ def run(runner, bench_ids=[], **args): '\x1b[m' if args['color'] else '', ', '.join(filter(None, [ '%d readed' % readed, - '%d proged' % proged, + '%d progged' % progged, '%d erased' % erased, 'in %.2fs' % (stop-start)])))) print() diff --git a/tests/test_badblocks.toml b/tests/test_badblocks.toml index d604c60c..e96b2eb8 100644 --- a/tests/test_badblocks.toml +++ b/tests/test_badblocks.toml @@ -48,7 +48,7 @@ code = ''' lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; printf("--- badblock: 0x%x ---\n", badblock); // mark our badblock as bad - lfs3_emubd_markbad(CFG, badblock) => 0; + lfs3_emubd_mkbad(CFG, badblock) => 0; // test creating a btree lfs3_t lfs3; @@ -131,7 +131,7 @@ code = ''' lfs3_deinit(&lfs3) => 0; // reset badblock - lfs3_emubd_markgood(CFG, badblock) => 0; + lfs3_emubd_mkgood(CFG, badblock) => 0; } ''' @@ -157,7 +157,7 @@ code = ''' lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; printf("--- badblock: 0x%x ---\n", badblock); // mark our badblock as bad - lfs3_emubd_markbad(CFG, badblock) => 0; + lfs3_emubd_mkbad(CFG, badblock) => 0; // test creating directories lfs3_t lfs3; @@ -246,7 +246,7 @@ code = ''' lfs3_unmount(&lfs3) => 0; // reset badblock - lfs3_emubd_markgood(CFG, badblock) => 0; + lfs3_emubd_mkgood(CFG, badblock) => 0; } ''' @@ -275,7 +275,7 @@ code = ''' lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; printf("--- badblock: 0x%x ---\n", badblock); // mark our badblock as bad - lfs3_emubd_markbad(CFG, badblock) => 0; + lfs3_emubd_mkbad(CFG, badblock) => 0; // test fuzz with dirs lfs3_t lfs3; @@ -432,7 +432,7 @@ code = ''' lfs3_unmount(&lfs3) => 0; // reset badblock - lfs3_emubd_markgood(CFG, badblock) => 0; + lfs3_emubd_mkgood(CFG, badblock) => 0; } ''' @@ -470,7 +470,7 @@ code = ''' lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; printf("--- badblock: 0x%x ---\n", badblock); // mark our badblock as bad - lfs3_emubd_markbad(CFG, badblock) => 0; + lfs3_emubd_mkbad(CFG, badblock) => 0; // test creating files lfs3_t lfs3; @@ -543,7 +543,7 @@ code = ''' lfs3_unmount(&lfs3) => 0; // reset badblock - lfs3_emubd_markgood(CFG, badblock) => 0; + lfs3_emubd_mkgood(CFG, badblock) => 0; } ''' @@ -584,7 +584,7 @@ code = ''' lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; printf("--- badblock: 0x%x ---\n", badblock); // mark our badblock as bad - lfs3_emubd_markbad(CFG, badblock) => 0; + lfs3_emubd_mkbad(CFG, badblock) => 0; // test fuzz with files lfs3_t lfs3; @@ -793,7 +793,7 @@ code = ''' lfs3_unmount(&lfs3) => 0; // reset badblock - lfs3_emubd_markgood(CFG, badblock) => 0; + lfs3_emubd_mkgood(CFG, badblock) => 0; } ''' @@ -841,7 +841,7 @@ code = ''' lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; printf("--- badblock: 0x%x ---\n", badblock); // mark our badblock as bad - lfs3_emubd_markbad(CFG, badblock) => 0; + lfs3_emubd_mkbad(CFG, badblock) => 0; // test with complex file writes lfs3_t lfs3; @@ -963,7 +963,7 @@ code = ''' lfs3_unmount(&lfs3) => 0; // reset badblock - lfs3_emubd_markgood(CFG, badblock) => 0; + lfs3_emubd_mkgood(CFG, badblock) => 0; } ''' @@ -1006,7 +1006,7 @@ code = ''' lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; printf("--- badblock: 0x%x ---\n", badblock); // mark our badblock as bad - lfs3_emubd_markbad(CFG, badblock) => 0; + lfs3_emubd_mkbad(CFG, badblock) => 0; // test with uncreats, zombies, etc lfs3_t lfs3; @@ -1419,7 +1419,7 @@ code = ''' lfs3_unmount(&lfs3) => 0; // reset badblock - lfs3_emubd_markgood(CFG, badblock) => 0; + lfs3_emubd_mkgood(CFG, badblock) => 0; } ''' @@ -1462,7 +1462,7 @@ code = ''' lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; printf("--- badblock: 0x%x ---\n", badblock); // mark our badblock as bad - lfs3_emubd_markbad(CFG, badblock) => 0; + lfs3_emubd_mkbad(CFG, badblock) => 0; // test with uncreats, zombies, dirs, etc lfs3_t lfs3; @@ -1971,7 +1971,7 @@ code = ''' lfs3_unmount(&lfs3) => 0; // reset badblock - lfs3_emubd_markgood(CFG, badblock) => 0; + lfs3_emubd_mkgood(CFG, badblock) => 0; } ''' @@ -2009,9 +2009,9 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - lfs3_emubd_markbad(CFG, i) => 0; + lfs3_emubd_mkbad(CFG, i) => 0; } else { - lfs3_emubd_markbad(CFG, i + BLOCK_COUNT/2) => 0; + lfs3_emubd_mkbad(CFG, i + BLOCK_COUNT/2) => 0; } } @@ -2116,11 +2116,11 @@ code = ''' // mark our badblock as bad if (!MIRROR) { if (i >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, i) => 0; + lfs3_emubd_mkbad(CFG, i) => 0; } } else { if (i+BLOCK_COUNT/2 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0; + lfs3_emubd_mkbad(CFG, i+BLOCK_COUNT/2) => 0; } } } @@ -2235,11 +2235,11 @@ code = ''' // mark our badblock as bad if (!MIRROR) { if (i >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, i) => 0; + lfs3_emubd_mkbad(CFG, i) => 0; } } else { if (i+BLOCK_COUNT/2 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0; + lfs3_emubd_mkbad(CFG, i+BLOCK_COUNT/2) => 0; } } } @@ -2431,11 +2431,11 @@ code = ''' // mark our badblock as bad if (!MIRROR) { if (i >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, i) => 0; + lfs3_emubd_mkbad(CFG, i) => 0; } } else { if (i+BLOCK_COUNT/2 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0; + lfs3_emubd_mkbad(CFG, i+BLOCK_COUNT/2) => 0; } } } @@ -2546,11 +2546,11 @@ code = ''' // mark our badblock as bad if (!MIRROR) { if (i >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, i) => 0; + lfs3_emubd_mkbad(CFG, i) => 0; } } else { if (i+BLOCK_COUNT/2 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0; + lfs3_emubd_mkbad(CFG, i+BLOCK_COUNT/2) => 0; } } } @@ -2804,11 +2804,11 @@ code = ''' // mark our badblock as bad if (!MIRROR) { if (i >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, i) => 0; + lfs3_emubd_mkbad(CFG, i) => 0; } } else { if (i+BLOCK_COUNT/2 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0; + lfs3_emubd_mkbad(CFG, i+BLOCK_COUNT/2) => 0; } } } @@ -2970,11 +2970,11 @@ code = ''' // mark our badblock as bad if (!MIRROR) { if (i >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, i) => 0; + lfs3_emubd_mkbad(CFG, i) => 0; } } else { if (i+BLOCK_COUNT/2 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0; + lfs3_emubd_mkbad(CFG, i+BLOCK_COUNT/2) => 0; } } } @@ -3427,11 +3427,11 @@ code = ''' // mark our badblock as bad if (!MIRROR) { if (i >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, i) => 0; + lfs3_emubd_mkbad(CFG, i) => 0; } } else { if (i+BLOCK_COUNT/2 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0; + lfs3_emubd_mkbad(CFG, i+BLOCK_COUNT/2) => 0; } } } @@ -3976,9 +3976,9 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - lfs3_emubd_markbad(CFG, 2*i+0) => 0; + lfs3_emubd_mkbad(CFG, 2*i+0) => 0; } else { - lfs3_emubd_markbad(CFG, 2*i+1) => 0; + lfs3_emubd_mkbad(CFG, 2*i+1) => 0; } } @@ -4083,11 +4083,11 @@ code = ''' // mark our badblock as bad if (!MIRROR) { if (2*i+0 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, 2*i+0) => 0; + lfs3_emubd_mkbad(CFG, 2*i+0) => 0; } } else { if (2*i+1 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, 2*i+1) => 0; + lfs3_emubd_mkbad(CFG, 2*i+1) => 0; } } } @@ -4202,11 +4202,11 @@ code = ''' // mark our badblock as bad if (!MIRROR) { if (2*i+0 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, 2*i+0) => 0; + lfs3_emubd_mkbad(CFG, 2*i+0) => 0; } } else { if (2*i+1 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, 2*i+1) => 0; + lfs3_emubd_mkbad(CFG, 2*i+1) => 0; } } } @@ -4398,11 +4398,11 @@ code = ''' // mark our badblock as bad if (!MIRROR) { if (2*i+0 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, 2*i+0) => 0; + lfs3_emubd_mkbad(CFG, 2*i+0) => 0; } } else { if (2*i+1 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, 2*i+1) => 0; + lfs3_emubd_mkbad(CFG, 2*i+1) => 0; } } } @@ -4513,11 +4513,11 @@ code = ''' // mark our badblock as bad if (!MIRROR) { if (2*i+0 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, 2*i+0) => 0; + lfs3_emubd_mkbad(CFG, 2*i+0) => 0; } } else { if (2*i+1 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, 2*i+1) => 0; + lfs3_emubd_mkbad(CFG, 2*i+1) => 0; } } } @@ -4771,11 +4771,11 @@ code = ''' // mark our badblock as bad if (!MIRROR) { if (2*i+0 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, 2*i+0) => 0; + lfs3_emubd_mkbad(CFG, 2*i+0) => 0; } } else { if (2*i+1 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, 2*i+1) => 0; + lfs3_emubd_mkbad(CFG, 2*i+1) => 0; } } } @@ -4935,11 +4935,11 @@ code = ''' // mark our badblock as bad if (!MIRROR) { if (2*i+0 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, 2*i+0) => 0; + lfs3_emubd_mkbad(CFG, 2*i+0) => 0; } } else { if (2*i+1 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, 2*i+1) => 0; + lfs3_emubd_mkbad(CFG, 2*i+1) => 0; } } } @@ -5392,11 +5392,11 @@ code = ''' // mark our badblock as bad if (!MIRROR) { if (2*i+0 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, 2*i+0) => 0; + lfs3_emubd_mkbad(CFG, 2*i+0) => 0; } } else { if (2*i+1 >= FORMAT_BLOCK_COUNT) { - lfs3_emubd_markbad(CFG, 2*i+1) => 0; + lfs3_emubd_mkbad(CFG, 2*i+1) => 0; } } } @@ -5924,10 +5924,10 @@ defines.BADBLOCK_BEHAVIOR = [ ] code = ''' if (BADBLOCKS & 0x1) { - lfs3_emubd_markbad(CFG, 0) => 0; + lfs3_emubd_mkbad(CFG, 0) => 0; } if (BADBLOCKS & 0x2) { - lfs3_emubd_markbad(CFG, 1) => 0; + lfs3_emubd_mkbad(CFG, 1) => 0; } lfs3_t lfs3; @@ -5955,10 +5955,10 @@ code = ''' CFG) => 0; if (BADBLOCKS & 0x1) { - lfs3_emubd_markbad(CFG, 0) => 0; + lfs3_emubd_mkbad(CFG, 0) => 0; } if (BADBLOCKS & 0x2) { - lfs3_emubd_markbad(CFG, 1) => 0; + lfs3_emubd_mkbad(CFG, 1) => 0; } lfs3_mount(&lfs3, diff --git a/tests/test_ck.toml b/tests/test_ck.toml index 0ccbd0fc..31033fa0 100644 --- a/tests/test_ck.toml +++ b/tests/test_ck.toml @@ -1493,7 +1493,7 @@ code = ''' (lfs3_size_t)BADBLOCK, badbit/8, badbit, badbit/8, badbit%8); // mark our badbit as bad - lfs3_emubd_markbadbit(CFG, BADBLOCK, badbit) => 0; + lfs3_emubd_mkbadbit(CFG, BADBLOCK, badbit) => 0; // formatting the filesystem may already find the bit error lfs3_t lfs3; @@ -1552,7 +1552,7 @@ code = ''' corrupt:; // reset badbit - lfs3_emubd_markgood(CFG, BADBLOCK) => 0; + lfs3_emubd_mkgood(CFG, BADBLOCK) => 0; } ''' @@ -1610,7 +1610,7 @@ code = ''' badblock, badbit/8, badbit, badbit/8, badbit%8); // mark our badbit as bad - lfs3_emubd_markbadbit(CFG, badblock, badbit) => 0; + lfs3_emubd_mkbadbit(CFG, badblock, badbit) => 0; // format lfs3_t lfs3; @@ -1660,7 +1660,7 @@ code = ''' lfs3_unmount(&lfs3) => 0; // reset badbit - lfs3_emubd_markgood(CFG, badblock) => 0; + lfs3_emubd_mkgood(CFG, badblock) => 0; } ''' @@ -1721,7 +1721,7 @@ code = ''' badblock, badbit/8, badbit, badbit/8, badbit%8); // mark our badbit as bad - lfs3_emubd_markbadbit(CFG, badblock, badbit) => 0; + lfs3_emubd_mkbadbit(CFG, badblock, badbit) => 0; // format lfs3_t lfs3; @@ -1771,7 +1771,7 @@ code = ''' lfs3_unmount(&lfs3) => 0; // reset badbit - lfs3_emubd_markgood(CFG, badblock) => 0; + lfs3_emubd_mkgood(CFG, badblock) => 0; } ''' @@ -1816,8 +1816,8 @@ code = ''' badbit_/8, badbit_%8); // mark our badbits as bad - lfs3_emubd_markbadbit(CFG, BADBLOCK, badbit) => 0; - lfs3_emubd_markbadbit(CFG, BADBLOCK_, badbit_) => 0; + lfs3_emubd_mkbadbit(CFG, BADBLOCK, badbit) => 0; + lfs3_emubd_mkbadbit(CFG, BADBLOCK_, badbit_) => 0; // keep track of open files so we clean up correctly lfs3_file_t files[N]; @@ -1980,8 +1980,8 @@ code = ''' corrupt:; // reset badbits - lfs3_emubd_markgood(CFG, BADBLOCK) => 0; - lfs3_emubd_markgood(CFG, BADBLOCK_) => 0; + lfs3_emubd_mkgood(CFG, BADBLOCK) => 0; + lfs3_emubd_mkgood(CFG, BADBLOCK_) => 0; } ''' @@ -2063,7 +2063,7 @@ code = ''' corrupt:; // reset badbit - lfs3_emubd_markgood(CFG, BADBLOCK) => 0; + lfs3_emubd_mkgood(CFG, BADBLOCK) => 0; } ''' @@ -2171,7 +2171,7 @@ code = ''' lfs3_unmount(&lfs3) => 0; // reset badbit - lfs3_emubd_markgood(CFG, badblock) => 0; + lfs3_emubd_mkgood(CFG, badblock) => 0; } ''' @@ -2282,7 +2282,7 @@ code = ''' lfs3_unmount(&lfs3) => 0; // reset badbit - lfs3_emubd_markgood(CFG, badblock) => 0; + lfs3_emubd_mkgood(CFG, badblock) => 0; } ''' @@ -2346,7 +2346,7 @@ code = ''' (lfs3_size_t)BADBLOCK, badbit/8, badbit, badbit/8, badbit%8); // mark our badbit as bad - lfs3_emubd_markbadbit(CFG, BADBLOCK, badbit) => 0; + lfs3_emubd_mkbadbit(CFG, BADBLOCK, badbit) => 0; // With metastability, basically any filesystem operation can // return LFS3_ERR_CORRUPT. This is ok, what we're really testing @@ -2430,7 +2430,7 @@ code = ''' corrupt:; // reset badbit - lfs3_emubd_markgood(CFG, BADBLOCK) => 0; + lfs3_emubd_mkgood(CFG, BADBLOCK) => 0; } ''' @@ -2504,7 +2504,7 @@ code = ''' badblock, badbit/8, badbit, badbit/8, badbit%8); // mark our badbit as bad - lfs3_emubd_markbadbit(CFG, badblock, badbit) => 0; + lfs3_emubd_mkbadbit(CFG, badblock, badbit) => 0; // With metastability, basically any filesystem operation can // return LFS3_ERR_CORRUPT. This is ok, what we're really testing @@ -2573,7 +2573,7 @@ code = ''' lfs3_unmount(&lfs3) => 0; // reset badbit - lfs3_emubd_markgood(CFG, badblock) => 0; + lfs3_emubd_mkgood(CFG, badblock) => 0; } ''' @@ -2641,7 +2641,7 @@ code = ''' badblock, badbit/8, badbit, badbit/8, badbit%8); // mark our badbit as bad - lfs3_emubd_markbadbit(CFG, badblock, badbit) => 0; + lfs3_emubd_mkbadbit(CFG, badblock, badbit) => 0; // With metastability, basically any filesystem operation can // return LFS3_ERR_CORRUPT. This is ok, what we're really testing @@ -2710,7 +2710,7 @@ code = ''' lfs3_unmount(&lfs3) => 0; // reset badbit - lfs3_emubd_markgood(CFG, badblock) => 0; + lfs3_emubd_mkgood(CFG, badblock) => 0; } ''' @@ -2818,7 +2818,7 @@ code = ''' // bit differently // mark our badblock as bad - lfs3_emubd_markbad(CFG, badblock) => 0; + lfs3_emubd_mkbad(CFG, badblock) => 0; // manually flipping? flip all badbits in badblocks if (BADBLOCK_BEHAVIOR == LFS3_EMUBD_BADBLOCK_MANUAL) { @@ -3136,7 +3136,7 @@ code = ''' // bit differently // mark our badblock as bad - lfs3_emubd_markbad(CFG, badblock) => 0; + lfs3_emubd_mkbad(CFG, badblock) => 0; // manually flipping? flip all badbits in badblocks if (BADBLOCK_BEHAVIOR == LFS3_EMUBD_BADBLOCK_MANUAL) { @@ -3552,7 +3552,7 @@ code = ''' // bit differently // mark our badblock as bad - lfs3_emubd_markbad(CFG, badblock) => 0; + lfs3_emubd_mkbad(CFG, badblock) => 0; // manually flipping? flip all badbits in badblocks if (BADBLOCK_BEHAVIOR == LFS3_EMUBD_BADBLOCK_MANUAL) { @@ -3837,7 +3837,7 @@ code = ''' // bit differently // mark our badblock as bad - lfs3_emubd_markbad(CFG, badblock) => 0; + lfs3_emubd_mkbad(CFG, badblock) => 0; // manually flipping? flip all badbits in badblocks if (BADBLOCK_BEHAVIOR == LFS3_EMUBD_BADBLOCK_MANUAL) { @@ -4441,7 +4441,7 @@ code = ''' // bit differently // mark our badblock as bad - lfs3_emubd_markbad(CFG, badblock) => 0; + lfs3_emubd_mkbad(CFG, badblock) => 0; // manually flipping? flip all badbits in badblocks if (BADBLOCK_BEHAVIOR == LFS3_EMUBD_BADBLOCK_MANUAL) {