summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJan Rybar <jrybar@redhat.com>2020-10-26 17:00:27 +0000
committerJan Rybar <jrybar@redhat.com>2020-10-26 17:00:27 +0000
commit957a015157fd359d9679540f664183e4b9492896 (patch)
tree41e7f5541d01e479e588cd3dd5a1769e1af0127a /test
parentff4c2144f0fb1325275887d9e254117fcd8a1b52 (diff)
downloadpolkit-957a015157fd359d9679540f664183e4b9492896.tar.gz
build: Port to meson build system
meson is a build system focused on speed an ease of use, which helps speeding up the software development. This patch adds meson support along autotools.
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am5
-rw-r--r--test/meson.build26
-rw-r--r--test/polkit/Makefile.am2
-rw-r--r--test/polkit/meson.build27
-rw-r--r--test/polkitbackend/Makefile.am2
-rw-r--r--test/polkitbackend/meson.build32
-rwxr-xr-xtest/polkitbackend/polkitbackendjsauthoritytest-wrapper.py23
7 files changed, 112 insertions, 5 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 59d0680..aacc892 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -6,7 +6,10 @@ noinst_LTLIBRARIES = libpolkit-test-helper.la
libpolkit_test_helper_la_SOURCES = polkittesthelper.c polkittesthelper.h
libpolkit_test_helper_la_LIBADD = $(GLIB_LIBS)
-EXTRA_DIST = data
+EXTRA_DIST = \
+ data \
+ meson.build \
+ $(NULL)
# Use mocklibc to override NSS services for tests
export MOCK_PASSWD := $(abs_top_srcdir)/test/data/etc/passwd
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..3f02d35
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,26 @@
+libpolkit_test_helper = static_library(
+ 'polkit-test-helper',
+ sources: 'polkittesthelper.c',
+ dependencies: glib_dep,
+)
+
+libpolkit_test_helper_dep = declare_dependency(
+ include_directories: '.',
+ dependencies: glib_dep,
+ link_with: libpolkit_test_helper,
+)
+
+libmocklibc = subproject('mocklibc').get_variable('libmocklibc')
+
+test_data_dir = meson.current_source_dir() / 'data'
+test_etc_dir = test_data_dir / 'etc'
+
+test_env = environment()
+test_env.set('LD_PRELOAD', libmocklibc.full_path())
+test_env.set('MOCK_PASSWD', test_etc_dir / 'passwd')
+test_env.set('MOCK_GROUP', test_etc_dir / 'group')
+test_env.set('MOCK_NETGROUP', test_etc_dir / 'netgroup')
+test_env.set('POLKIT_TEST_DATA', test_data_dir)
+
+subdir('polkit')
+subdir('polkitbackend')
diff --git a/test/polkit/Makefile.am b/test/polkit/Makefile.am
index 1e0a23f..261d1d5 100644
--- a/test/polkit/Makefile.am
+++ b/test/polkit/Makefile.am
@@ -48,6 +48,8 @@ polkitidentitytest_SOURCES = polkitidentitytest.c
check_PROGRAMS = $(TEST_PROGS)
TESTS = $(TEST_PROGS)
+EXTRA_DIST = meson.build
+
clean-local :
rm -f *~
diff --git a/test/polkit/meson.build b/test/polkit/meson.build
new file mode 100644
index 0000000..9c5254f
--- /dev/null
+++ b/test/polkit/meson.build
@@ -0,0 +1,27 @@
+test_units = [
+ 'polkitunixusertest',
+ 'polkitunixgrouptest',
+ 'polkitunixnetgrouptest',
+ 'polkitidentitytest',
+]
+
+c_flags = [
+ '-D_POLKIT_COMPILATION',
+ '-D_POLKIT_BACKEND_COMPILATION',
+]
+
+foreach test_unit: test_units
+ exe = executable(
+ test_unit,
+ test_unit + '.c',
+ dependencies: libpolkit_gobject_dep,
+ c_args: c_flags,
+ )
+
+ test(
+ test_unit,
+ exe,
+ env: test_env,
+ is_parallel: false,
+ )
+endforeach
diff --git a/test/polkitbackend/Makefile.am b/test/polkitbackend/Makefile.am
index b714c60..267a2d2 100644
--- a/test/polkitbackend/Makefile.am
+++ b/test/polkitbackend/Makefile.am
@@ -48,6 +48,8 @@ TEST_PROGS += polkitbackendjsauthoritytest-wrapper.py
noinst_PROGRAMS = polkitbackendjsauthoritytest
TESTS = $(TEST_PROGS)
+EXTRA_DIST = meson.build
+
clean-local :
rm -f *~
diff --git a/test/polkitbackend/meson.build b/test/polkitbackend/meson.build
new file mode 100644
index 0000000..98ba120
--- /dev/null
+++ b/test/polkitbackend/meson.build
@@ -0,0 +1,32 @@
+test_unit = 'test-polkitbackendjsauthority'
+
+deps = [
+ libpolkit_gobject_dep,
+ libpolkit_test_helper_dep,
+]
+
+c_flags = [
+ '-D_POLKIT_COMPILATION',
+ '-D_POLKIT_BACKEND_COMPILATION',
+]
+
+test_env.set('TOP_BUILD_DIR', build_root)
+test_env.set('TOP_SRC_DIR', source_root)
+
+exe = executable(
+ test_unit,
+ test_unit + '.c',
+ include_directories: top_inc,
+ dependencies: deps,
+ c_args: c_flags,
+ link_with: libpolkit_backend,
+)
+
+prog = find_program('polkitbackendjsauthoritytest-wrapper.py')
+
+test(
+ test_unit,
+ prog,
+ env: test_env,
+ is_parallel: false,
+)
diff --git a/test/polkitbackend/polkitbackendjsauthoritytest-wrapper.py b/test/polkitbackend/polkitbackendjsauthoritytest-wrapper.py
index 2a4e160..8e067eb 100755
--- a/test/polkitbackend/polkitbackendjsauthoritytest-wrapper.py
+++ b/test/polkitbackend/polkitbackendjsauthoritytest-wrapper.py
@@ -28,13 +28,22 @@ class TestPolkitBackendJsAuthority(dbusmock.DBusTestCase):
@classmethod
def setUpClass(klass):
klass.start_system_bus()
+ klass.mocklibc_path = None
- klass.top_build_dir = '../../'
if 'TOP_BUILD_DIR' in os.environ:
klass.top_build_dir = os.environ['TOP_BUILD_DIR']
- klass.mocklibc_path = klass.top_build_dir + '/test/mocklibc/bin/mocklibc'
- assert(os.path.exists(klass.mocklibc_path))
+ klass.mocklibc_path = klass.top_build_dir + '/subprojects/mocklibc-1.0/bin/mocklibc'
+
+ # suppose autotools over meson
+ if not os.path.exists(klass.mocklibc_path):
+ klass.top_build_dir = '../../'
+ klass.mocklibc_path = klass.top_build_dir + '/test/mocklibc/bin/mocklibc'
print ('Top build dir: %s' % klass.top_build_dir)
+ print ('mocklibc path: %s' % klass.mocklibc_path)
+ assert(os.path.exists(klass.mocklibc_path))
+
+ # WORKAROUND - unzipped mocklibc does not preserve file permissions
+ os.chmod(klass.mocklibc_path, 0o755)
klass.top_src_dir = os.path.dirname(os.path.realpath(__file__)) + '/../../'
if 'TOP_SRC_DIR' in os.environ:
@@ -54,7 +63,13 @@ class TestPolkitBackendJsAuthority(dbusmock.DBusTestCase):
def test_polkitbackendjsauthoritytest(self):
# Add '; exit 0' at the end of the cmd line if launching fails and you
# want to capture the error output
- out = subprocess.check_output(self.mocklibc_path + ' ' + self.top_build_dir + '/test/polkitbackend/polkitbackendjsauthoritytest',
+ test_path = self.top_build_dir + '/test/polkitbackend/test-polkitbackendjsauthority'
+
+ if not os.path.exists(test_path):
+ print('\n %s... not found' % test_path)
+ test_path = self.top_build_dir + '/test/polkitbackend/polkitbackendjsauthoritytest'
+
+ out = subprocess.check_output(self.mocklibc_path + ' ' + test_path,
stderr=subprocess.STDOUT,
shell=True,
universal_newlines=True)