[dconf: 1/6] tests: factor out abicheck from gsettings




commit 7bcd1b2acf965b3170d8340a7eced0eabe438ccf
Author: Daniel Playfair Cal <daniel playfair cal gmail com>
Date:   Mon May 4 16:44:27 2020 +1000

    tests: factor out abicheck from gsettings
    
    This will allow it to be used for other binaries

 gsettings/abicheck.sh | 26 --------------------------
 gsettings/meson.build | 14 --------------
 gsettings/symbols.txt |  3 +++
 tests/abicheck.sh     | 33 +++++++++++++++++++++++++++++++++
 tests/meson.build     | 16 ++++++++++++++++
 5 files changed, 52 insertions(+), 40 deletions(-)
---
diff --git a/gsettings/meson.build b/gsettings/meson.build
index a28892d9..ee0f723c 100644
--- a/gsettings/meson.build
+++ b/gsettings/meson.build
@@ -16,17 +16,3 @@ libdconf_settings = shared_library(
   install: true,
   install_dir: gio_module_dir,
 )
-
-envs = test_env + [
-  'G_TEST_SRCDIR=' + meson.current_source_dir(),
-  'G_TEST_BUILDDIR=' + meson.current_build_dir(),
-  'GSETTINGS_LIB=' + libdconf_settings.full_path(),
-]
-
-unit_test = 'abicheck'
-
-test(
-  unit_test,
-  find_program(unit_test + '.sh'),
-  env: envs,
-)
diff --git a/gsettings/symbols.txt b/gsettings/symbols.txt
new file mode 100644
index 00000000..0ac9e5e2
--- /dev/null
+++ b/gsettings/symbols.txt
@@ -0,0 +1,3 @@
+g_io_module_load
+g_io_module_query
+g_io_module_unload
diff --git a/tests/abicheck.sh b/tests/abicheck.sh
new file mode 100755
index 00000000..49291bdd
--- /dev/null
+++ b/tests/abicheck.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# The following checks that a given binary only defines the symbols
+# specified
+#
+# We also make sure to ignore gcov symbols included when building with
+# --coverage, which usually means the following:
+#
+# __gcov_error_file
+# __gcov_master
+# __gcov_sort_n_vals
+# __gcov_var
+#
+# And starting with gcc-9, also this one:
+#
+# mangle_path
+
+set -x
+
+if test $# != 2; then
+    echo "  Usage: $0 <binary> <symbol_file>"
+    echo "  symbol_file is a file where each line is the name of an exported symbol"
+    exit 1
+fi
+
+BINARY="$1"
+SYMBOL_FILE="$2"
+
+${NM:-nm} --dynamic --defined-only "$BINARY" | \
+    cut -f 3 -d ' ' | \
+    grep -v ^_ | \
+    grep -v ^mangle_path | \
+    diff "$SYMBOL_FILE" -
diff --git a/tests/meson.build b/tests/meson.build
index 0d4260f1..0992435e 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -48,6 +48,22 @@ foreach unit_test: unit_tests
   test(unit_test[0], exe, is_parallel: false, env: envs)
 endforeach
 
+symbol_test = find_program('abicheck.sh')
+
+abi_tests = [
+  ['gsettings', libdconf_settings, files('../gsettings/symbols.txt')[0]]
+]
+
+foreach abi_test: abi_tests
+  test(
+    abi_test[0],
+    symbol_test,
+    env: envs,
+    args: [abi_test[1].full_path(), abi_test[2]],
+  )
+endforeach
+
+
 python3 = find_program('python3', required: false)
 dbus_daemon = find_program('dbus-daemon', required: false)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]