Kaynağa Gözat

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
Christopher Haster 3 yıl önce
ebeveyn
işleme
1a07c2ce0d

+ 13 - 0
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;
+                }
+            }
         }
     }
 

+ 6 - 1
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

+ 6 - 0
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
 

+ 6 - 1
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

+ 6 - 0
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
 

+ 2 - 2
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:

+ 1 - 1
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

+ 1 - 1
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

+ 4 - 2
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)):

+ 2 - 2
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:

+ 3 - 3
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 = '''