Browse Source

Dropped permutation number for full leb16-encoded defines

This is probably how the test runner should have been implemented in the
first place, but it took a few tries to get here.

This makes it so the test identifier, which is a bit longer now, fully
encodes the state of the defines in the test. This removes the need for
the extra geometry field and allows reproduction of tests with custom
defines at runtime.

The test runner may have already seemed like a solved problem, but these
changes are really to enable repurposing the test runner as a bench
runner.
Christopher Haster 3 years ago
parent
commit
bfbe44e70d
3 changed files with 449 additions and 340 deletions
  1. 418 293
      runners/test_runner.c
  2. 11 6
      runners/test_runner.h
  3. 20 41
      scripts/test.py

File diff suppressed because it is too large
+ 418 - 293
runners/test_runner.c


+ 11 - 6
runners/test_runner.h

@@ -24,12 +24,17 @@ void test_trace(const char *fmt, ...);
 
 
 
 
 // generated test configurations
 // generated test configurations
+struct lfs_config;
+
 enum test_flags {
 enum test_flags {
     TEST_REENTRANT = 0x1,
     TEST_REENTRANT = 0x1,
 };
 };
 typedef uint8_t test_flags_t;
 typedef uint8_t test_flags_t;
 
 
-struct lfs_config;
+typedef struct test_define {
+    intmax_t (*cb)(void *data);
+    void *data;
+} test_define_t;
 
 
 struct test_case {
 struct test_case {
     const char *id;
     const char *id;
@@ -38,7 +43,7 @@ struct test_case {
     test_flags_t flags;
     test_flags_t flags;
     size_t permutations;
     size_t permutations;
 
 
-    intmax_t (*const *const *defines)(size_t);
+    const test_define_t *const *defines;
 
 
     bool (*filter)(void);
     bool (*filter)(void);
     void (*run)(struct lfs_config *cfg);
     void (*run)(struct lfs_config *cfg);
@@ -89,10 +94,10 @@ intmax_t test_define(size_t define);
 #define POWERLOSS_BEHAVIOR  test_define(POWERLOSS_BEHAVIOR_i)
 #define POWERLOSS_BEHAVIOR  test_define(POWERLOSS_BEHAVIOR_i)
 
 
 #define TEST_IMPLICIT_DEFINES \
 #define TEST_IMPLICIT_DEFINES \
-    TEST_DEFINE(READ_SIZE,          test_geometry->read_size) \
-    TEST_DEFINE(PROG_SIZE,          test_geometry->prog_size) \
-    TEST_DEFINE(BLOCK_SIZE,         test_geometry->block_size) \
-    TEST_DEFINE(BLOCK_COUNT,        test_geometry->block_count) \
+    TEST_DEFINE(READ_SIZE,          PROG_SIZE) \
+    TEST_DEFINE(PROG_SIZE,          BLOCK_SIZE) \
+    TEST_DEFINE(BLOCK_SIZE,         0) \
+    TEST_DEFINE(BLOCK_COUNT,        (1024*1024)/BLOCK_SIZE) \
     TEST_DEFINE(CACHE_SIZE,         lfs_max(64,lfs_max(READ_SIZE,PROG_SIZE))) \
     TEST_DEFINE(CACHE_SIZE,         lfs_max(64,lfs_max(READ_SIZE,PROG_SIZE))) \
     TEST_DEFINE(LOOKAHEAD_SIZE,     16) \
     TEST_DEFINE(LOOKAHEAD_SIZE,     16) \
     TEST_DEFINE(BLOCK_CYCLES,       -1) \
     TEST_DEFINE(BLOCK_CYCLES,       -1) \

+ 20 - 41
scripts/test.py

@@ -250,19 +250,19 @@ def compile(test_paths, **args):
                                     define_cbs[v] = name
                                     define_cbs[v] = name
                                     f.writeln('intmax_t %s('
                                     f.writeln('intmax_t %s('
                                         '__attribute__((unused)) '
                                         '__attribute__((unused)) '
-                                        'size_t define) {' % name)
+                                        'void *data) {' % name)
                                     f.writeln(4*' '+'return %s;' % v)
                                     f.writeln(4*' '+'return %s;' % v)
                                     f.writeln('}')
                                     f.writeln('}')
                                     f.writeln()
                                     f.writeln()
-                        f.writeln('intmax_t (*const *const '
-                            '__test__%s__%s__defines[])(size_t) = {'
+                        f.writeln('const test_define_t *const '
+                            '__test__%s__%s__defines[] = {'
                             % (suite.name, case.name))
                             % (suite.name, case.name))
                         for defines in case.permutations:
                         for defines in case.permutations:
-                            f.writeln(4*' '+'(intmax_t (*const['
-                                'TEST_IMPLICIT_DEFINE_COUNT+%d])(size_t)){' % (
+                            f.writeln(4*' '+'(const test_define_t['
+                                'TEST_IMPLICIT_DEFINE_COUNT+%d]){' % (
                                 len(suite.defines)))
                                 len(suite.defines)))
                             for k, v in sorted(defines.items()):
                             for k, v in sorted(defines.items()):
-                                f.writeln(8*' '+'[%-24s] = %s,' % (
+                                f.writeln(8*' '+'[%-24s] = {%s, NULL},' % (
                                     k+'_i', define_cbs[v]))
                                     k+'_i', define_cbs[v]))
                             f.writeln(4*' '+'},')
                             f.writeln(4*' '+'},')
                         f.writeln('};')
                         f.writeln('};')
@@ -321,8 +321,8 @@ def compile(test_paths, **args):
                         write_case_functions(f, suite, case)
                         write_case_functions(f, suite, case)
                     else:
                     else:
                         if case.defines:
                         if case.defines:
-                            f.writeln('extern intmax_t (*const *const '
-                                '__test__%s__%s__defines[])(size_t);'
+                            f.writeln('extern const test_define_t *const ' 
+                                '__test__%s__%s__defines[];'
                                 % (suite.name, case.name))
                                 % (suite.name, case.name))
                         if suite.if_ is not None or case.if_ is not None:
                         if suite.if_ is not None or case.if_ is not None:
                             f.writeln('extern bool __test__%s__%s__filter('
                             f.writeln('extern bool __test__%s__%s__filter('
@@ -472,7 +472,10 @@ def list_(runner, test_ids, **args):
     if args.get('list_suite_paths'): cmd.append('--list-suite-paths')
     if args.get('list_suite_paths'): cmd.append('--list-suite-paths')
     if args.get('list_case_paths'):  cmd.append('--list-case-paths')
     if args.get('list_case_paths'):  cmd.append('--list-case-paths')
     if args.get('list_defines'):     cmd.append('--list-defines')
     if args.get('list_defines'):     cmd.append('--list-defines')
-    if args.get('list_implicit'):    cmd.append('--list-implicit')
+    if args.get('list_permutation_defines'):
+                                     cmd.append('--list-permutation-defines')
+    if args.get('list_implicit_defines'):
+                                     cmd.append('--list-implicit-defines')
     if args.get('list_geometries'):  cmd.append('--list-geometries')
     if args.get('list_geometries'):  cmd.append('--list-geometries')
     if args.get('list_powerlosses'): cmd.append('--list-powerlosses')
     if args.get('list_powerlosses'): cmd.append('--list-powerlosses')
 
 
@@ -554,33 +557,8 @@ def find_path(runner_, id, **args):
     return path
     return path
 
 
 def find_defines(runner_, id, **args):
 def find_defines(runner_, id, **args):
-    # query implicit defines from runner
-    cmd = runner_ + ['--list-implicit']
-    if args.get('verbose'):
-        print(' '.join(shlex.quote(c) for c in cmd))
-    proc = sp.Popen(cmd,
-        stdout=sp.PIPE,
-        stderr=sp.PIPE if not args.get('verbose') else None,
-        universal_newlines=True,
-        errors='replace',
-        close_fds=False)
-    implicit_defines = co.OrderedDict()
-    pattern = re.compile('^(?P<define>\w+)=(?P<values>.+)')
-    for line in proc.stdout:
-        m = pattern.match(line)
-        if m:
-            define = m.group('define')
-            values = m.group('values').split(',')
-            implicit_defines[define] = set(values)
-    proc.wait()
-    if proc.returncode != 0:
-        if not args.get('verbose'):
-            for line in proc.stderr:
-                sys.stdout.write(line)
-        sys.exit(-1)
-
-    # query case defines from runner
-    cmd = runner_ + ['--list-defines', id]
+    # query permutation defines from runner
+    cmd = runner_ + ['--list-permutation-defines', id]
     if args.get('verbose'):
     if args.get('verbose'):
         print(' '.join(shlex.quote(c) for c in cmd))
         print(' '.join(shlex.quote(c) for c in cmd))
     proc = sp.Popen(cmd,
     proc = sp.Popen(cmd,
@@ -596,9 +574,7 @@ def find_defines(runner_, id, **args):
         if m:
         if m:
             define = m.group('define')
             define = m.group('define')
             value = m.group('value')
             value = m.group('value')
-            if (define not in implicit_defines
-                    or value not in implicit_defines[define]):
-                defines[define] = value
+            defines[define] = value
     proc.wait()
     proc.wait()
     if proc.returncode != 0:
     if proc.returncode != 0:
         if not args.get('verbose'):
         if not args.get('verbose'):
@@ -998,7 +974,8 @@ def main(**args):
             or args.get('list_suite_paths')
             or args.get('list_suite_paths')
             or args.get('list_case_paths')
             or args.get('list_case_paths')
             or args.get('list_defines')
             or args.get('list_defines')
-            or args.get('list_implicit')
+            or args.get('list_permutation_defines')
+            or args.get('list_implicit_defines')
             or args.get('list_geometries')
             or args.get('list_geometries')
             or args.get('list_powerlosses')):
             or args.get('list_powerlosses')):
         return list_(**args)
         return list_(**args)
@@ -1039,7 +1016,9 @@ if __name__ == "__main__":
         help="List the path and line number for each test case.")
         help="List the path and line number for each test case.")
     test_parser.add_argument('--list-defines', action='store_true',
     test_parser.add_argument('--list-defines', action='store_true',
         help="List all defines in this test-runner.")
         help="List all defines in this test-runner.")
-    test_parser.add_argument('--list-implicit', action='store_true',
+    test_parser.add_argument('--list-permutation-defines', action='store_true',
+        help="List explicit defines in this test-runner.")
+    test_parser.add_argument('--list-implicit-defines', action='store_true',
         help="List implicit defines in this test-runner.")
         help="List implicit defines in this test-runner.")
     test_parser.add_argument('--list-geometries', action='store_true',
     test_parser.add_argument('--list-geometries', action='store_true',
         help="List the available disk geometries.")
         help="List the available disk geometries.")

Some files were not shown because too many files changed in this diff