[libglnx/wip/smcv/testing-helpers: 7/8] Move assertion/test utilities to a separate header
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libglnx/wip/smcv/testing-helpers: 7/8] Move assertion/test utilities to a separate header
- Date: Fri, 19 Aug 2022 10:01:35 +0000 (UTC)
commit 5a60c0bca5d91ba701ca4a2f9bcfae9eec65253b
Author: Simon McVittie <smcv collabora com>
Date: Sat Jul 2 17:33:56 2022 +0100
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>
Makefile-libglnx.am | 1 +
glnx-backport-testutils.h | 43 +++++++++++++++++++++++++++++++++++++++++++
glnx-backports.h | 12 ------------
libglnx.h | 1 +
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
diff --git a/libglnx.h b/libglnx.h
index ca82ba5..63d73ad 100644
--- a/libglnx.h
+++ b/libglnx.h
@@ -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',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]