diff options
author | Simon McVittie <smcv@collabora.com> | 2022-07-02 17:33:56 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2022-08-19 10:56:36 +0100 |
commit | 5a60c0bca5d91ba701ca4a2f9bcfae9eec65253b (patch) | |
tree | 1fa6c47ec84fd0db070ba4694aa137f4620f6cb9 | |
parent | 9a0e6fd00473ad2c529ec86249b48d88e893d165 (diff) | |
download | libglnx-5a60c0bca5d91ba701ca4a2f9bcfae9eec65253b.tar.gz |
Move assertion/test utilities to a separate header
A lot of recent convenience APIs can easily be backported, but they'll
clutter glnx-backports.h. In preparation, split these out.
Another reason to separate these is that when we start adding backports
of test utilities that need implementation code in the libglnx static
library, we'll want their implementations to be in a separate
translation unit, so that they don't get linked into production
executables, only into tests.
Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r-- | Makefile-libglnx.am | 1 | ||||
-rw-r--r-- | glnx-backport-testutils.h | 43 | ||||
-rw-r--r-- | glnx-backports.h | 12 | ||||
-rw-r--r-- | libglnx.h | 1 | ||||
-rw-r--r-- | meson.build | 1 |
5 files changed, 46 insertions, 12 deletions
diff --git a/Makefile-libglnx.am b/Makefile-libglnx.am index bea7b13..f699ff2 100644 --- a/Makefile-libglnx.am +++ b/Makefile-libglnx.am @@ -33,6 +33,7 @@ libglnx_la_SOURCES = \ $(libglnx_srcpath)/glnx-macros.h \ $(libglnx_srcpath)/glnx-backport-autocleanups.h \ $(libglnx_srcpath)/glnx-backport-autoptr.h \ + $(libglnx_srcpath)/glnx-backport-testutils.h \ $(libglnx_srcpath)/glnx-backports.h \ $(libglnx_srcpath)/glnx-backports.c \ $(libglnx_srcpath)/glnx-local-alloc.h \ diff --git a/glnx-backport-testutils.h b/glnx-backport-testutils.h new file mode 100644 index 0000000..f43c204 --- /dev/null +++ b/glnx-backport-testutils.h @@ -0,0 +1,43 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * Copyright 2015 Colin Walters <walters@verbum.org> + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#include <gio/gio.h> + +#include "glnx-backports.h" + +G_BEGIN_DECLS + +#ifndef g_assert_nonnull +#define g_assert_nonnull(x) g_assert (x != NULL) +#endif + +#ifndef g_assert_null +#define g_assert_null(x) g_assert (x == NULL) +#endif + +#if !GLIB_CHECK_VERSION (2, 38, 0) +#define g_test_skip(s) g_test_message ("SKIP: %s", s) +#endif + +G_END_DECLS diff --git a/glnx-backports.h b/glnx-backports.h index 6f766a3..b535e2d 100644 --- a/glnx-backports.h +++ b/glnx-backports.h @@ -84,16 +84,4 @@ gboolean glnx_set_object (GObject **object_ptr, #define G_OPTION_ENTRY_NULL { NULL, 0, 0, 0, NULL, NULL, NULL } #endif -#ifndef g_assert_nonnull -#define g_assert_nonnull(x) g_assert (x != NULL) -#endif - -#ifndef g_assert_null -#define g_assert_null(x) g_assert (x == NULL) -#endif - -#if !GLIB_CHECK_VERSION (2, 38, 0) -#define g_test_skip(s) g_test_message ("SKIP: %s", s) -#endif - G_END_DECLS @@ -29,6 +29,7 @@ G_BEGIN_DECLS #include <glnx-missing.h> #include <glnx-local-alloc.h> #include <glnx-backport-autocleanups.h> +#include <glnx-backport-testutils.h> #include <glnx-backports.h> #include <glnx-lockfile.h> #include <glnx-errors.h> diff --git a/meson.build b/meson.build index 4787c85..86535a8 100644 --- a/meson.build +++ b/meson.build @@ -57,6 +57,7 @@ libglnx_inc = include_directories('.') libglnx_sources = [ 'glnx-backport-autocleanups.h', 'glnx-backport-autoptr.h', + 'glnx-backport-testutils.h', 'glnx-backports.c', 'glnx-backports.h', 'glnx-console.c', |