From d3fe38295471aa52a9647d2fd78ff142071b669d Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 25 May 2023 17:10:37 -0700 Subject: [PATCH] libsysprof-profile: add test-profiler --- src/libsysprof-profile/tests/meson.build | 30 +++++++++++++ src/libsysprof-profile/tests/test-profiler.c | 45 ++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 src/libsysprof-profile/tests/test-profiler.c diff --git a/src/libsysprof-profile/tests/meson.build b/src/libsysprof-profile/tests/meson.build index e69de29b..f559ff7e 100644 --- a/src/libsysprof-profile/tests/meson.build +++ b/src/libsysprof-profile/tests/meson.build @@ -0,0 +1,30 @@ +libsysprof_profile_test_env = [ + 'G_DEBUG=gc-friendly', + 'GSETTINGS_BACKEND=memory', + 'MALLOC_CHECK_=2', +] + +libsysprof_profile_testsuite_c_args = [ + '-DG_LOG_DOMAIN="libdex"', + '-DG_ENABLE_DEBUG', + '-UG_DISABLE_ASSERT', + '-UG_DISABLE_CAST_CHECKS', +] + +libsysprof_profile_testsuite = { + 'test-profiler' : {'skip': true}, +} + +libsysprof_profile_testsuite_deps = [ + libsysprof_profile_static_dep, +] + +foreach test, params: libsysprof_profile_testsuite + test_exe = executable(test, '@0@.c'.format(test), + c_args: libsysprof_profile_testsuite_c_args, + dependencies: libsysprof_profile_testsuite_deps, + ) + if not params.get('skip', false) + test(test, test_exe, env: libsysprof_profile_test_env) + endif +endforeach diff --git a/src/libsysprof-profile/tests/test-profiler.c b/src/libsysprof-profile/tests/test-profiler.c new file mode 100644 index 00000000..ef1850af --- /dev/null +++ b/src/libsysprof-profile/tests/test-profiler.c @@ -0,0 +1,45 @@ +/* test-profiler.c + * + * Copyright 2023 Christian Hergert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include + +static char *capture_file; +static const GOptionEntry entries[] = { + { "capture", 'c', 0, G_OPTION_ARG_FILENAME, &capture_file, "The file to capture into", "CAPTURE" }, + { 0 } +}; + +int +main (int argc, + char *argv[]) +{ + g_autoptr(GOptionContext) context = g_option_context_new ("- Tests the SysprofProfiler"); + g_autoptr(GError) error = NULL; + + g_option_context_add_main_entries (context, entries, NULL); + + if (!g_option_context_parse (context, &argc, &argv, &error)) + { + g_printerr ("%s\n", error->message); + return 1; + } + + return 0; +}