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`
pull/64/head
nirenjan 2026-03-16 15:56:38 -07:00
parent a1098bc134
commit b626a9367f
1 changed files with 31 additions and 29 deletions

View File

@ -21,39 +21,41 @@ level_class = ['nolvl', 'lvl']
backtrace_class = ['notr', 'tr'] backtrace_class = ['notr', 'tr']
test_files = [] test_files = []
test_name_template = '@0@-@1@-@2@-@3@' test_name_template = '-@0@-@1@-@2@'
foreach test_type: ['bench', 'test'] foreach date_arg: [0, 1]
test_src = test_type + '_pinelog.c' date_def = '-DPINELOG_SHOW_DATE=' + date_arg.to_string()
foreach date_arg: [0, 1] date_name = date_arg == 1 ? 'ts' : 'nots'
date_def = '-DPINELOG_SHOW_DATE=' + date_arg.to_string()
date_name = date_arg == 1 ? 'ts' : 'nots'
foreach level_arg: [0, 1] foreach level_arg: [0, 1]
level_def = '-DPINELOG_SHOW_LEVEL=' + level_arg.to_string() level_def = '-DPINELOG_SHOW_LEVEL=' + level_arg.to_string()
level_name = level_arg == 1 ? 'lvl' : 'nolvl' level_name = level_arg == 1 ? 'lvl' : 'nolvl'
foreach backtrace_arg: [0, 1] foreach backtrace_arg: [0, 1]
backtrace_def = '-DPINELOG_SHOW_BACKTRACE=' + backtrace_arg.to_string() backtrace_def = '-DPINELOG_SHOW_BACKTRACE=' + backtrace_arg.to_string()
backtrace_name = backtrace_arg == 1 ? 'tr' : 'notr' backtrace_name = backtrace_arg == 1 ? 'tr' : 'notr'
test_name = test_name_template.format(test_type, c_args = [
date_name, level_name, backtrace_name) '-DPINELOG_FATAL_STR="F"',
test_exe = executable(test_name, test_src, 'pinelog.c', '-DPINELOG_ERROR_STR="E"',
c_args: [ '-DPINELOG_WARNING_STR="W"',
'-DPINELOG_FATAL_STR="F"', '-DPINELOG_INFO_STR="I"',
'-DPINELOG_ERROR_STR="E"', '-DPINELOG_DEBUG_STR="D"',
'-DPINELOG_WARNING_STR="W"', '-DPINELOG_TRACE_STR="T"',
'-DPINELOG_INFO_STR="I"', '-DPINELOG_DEFAULT_LEVEL=PINELOG_LVL_TRACE',
'-DPINELOG_DEBUG_STR="D"', '-DPINELOG_DEFAULT_STREAM=stderr',
'-DPINELOG_TRACE_STR="T"', '-DPINELOG_TEST',
'-DPINELOG_DEFAULT_LEVEL=PINELOG_LVL_TRACE', date_def, level_def, backtrace_def
'-DPINELOG_DEFAULT_STREAM=stderr', ]
'-DPINELOG_TEST', test_name = test_name_template.format(
date_def, level_def, backtrace_def date_name, level_name, backtrace_name)
])
test(test_name, test_exe, protocol: 'tap') test_exe = executable('test' + test_name, 'test_pinelog.c', 'pinelog.c',
endforeach 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 endforeach
endforeach endforeach