Add test-cases that include sysprof headers into C++ code

Reproduces: https://gitlab.gnome.org/GNOME/sysprof/-/issues/114
Signed-off-by: Simon McVittie <smcv@debian.org>
This commit is contained in:
Simon McVittie
2024-02-24 11:36:59 +00:00
parent 36f4988ecc
commit b4a592a020
4 changed files with 67 additions and 8 deletions

View File

@ -21,6 +21,7 @@ libsysprof_capture_testsuite = {
'rewrite-pid' : {'skip': true}, 'rewrite-pid' : {'skip': true},
'test-capture' : {}, 'test-capture' : {},
'test-capture-cursor' : {}, 'test-capture-cursor' : {},
'test-cplusplus' : {'cpp': true},
'test-mapped-ring-buffer' : {}, 'test-mapped-ring-buffer' : {},
} }
@ -30,10 +31,18 @@ libsysprof_capture_testsuite_deps = [
] ]
foreach test, params: libsysprof_capture_testsuite foreach test, params: libsysprof_capture_testsuite
if params.get('cpp', false)
test_exe = executable(test, '@0@.cpp'.format(test),
cpp_args: libsysprof_capture_testsuite_c_args,
dependencies: libsysprof_capture_testsuite_deps,
)
else
test_exe = executable(test, '@0@.c'.format(test), test_exe = executable(test, '@0@.c'.format(test),
c_args: libsysprof_capture_testsuite_c_args, c_args: libsysprof_capture_testsuite_c_args,
dependencies: libsysprof_capture_testsuite_deps, dependencies: libsysprof_capture_testsuite_deps,
) )
endif
if not params.get('skip', false) if not params.get('skip', false)
test(test, test_exe, env: libsysprof_capture_test_env) test(test, test_exe, env: libsysprof_capture_test_env)
endif endif

View File

@ -0,0 +1,24 @@
/*
* Copyright 2024 Simon McVittie
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include <sysprof-capture.h>
#undef _NDEBUG
#include <assert.h>
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
int
main (UNUSED int argc,
UNUSED char *argv[])
{
assert (sysprof_getpagesize () > 0);
return 0;
}

View File

@ -16,6 +16,7 @@ libsysprof_testsuite = {
'test-allocs-by-func' : {'skip': true}, 'test-allocs-by-func' : {'skip': true},
'test-callgraph' : {'skip': true}, 'test-callgraph' : {'skip': true},
'test-capture-model' : {'skip': true}, 'test-capture-model' : {'skip': true},
'test-cplusplus' : {'cpp': true},
'test-elf-loader' : {'skip': true}, 'test-elf-loader' : {'skip': true},
'test-leak-detector' : {'skip': true}, 'test-leak-detector' : {'skip': true},
'test-list-counters' : {'skip': true}, 'test-list-counters' : {'skip': true},
@ -41,10 +42,18 @@ libsysprof_testsuite_deps = [
] ]
foreach test, params: libsysprof_testsuite foreach test, params: libsysprof_testsuite
if params.get('cpp', false)
test_exe = executable(test, '@0@.cpp'.format(test),
cpp_args: libsysprof_testsuite_c_args,
dependencies: libsysprof_testsuite_deps,
)
else
test_exe = executable(test, '@0@.c'.format(test), test_exe = executable(test, '@0@.c'.format(test),
c_args: libsysprof_testsuite_c_args, c_args: libsysprof_testsuite_c_args,
dependencies: libsysprof_testsuite_deps, dependencies: libsysprof_testsuite_deps,
) )
endif
if not params.get('skip', false) if not params.get('skip', false)
test(test, test_exe, env: libsysprof_test_env) test(test, test_exe, env: libsysprof_test_env)
endif endif

View File

@ -0,0 +1,17 @@
/*
* Copyright 2024 Simon McVittie
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include <sysprof.h>
#undef _NDEBUG
#include <assert.h>
int
main (G_GNUC_UNUSED int argc,
G_GNUC_UNUSED char *argv[])
{
assert (sysprof_callgraph_flags_get_type () != 0);
return 0;
}