diff options
author | Christopher Haster <geky@geky.net> | 2022-11-12 01:00:10 +0300 |
---|---|---|
committer | Christopher Haster <geky@geky.net> | 2022-11-15 22:42:07 +0300 |
commit | 1a07c2ce0d4613094b6b72d1416f3d6034933cba (patch) | |
tree | 695a6308660bc4fff4e9943956fcaab3ed16f0cc | |
parent | 6fce9e51568a280116b519fe986e171a2b34bd5c (diff) |
A number of small script fixes/tweaks from usage
- Fixed prettyasserts.py parsing when '->' is in expr
- Made prettyasserts.py failures not crash (yay dynamic typing)
- Fixed the initial state of the emubd disk file to match the internal
state in RAM
- Fixed true/false getting changed to True/False in test.py/bench.py
defines
- Fixed accidental substring matching in plot.py's --by comparison
- Fixed a missed LFS_BLOCk_CYCLES in test_superblocks.toml that was
missed
- Changed test.py/bench.py -v to only show commands being run
Including the test output is still possible with test.py -v -O-, making
the implicit inclusion redundant and noisy.
- Added license comments to bench_runner/test_runner
-rw-r--r-- | bd/lfs_emubd.c | 13 | ||||
-rw-r--r-- | runners/bench_runner.c | 7 | ||||
-rw-r--r-- | runners/bench_runner.h | 6 | ||||
-rw-r--r-- | runners/test_runner.c | 7 | ||||
-rw-r--r-- | runners/test_runner.h | 6 | ||||
-rwxr-xr-x | scripts/bench.py | 4 | ||||
-rwxr-xr-x | scripts/plot.py | 2 | ||||
-rwxr-xr-x | scripts/plotmpl.py | 2 | ||||
-rwxr-xr-x | scripts/prettyasserts.py | 6 | ||||
-rwxr-xr-x | scripts/test.py | 4 | ||||
-rw-r--r-- | tests/test_superblocks.toml | 6 |
11 files changed, 50 insertions, 13 deletions
diff --git a/bd/lfs_emubd.c b/bd/lfs_emubd.c index cf82f56..8b42ac5 100644 --- a/bd/lfs_emubd.c +++ b/bd/lfs_emubd.c @@ -164,6 +164,19 @@ int lfs_emubd_createcfg(const struct lfs_config *cfg, const char *path, memset(bd->disk->scratch, bd->cfg->erase_value, cfg->block_size); + + // go ahead and erase all of the disk, otherwise the file will not + // match our internal representation + for (size_t i = 0; i < cfg->block_count; i++) { + ssize_t res = write(bd->disk->fd, + bd->disk->scratch, + cfg->block_size); + if (res < 0) { + int err = -errno; + LFS_EMUBD_TRACE("lfs_emubd_create -> %d", err); + return err; + } + } } } diff --git a/runners/bench_runner.c b/runners/bench_runner.c index cb814dd..afb4c16 100644 --- a/runners/bench_runner.c +++ b/runners/bench_runner.c @@ -1,4 +1,9 @@ - +/* + * Runner for littlefs benchmarks + * + * Copyright (c) 2022, The littlefs authors. + * SPDX-License-Identifier: BSD-3-Clause + */ #ifndef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 199309L #endif diff --git a/runners/bench_runner.h b/runners/bench_runner.h index a33c31d..71ed5e3 100644 --- a/runners/bench_runner.h +++ b/runners/bench_runner.h @@ -1,3 +1,9 @@ +/* + * Runner for littlefs benchmarks + * + * Copyright (c) 2022, The littlefs authors. + * SPDX-License-Identifier: BSD-3-Clause + */ #ifndef BENCH_RUNNER_H #define BENCH_RUNNER_H diff --git a/runners/test_runner.c b/runners/test_runner.c index 076f625..ea0864d 100644 --- a/runners/test_runner.c +++ b/runners/test_runner.c @@ -1,4 +1,9 @@ - +/* + * Runner for littlefs tests + * + * Copyright (c) 2022, The littlefs authors. + * SPDX-License-Identifier: BSD-3-Clause + */ #ifndef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 199309L #endif diff --git a/runners/test_runner.h b/runners/test_runner.h index f956150..48e58dc 100644 --- a/runners/test_runner.h +++ b/runners/test_runner.h @@ -1,3 +1,9 @@ +/* + * Runner for littlefs tests + * + * Copyright (c) 2022, The littlefs authors. + * SPDX-License-Identifier: BSD-3-Clause + */ #ifndef TEST_RUNNER_H #define TEST_RUNNER_H diff --git a/scripts/bench.py b/scripts/bench.py index 225e523..13d8f08 100755 --- a/scripts/bench.py +++ b/scripts/bench.py @@ -118,6 +118,8 @@ class BenchCase: else: yield v_ # or a literal value + elif isinstance(v, bool): + yield 'true' if v else 'false' else: yield v @@ -817,8 +819,6 @@ def run_stage(name, runner_, ids, stdout_, trace_, output_, **args): stdout_.flush() except BrokenPipeError: pass - if args.get('verbose'): - sys.stdout.write(line) m = pattern.match(line) if m: diff --git a/scripts/plot.py b/scripts/plot.py index d2e6401..891e943 100755 --- a/scripts/plot.py +++ b/scripts/plot.py @@ -535,7 +535,7 @@ def datasets(results, by=None, x=None, y=None, define=[]): results, x_, y_, - [(by_, k_) for by_, k_ in zip(by, ks_)] + [(by_, {k_}) for by_, k_ in zip(by, ks_)] if by is not None else []) return datasets diff --git a/scripts/plotmpl.py b/scripts/plotmpl.py index 5228652..faea598 100755 --- a/scripts/plotmpl.py +++ b/scripts/plotmpl.py @@ -286,7 +286,7 @@ def datasets(results, by=None, x=None, y=None, define=[]): results, x_, y_, - [(by_, k_) for by_, k_ in zip(by, ks_)] + [(by_, {k_}) for by_, k_ in zip(by, ks_)] if by is not None else []) return datasets diff --git a/scripts/prettyasserts.py b/scripts/prettyasserts.py index b10fdda..3a62d36 100755 --- a/scripts/prettyasserts.py +++ b/scripts/prettyasserts.py @@ -39,6 +39,7 @@ LEXEMES = { 'cmp': CMP.keys(), 'logic': ['\&\&', '\|\|'], 'sep': [':', ';', '\{', '\}', ','], + 'op': ['->'], # specifically ops that conflict with cmp } @@ -330,7 +331,7 @@ def p_expr(p): except ParseFailure: p.pop(state) res.append(p.expect('assert')) - elif p.accept('string', None, 'ws'): + elif p.accept('string', 'op', 'ws', None): res.append(p.m) else: return ''.join(res) @@ -414,7 +415,8 @@ def main(input=None, output=None, pattern=[], limit=LIMIT): f.write(p.m) else: break - except ParseFailure as f: + except ParseFailure as e: + print('warning: %s' % e) pass for i in range(p.off, len(p.tokens)): diff --git a/scripts/test.py b/scripts/test.py index 5ceb420..929129a 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -121,6 +121,8 @@ class TestCase: else: yield v_ # or a literal value + elif isinstance(v, bool): + yield 'true' if v else 'false' else: yield v @@ -827,8 +829,6 @@ def run_stage(name, runner_, ids, stdout_, trace_, output_, **args): stdout_.flush() except BrokenPipeError: pass - if args.get('verbose'): - sys.stdout.write(line) m = pattern.match(line) if m: diff --git a/tests/test_superblocks.toml b/tests/test_superblocks.toml index d45d788..689bbcd 100644 --- a/tests/test_superblocks.toml +++ b/tests/test_superblocks.toml @@ -36,7 +36,7 @@ code = ''' # expanding superblock [cases.test_superblocks_expand] -defines.LFS_BLOCK_CYCLES = [32, 33, 1] +defines.BLOCK_CYCLES = [32, 33, 1] defines.N = [10, 100, 1000] code = ''' lfs_t lfs; @@ -70,7 +70,7 @@ code = ''' # expanding superblock with power cycle [cases.test_superblocks_expand_power_cycle] -defines.LFS_BLOCK_CYCLES = [32, 33, 1] +defines.BLOCK_CYCLES = [32, 33, 1] defines.N = [10, 100, 1000] code = ''' lfs_t lfs; @@ -108,7 +108,7 @@ code = ''' # reentrant expanding superblock [cases.test_superblocks_reentrant_expand] -defines.LFS_BLOCK_CYCLES = [2, 1] +defines.BLOCK_CYCLES = [2, 1] defines.N = 24 reentrant = true code = ''' |