mirror of
https://github.com/littlefs-project/littlefs.git
synced 2025-12-09 17:12:40 +00:00
Tweaked test.py/bench.py to allow no suites to test compilation
This is mainly to allow bench_runner to at least compile after moving benches out of tree. Also cleaned up lingering runner/suite munging leftover from the change to an optional -R/--runner parameter.
This commit is contained in:
@@ -28,7 +28,7 @@ import time
|
|||||||
import toml
|
import toml
|
||||||
|
|
||||||
|
|
||||||
RUNNER_PATH = './runners/bench_runner'
|
RUNNER_PATH = ['./runners/bench_runner']
|
||||||
HEADER_PATH = 'runners/bench_runner.h'
|
HEADER_PATH = 'runners/bench_runner.h'
|
||||||
|
|
||||||
GDB_PATH = ['gdb']
|
GDB_PATH = ['gdb']
|
||||||
@@ -266,16 +266,12 @@ def compile(bench_paths, **args):
|
|||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
path = path + '/*.toml'
|
path = path + '/*.toml'
|
||||||
|
|
||||||
for path in glob.glob(path):
|
if '*' in path:
|
||||||
|
for path in glob.glob(path):
|
||||||
|
paths.append(path)
|
||||||
|
else:
|
||||||
paths.append(path)
|
paths.append(path)
|
||||||
|
|
||||||
if not paths:
|
|
||||||
print('%serror:%s no bench suites found in %r?' % (
|
|
||||||
'\x1b[01;31m' if args['color'] else '',
|
|
||||||
'\x1b[m' if args['color'] else '',
|
|
||||||
bench_paths))
|
|
||||||
sys.exit(-1)
|
|
||||||
|
|
||||||
# load the suites
|
# load the suites
|
||||||
suites = [BenchSuite(path, args) for path in paths]
|
suites = [BenchSuite(path, args) for path in paths]
|
||||||
|
|
||||||
@@ -597,13 +593,15 @@ def compile(bench_paths, **args):
|
|||||||
# will be linked
|
# will be linked
|
||||||
for suite in suites:
|
for suite in suites:
|
||||||
f.writeln('extern const struct bench_suite '
|
f.writeln('extern const struct bench_suite '
|
||||||
'__bench__%s__suite;' % suite.name);
|
'__bench__%s__suite;' % suite.name)
|
||||||
f.writeln()
|
f.writeln()
|
||||||
|
|
||||||
f.writeln('__attribute__((weak))')
|
f.writeln('__attribute__((weak))')
|
||||||
f.writeln('const struct bench_suite *const bench_suites[] = {');
|
f.writeln('const struct bench_suite *const bench_suites[] = {');
|
||||||
for suite in suites:
|
for suite in suites:
|
||||||
f.writeln(4*' '+'&__bench__%s__suite,' % suite.name);
|
f.writeln(4*' '+'&__bench__%s__suite,' % suite.name)
|
||||||
|
if len(suites) == 0:
|
||||||
|
f.writeln(4*' '+'0,')
|
||||||
f.writeln('};')
|
f.writeln('};')
|
||||||
f.writeln('__attribute__((weak))')
|
f.writeln('__attribute__((weak))')
|
||||||
f.writeln('const size_t bench_suite_count = %d;' % len(suites))
|
f.writeln('const size_t bench_suite_count = %d;' % len(suites))
|
||||||
@@ -1541,6 +1539,7 @@ if __name__ == "__main__":
|
|||||||
bench_parser.add_argument(
|
bench_parser.add_argument(
|
||||||
'-R', '--runner',
|
'-R', '--runner',
|
||||||
type=lambda x: x.split(),
|
type=lambda x: x.split(),
|
||||||
|
default=RUNNER_PATH,
|
||||||
help="Bench runner to use for benching. Defaults to %r." % RUNNER_PATH)
|
help="Bench runner to use for benching. Defaults to %r." % RUNNER_PATH)
|
||||||
bench_parser.add_argument(
|
bench_parser.add_argument(
|
||||||
'-Y', '--summary',
|
'-Y', '--summary',
|
||||||
@@ -1729,11 +1728,9 @@ if __name__ == "__main__":
|
|||||||
'-o', '--output',
|
'-o', '--output',
|
||||||
help="Output file.")
|
help="Output file.")
|
||||||
|
|
||||||
# runner/bench_paths overlap, so need to do some munging here
|
# do the thing
|
||||||
args = parser.parse_intermixed_args()
|
args = parser.parse_intermixed_args()
|
||||||
args.bench_paths = [' '.join(args.runner or [])] + args.bench_ids
|
args.bench_paths = args.bench_ids
|
||||||
args.runner = args.runner or [RUNNER_PATH]
|
|
||||||
|
|
||||||
sys.exit(main(**{k: v
|
sys.exit(main(**{k: v
|
||||||
for k, v in vars(args).items()
|
for k, v in vars(args).items()
|
||||||
if v is not None}))
|
if v is not None}))
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import time
|
|||||||
import toml
|
import toml
|
||||||
|
|
||||||
|
|
||||||
RUNNER_PATH = './runners/test_runner'
|
RUNNER_PATH = ['./runners/test_runner']
|
||||||
HEADER_PATH = 'runners/test_runner.h'
|
HEADER_PATH = 'runners/test_runner.h'
|
||||||
|
|
||||||
GDB_PATH = ['gdb']
|
GDB_PATH = ['gdb']
|
||||||
@@ -271,16 +271,12 @@ def compile(test_paths, **args):
|
|||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
path = path + '/*.toml'
|
path = path + '/*.toml'
|
||||||
|
|
||||||
for path in glob.glob(path):
|
if '*' in path:
|
||||||
|
for path in glob.glob(path):
|
||||||
|
paths.append(path)
|
||||||
|
else:
|
||||||
paths.append(path)
|
paths.append(path)
|
||||||
|
|
||||||
if not paths:
|
|
||||||
print('%serror:%s no test suites found in %r?' % (
|
|
||||||
'\x1b[01;31m' if args['color'] else '',
|
|
||||||
'\x1b[m' if args['color'] else '',
|
|
||||||
test_paths))
|
|
||||||
sys.exit(-1)
|
|
||||||
|
|
||||||
# load the suites
|
# load the suites
|
||||||
suites = [TestSuite(path, args) for path in paths]
|
suites = [TestSuite(path, args) for path in paths]
|
||||||
|
|
||||||
@@ -604,13 +600,15 @@ def compile(test_paths, **args):
|
|||||||
# will be linked
|
# will be linked
|
||||||
for suite in suites:
|
for suite in suites:
|
||||||
f.writeln('extern const struct test_suite '
|
f.writeln('extern const struct test_suite '
|
||||||
'__test__%s__suite;' % suite.name);
|
'__test__%s__suite;' % suite.name)
|
||||||
f.writeln()
|
f.writeln()
|
||||||
|
|
||||||
f.writeln('__attribute__((weak))')
|
f.writeln('__attribute__((weak))')
|
||||||
f.writeln('const struct test_suite *const test_suites[] = {');
|
f.writeln('const struct test_suite *const test_suites[] = {')
|
||||||
for suite in suites:
|
for suite in suites:
|
||||||
f.writeln(4*' '+'&__test__%s__suite,' % suite.name);
|
f.writeln(4*' '+'&__test__%s__suite,' % suite.name)
|
||||||
|
if len(suites) == 0:
|
||||||
|
f.writeln(4*' '+'0,')
|
||||||
f.writeln('};')
|
f.writeln('};')
|
||||||
f.writeln('__attribute__((weak))')
|
f.writeln('__attribute__((weak))')
|
||||||
f.writeln('const size_t test_suite_count = %d;' % len(suites))
|
f.writeln('const size_t test_suite_count = %d;' % len(suites))
|
||||||
@@ -1464,6 +1462,7 @@ if __name__ == "__main__":
|
|||||||
test_parser.add_argument(
|
test_parser.add_argument(
|
||||||
'-R', '--runner',
|
'-R', '--runner',
|
||||||
type=lambda x: x.split(),
|
type=lambda x: x.split(),
|
||||||
|
default=RUNNER_PATH,
|
||||||
help="Test runner to use for testing. Defaults to %r." % RUNNER_PATH)
|
help="Test runner to use for testing. Defaults to %r." % RUNNER_PATH)
|
||||||
test_parser.add_argument(
|
test_parser.add_argument(
|
||||||
'-Y', '--summary',
|
'-Y', '--summary',
|
||||||
@@ -1671,11 +1670,9 @@ if __name__ == "__main__":
|
|||||||
'-o', '--output',
|
'-o', '--output',
|
||||||
help="Output file.")
|
help="Output file.")
|
||||||
|
|
||||||
# runner/test_paths overlap, so need to do some munging here
|
# do the thing
|
||||||
args = parser.parse_intermixed_args()
|
args = parser.parse_intermixed_args()
|
||||||
args.test_paths = [' '.join(args.runner or [])] + args.test_ids
|
args.test_paths = args.test_ids
|
||||||
args.runner = args.runner or [RUNNER_PATH]
|
|
||||||
|
|
||||||
sys.exit(main(**{k: v
|
sys.exit(main(**{k: v
|
||||||
for k, v in vars(args).items()
|
for k, v in vars(args).items()
|
||||||
if v is not None}))
|
if v is not None}))
|
||||||
|
|||||||
Reference in New Issue
Block a user