mirror of
https://github.com/littlefs-project/littlefs.git
synced 2026-02-04 14:45:26 +00:00
Added trace and persist flags to test_runner
This commit is contained in:
@ -14,7 +14,6 @@ import toml
|
||||
TEST_PATHS = ['tests_']
|
||||
|
||||
SUITE_PROLOGUE = """
|
||||
//////// AUTOGENERATED ////////
|
||||
#include "runners/test_runner.h"
|
||||
#include <stdio.h>
|
||||
"""
|
||||
@ -222,7 +221,21 @@ def compile(**args):
|
||||
suite = TestSuite(paths[0])
|
||||
if 'output' in args:
|
||||
with openio(args['output'], 'w') as f:
|
||||
f.write(SUITE_PROLOGUE)
|
||||
# redirect littlefs tracing
|
||||
f.write('#define LFS_TRACE_(fmt, ...) do { \\\n')
|
||||
f.write(8*' '+'extern FILE *test_trace; \\\n')
|
||||
f.write(8*' '+'if (test_trace) { \\\n')
|
||||
f.write(12*' '+'fprintf(test_trace, '
|
||||
'"%s:%d:trace: " fmt "%s\\n", \\\n')
|
||||
f.write(20*' '+'__FILE__, __LINE__, __VA_ARGS__); \\\n')
|
||||
f.write(8*' '+'} \\\n')
|
||||
f.write(4*' '+'} while (0)\n')
|
||||
f.write('#define LFS_TRACE(...) LFS_TRACE_(__VA_ARGS__, "")\n')
|
||||
f.write('#define LFS_TESTBD_TRACE(...) '
|
||||
'LFS_TRACE_(__VA_ARGS__, "")\n')
|
||||
f.write('\n')
|
||||
|
||||
f.write('%s\n' % SUITE_PROLOGUE.strip())
|
||||
f.write('\n')
|
||||
if suite.code is not None:
|
||||
if suite.code_lineno is not None:
|
||||
@ -380,6 +393,21 @@ def compile(**args):
|
||||
# write out a test source
|
||||
if 'output' in args:
|
||||
with openio(args['output'], 'w') as f:
|
||||
# redirect littlefs tracing
|
||||
f.write('#define LFS_TRACE_(fmt, ...) do { \\\n')
|
||||
f.write(8*' '+'extern FILE *test_trace; \\\n')
|
||||
f.write(8*' '+'if (test_trace) { \\\n')
|
||||
f.write(12*' '+'fprintf(test_trace, '
|
||||
'"%s:%d:trace: " fmt "%s\\n", \\\n')
|
||||
f.write(20*' '+'__FILE__, __LINE__, __VA_ARGS__); \\\n')
|
||||
f.write(8*' '+'} \\\n')
|
||||
f.write(4*' '+'} while (0)\n')
|
||||
f.write('#define LFS_TRACE(...) LFS_TRACE_(__VA_ARGS__, "")\n')
|
||||
f.write('#define LFS_TESTBD_TRACE(...) '
|
||||
'LFS_TRACE_(__VA_ARGS__, "")\n')
|
||||
f.write('\n')
|
||||
|
||||
# copy source
|
||||
f.write('#line 1 "%s"\n' % args['source'])
|
||||
with open(args['source']) as sf:
|
||||
shutil.copyfileobj(sf, f)
|
||||
|
||||
Reference in New Issue
Block a user