mirror of https://github.com/nirenjan/pinelog.git
fix(pinelog): Mark benchmark tests as such in Meson
Prior to this change, the pinelog benchmark suite was running as a regular test, however, this is not ideal since it can result in timing issues and giving false data to the runners. This change explicitly marks them as benchmarks, so they can run using `meson test --benchmark`switch-to-meson
parent
8a5a431635
commit
05ecc7698e
60
meson.build
60
meson.build
|
|
@ -21,39 +21,41 @@ level_class = ['nolvl', 'lvl']
|
|||
backtrace_class = ['notr', 'tr']
|
||||
|
||||
test_files = []
|
||||
test_name_template = '@0@-@1@-@2@-@3@'
|
||||
foreach test_type: ['bench', 'test']
|
||||
test_src = test_type + '_pinelog.c'
|
||||
foreach date_arg: [0, 1]
|
||||
date_def = '-DPINELOG_SHOW_DATE=' + date_arg.to_string()
|
||||
date_name = date_arg == 1 ? 'ts' : 'nots'
|
||||
test_name_template = '-@0@-@1@-@2@'
|
||||
foreach date_arg: [0, 1]
|
||||
date_def = '-DPINELOG_SHOW_DATE=' + date_arg.to_string()
|
||||
date_name = date_arg == 1 ? 'ts' : 'nots'
|
||||
|
||||
foreach level_arg: [0, 1]
|
||||
level_def = '-DPINELOG_SHOW_LEVEL=' + level_arg.to_string()
|
||||
level_name = level_arg == 1 ? 'lvl' : 'nolvl'
|
||||
foreach level_arg: [0, 1]
|
||||
level_def = '-DPINELOG_SHOW_LEVEL=' + level_arg.to_string()
|
||||
level_name = level_arg == 1 ? 'lvl' : 'nolvl'
|
||||
|
||||
foreach backtrace_arg: [0, 1]
|
||||
backtrace_def = '-DPINELOG_SHOW_BACKTRACE=' + backtrace_arg.to_string()
|
||||
backtrace_name = backtrace_arg == 1 ? 'tr' : 'notr'
|
||||
foreach backtrace_arg: [0, 1]
|
||||
backtrace_def = '-DPINELOG_SHOW_BACKTRACE=' + backtrace_arg.to_string()
|
||||
backtrace_name = backtrace_arg == 1 ? 'tr' : 'notr'
|
||||
|
||||
test_name = test_name_template.format(test_type,
|
||||
date_name, level_name, backtrace_name)
|
||||
test_exe = executable(test_name, test_src, 'pinelog.c',
|
||||
c_args: [
|
||||
'-DPINELOG_FATAL_STR="F"',
|
||||
'-DPINELOG_ERROR_STR="E"',
|
||||
'-DPINELOG_WARNING_STR="W"',
|
||||
'-DPINELOG_INFO_STR="I"',
|
||||
'-DPINELOG_DEBUG_STR="D"',
|
||||
'-DPINELOG_TRACE_STR="T"',
|
||||
'-DPINELOG_DEFAULT_LEVEL=PINELOG_LVL_TRACE',
|
||||
'-DPINELOG_DEFAULT_STREAM=stderr',
|
||||
'-DPINELOG_TEST',
|
||||
date_def, level_def, backtrace_def
|
||||
])
|
||||
c_args = [
|
||||
'-DPINELOG_FATAL_STR="F"',
|
||||
'-DPINELOG_ERROR_STR="E"',
|
||||
'-DPINELOG_WARNING_STR="W"',
|
||||
'-DPINELOG_INFO_STR="I"',
|
||||
'-DPINELOG_DEBUG_STR="D"',
|
||||
'-DPINELOG_TRACE_STR="T"',
|
||||
'-DPINELOG_DEFAULT_LEVEL=PINELOG_LVL_TRACE',
|
||||
'-DPINELOG_DEFAULT_STREAM=stderr',
|
||||
'-DPINELOG_TEST',
|
||||
date_def, level_def, backtrace_def
|
||||
]
|
||||
test_name = test_name_template.format(
|
||||
date_name, level_name, backtrace_name)
|
||||
|
||||
test(test_name, test_exe, protocol: 'tap')
|
||||
endforeach
|
||||
test_exe = executable('test' + test_name, 'test_pinelog.c', 'pinelog.c',
|
||||
c_args: c_args)
|
||||
test('test' + test_name, test_exe, protocol: 'tap')
|
||||
|
||||
bench_exe = executable('bench' + test_name, 'bench_pinelog.c', 'pinelog.c',
|
||||
c_args: c_args)
|
||||
benchmark('bench' + test_name, bench_exe, protocol: 'tap')
|
||||
endforeach
|
||||
endforeach
|
||||
endforeach
|
||||
|
|
|
|||
Loading…
Reference in New Issue